View Full Version : Emerald Theme Change Script (Was: How Emerald Manages it's themes)
Arcnsparc
January 11th, 2008, 01:14 AM
Does anyone know or know where to find how the Emerald Theme manager actually manages the themes it uses? I ask because in an attempt to script a change to the current emerald theme. I haven't found a way to do it yet but I have ideas. One way might be swapping out the theme file before emerald starts. I still need to test this by finding where emerald keeps its configuration and theme info after I import the themes.
Dbus might work but I haven't seen anything about this when searching for info on it.
The other way might be to open up the emerald theme manager with a command (i dont know what the command is) and then somehow macro the theme selection into it via key commands. The search function might be useful for this, but this is out of my league and probably not the way to go about an automatic theme change.
I welcome any and all ideas! Thanks!
some-guy
January 11th, 2008, 01:54 AM
It actually uses a kind of hacky method, it replaces ~/.emerald/theme with the contents of ~/.emerald/themes/themename :)
Arcnsparc
January 11th, 2008, 04:19 AM
So for a script to change the emerald theme, i would:
turn off emerald
replace the contents of the theme folder with the contents of the new theme folder
then restart emerald
sound about right?
my only worry is that it will mess with the theme manager, but i dont think it will
Here is my script, i have to try a different version to see if it will work first but i think it will:
#Turn off compiz
metacity --replace
#delete old theme folder
rm /home/jake/.emerald/theme
#copy & paste new theme folder to .emerald
cp /home/jake/.emerald/themes/NEWTHEME /home/jake/.emerald
#rename new theme to "theme"
mv /home/jake/.emerald/NEWTHEME /home/jake/.emerald/theme
sleep 1
# Restart Compiz
compiz --replace ccp &
Ill get back with results in a bit, thanks for showing me where the emerald stuff was that is awesome!
Deciare
January 11th, 2008, 04:39 AM
You don't need to kill the compiz process; only emerald. Also, restarting emerald after you finish copying the files is fine; there's no need to kill it before that.
Your rm command will also not work on a directory because it's missing the -r parameter, which tells it to delete files recursively.
Your cp command also needs -r for the same reason, and you didn't include "theme" at the end of the destination folder. Including that as part of the copy command saves you from having to rename it later.
Also, you can use "~" as an alias for your home directory.
And let's accept NEWTHEME as a parameter instead of hardcoding it. :)
With all that in mind, here is how I propose you modify your script:
newtheme="$@"
if [ -z "$newtheme" ]; then
echo "Usage: $0 <name of new theme>"
exit 1
fi
#delete old theme folder
rm -rf ~/.emerald/theme
#copy & paste new theme folder to .emerald
cp -r ~/.emerald/themes/"$newtheme" ~/.emerald/theme
sleep 1
# Restart Emerald
emerald --replace &
SmSpillaz
January 11th, 2008, 04:44 AM
I've moved this to Application Development as a script is starting to be developed.
Deciare
January 13th, 2008, 03:59 AM
Oops, I made a pretty significant mistake in that script. None of the themes that come with the emerald-themes package are in your home directory, so we need to check /usr/share/themes/emerald and /usr/local/share/themes/emerald as well.
#!/bin/bash
newtheme="$@"
if [ -z "$newtheme" ]; then
echo "Usage: $0 <name of new theme>"
exit 1
fi
#delete old theme folder
rm -rf ~/.emerald/theme
#copy & paste new theme folder to .emerald
if [ -e ~/.emerald/themes/"$newtheme" ]; then
cp -r ~/.emerald/themes/"$newtheme" ~/.emerald/theme
elif [ -e /usr/share/emerald/themes/"$newtheme" ]; then
cp -r /usr/share/emerald/themes/"$newtheme" ~/.emerald/theme
elif [ -e /usr/local/share/emerald/themes/"$newtheme" ]; then
cp -r /usr/local/share/emerald/themes/"$newtheme" ~/.emerald/theme
else
echo "There is no theme named \"$newtheme\"."
exit 1
fi
sleep 1
# Restart Emerald
emerald --replace &
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.