TIP Rotating GDM Themes
From Gentoo Linux Wiki
This article is still a Stub. You can help Gentoo-Wiki by expanding it.
| Terminals / Shells • Network • X Window System • Portage • System • Filesystems • Kernel • Other |
Contents |
[edit] GDM Themes
Normally you have just one GDM theme everytime you startup GDM. If you have your own theme it gets a bit better, but you will still have just one theme every time. The folowing are two methods to change that. The first one is a bash dependant randomizing script, it just has the tendency to choose some themes more then other ones. That is something that I didn't like about it. The second one is a non bash dependant rotation script, it goes from the first to the last and to the first theme again. I must warn you that neither script has no error checking what so ever. Nor do they have any comments, they just do what they are supposed to do; probably in some ugly way. But the result will be a different theme every time that you start GDM.
[edit] General modifications
These scripts just require you to only change one config file, which would be /etc/X11/gdm/Init/Default. Add a line which says to run the script, wherever you put it. Change it from:
OLD_IFS=$IFS
gdmwhich () { COMMAND="$1"
So it looks something like this:
OLD_IFS=$IFS
/usr/sbin/rotate_gdm_theme gdmwhich () { COMMAND="$1"
[edit] The Randomizing script
This is the most simple script of the two, all it does is take one name from the output of ls and use sed to change one line in /etc/X11/gdm/gdm.conf
#!/bin/bash # put in /etc/X11/gdm/Init/Default for gnome startup # sed will segfault if it doesn't have permission # to read gdm.conf so let's check: if [ `whoami` == "root" ]; then THEME_DIR=/usr/share/gdm/themes THEMES=`ls -1 "$THEME_DIR"` N=`echo $THEMES | wc -w` ((N=RANDOM%N+1)) # The -i.old option creates a backup copy called # gdm.conf.old sed -i.old s/GraphicalTheme=.*/GraphicalTheme=`echo $THEMES | cut -d ' ' -f $N`/ /etc/X11/gdm/gdm.conf else echo "You must be root to run this script." fi
[edit] The Rotation script
For this to work you will have to change some more stuff, because of the way it is designed (to just work). If you do not change the things as stated at the top in the script it will horribly fail and continue the while-loop infinitely. The positive sides of this script are that it will use every theme at a time and it is not bash dependant (for systems that do not have bash).
#!/bin/sh
# put in /etc/X11/gdm/Init/Default for gnome startup
# sed will segfault if it doesn't have permission
# to read gdm.conf.
#
# In /etc/X11/gdm/gdm.conf edit the folowing lines:
# GraphicalTheme=default
# GraphicalThemeDir=/usr/share/gdm/
# Also make sure that you already have a link to /usr/share/gdm/default
THEME_DIR=/usr/share/gdm/themes
THEMES=`ls -1 "$THEME_DIR"`
N=`echo $THEMES | wc -w`
LINK_DEST=/usr/share/gdm/default
CURRENT_FILE=""
I=1
wanted=0
THEME=""
current_file()
{
CURRENT_FILE=`ls -dl $LINK_DEST|cut -d '>' -f2`
CURRENT_FILE=`basename $CURRENT_FILE`
}
link_file()
{
rm -f $LINK_DEST
ln -s /usr/share/gdm/themes/${THEME} ${LINK_DEST}
}
choose()
{
current_file
while :;do
for j in ${THEMES}
do
if [ "${j}" == "${CURRENT_FILE}" ]; then wanted=$(($I+1)); fi
if [ $wanted -eq $N ]; then wanted=1; fi
if [ ${wanted} -eq ${I} ]; then THEME=${j}; link_file; exit; fi
I=$(($I+1))
done
done
}
if [ `whoami` == "root" ]; then
choose
else
echo "You must be root to run this script."
fi
[edit] Final notes
If you folow the guidelines it will work, as it does with me. Use the discussion page if not. So if you have a lot of themes this will be your chance to view them all without manually changing them every time.
