Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old April 12th, 2008   #1
kirsis
Just Give Me the Beans!
 
kirsis's Avatar
 
Join Date: Dec 2006
Location: Riga, Latvia
Beans: 74
Ubuntu Karmic Koala (testing)
Send a message via MSN to kirsis Send a message via Skype™ to kirsis
Lightbulb HOWTO: (GDM) Show the user wallpaper/background color, while logging in

EDIT: An improved, multi-user friendly version available on page 3. Clickity:
http://ubuntuforums.org/showthread.p...33#post5427233
-----------------------------------


One of my pet peeves with GDM has been that after logging in, it always turns the screen to a certain color (default = light brown, though this can be changed).

I feel that showing the users wallpaper or the users background color, while starting up the session, feels more polished. Here's how to achieve it, if you feel the same way:

1) We need the install the package xloadimage, which contains the app 'xsetbg'

Code:
sudo aptitude install xloadimage
2) Create the script that will set the background immediately after entering your username/password:

Code:
sudo gedit /etc/gdm/PostLogin/Default
Paste the following code in this file:

Code:
#!/bin/sh
#
# Note that output goes into the .xsession-errors file for easy debugging
#
# Extract the wallpaper filename
WALLPAPER="`cat ~/.gconf/desktop/gnome/background/%gconf.xml | sed -n -e 'N
s/^[ \t]*<entry name="picture_filename".*\n[ \t]*<stringvalue>\(.*\)<\/stringvalue>.*$/\1/ip'`"

# Check if the wallpaper file exists. If yes - draw it, if no - use primary background color
if [ -e "$WALLPAPER" ] && [ -f "$WALLPAPER" ] ; then
	xsetbg -onroot "$WALLPAPER"
else
	
	PRIMARY_COLOR="`cat ~/.gconf/desktop/gnome/background/%gconf.xml | sed -n -e 'N
s/^[ \t]*<entry name="primary_color".*\n[ \t]*<stringvalue>\(.*\)<\/stringvalue>.*$/\1/ip'`"
	xsetroot -cursor_name left_ptr -solid "$PRIMARY_COLOR"
fi

exit 0
(P.S. If you have a tiled background, add the '-tile' switch to the line that executes 'xsetbg')

This script will check for a wallpaper setting, and use 'xsetbg' to draw it to the root window. If a wallpaper image does not exist, it will fill the screen with the desktop background color.


Don't forget to make this script executable:

Code:
sudo chmod +x /etc/gdm/PostLogin/Default
Now the only step left is to remove the /etc/gdm/PreSession/Default file. This is the file that sets the root window color and it executes after the PostLogin file, so just move it out of the way:

Code:
sudo mv -v /etc/gdm/PreSession/Default /etc/gdm/PreSession/Default.bak
There you go. Now while logging in you should be seeing your background color/wallpaper, instead of the gdm background color.

Problems

There are three problems that this script doesn't or can't handle.

1) If you use a gradient as your desktop background, it will not be displayed. The screen will be filled with just one color (the primary color in the gradient)

2) If your wallpaper is scaled to fit, I suggest you resize it so that it matches your desktop as this script will not do that for you. You can, in theory, use the '-background' switch, coupled with '-border black', '-smooth' and (for png's) '-gamma 2.0', but I've found that 'xsetbg' can't properly scale to fit a lot of images (depending on their resolution, it may leave empty vertical/horizontal space at the edges) and the quality of scaled images is sub-par. I suggest you just resize the wallpaper to fit your resolution in GIMP.

3) If you use desktop effects then at one point the desktop might turn black. I haven't figured out yet, how to avoid this.





There you go, I hope this is useful for somebody
(Tested on Hardy Heron, but should work on older versions too.)


Update: Instructions on how to reverse the modifications

If for some reason the script isn't working out for you (due to the black screen problem or for whatever other reason), you can revert the effect with:

Code:
sudo rm /etc/gdm/PostLogin/Default
sudo mv /etc/gdm/PreSession/Default.bak /etc/gdm/PreSession/Default
The first line deletes the file that sets the background and the other line restores the original gdm script.

Last edited by kirsis; July 21st, 2008 at 02:59 AM.. Reason: Updated instructions
kirsis is offline   Reply With Quote
Old April 14th, 2008   #2
aashay
Way Too Much Ubuntu
 
aashay's Avatar
 
Join Date: Feb 2007
Location: India
Beans: 291
Ubuntu 7.10 Gutsy Gibbon
Send a message via MSN to aashay
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

Quote:
Originally Posted by kirsis View Post
Don't forget to make this script executable:

Code:
sudo chmod +x /etc/gdm/PreSession/Default
Shouldn't this be the PostSession file?
aashay is offline   Reply With Quote
Old April 14th, 2008   #3
kirsis
Just Give Me the Beans!
 
kirsis's Avatar
 
Join Date: Dec 2006
Location: Riga, Latvia
Beans: 74
Ubuntu Karmic Koala (testing)
Send a message via MSN to kirsis Send a message via Skype™ to kirsis
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

Damn, ADHD strikes again

The PostLogin/Default file has to be executable, thanks for catching that
kirsis is offline   Reply With Quote
Old April 14th, 2008   #4
Eclipse.
Way Too Much Ubuntu
 
Join Date: Mar 2007
Location: Glasgow
Beans: 285
Ubuntu Jaunty Jackalope (testing)
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

I have been looking for something like this for ages.

I even asked for something simliar to be intergrated into gutsy at the time.

Thanks.
Eclipse. is offline   Reply With Quote
Old April 14th, 2008   #5
liquid circuit
5 Cups of Ubuntu
 
Join Date: Jun 2007
Beans: 44
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

Worked perfectly (after I resized my wallpaper to my resolution, as you suggested)!!! I have compiz enabled, and the graphical blinks/redraws are minimal (using a ATI Radeon 9200).
liquid circuit is offline   Reply With Quote
Old April 15th, 2008   #6
kirsis
Just Give Me the Beans!
 
kirsis's Avatar
 
Join Date: Dec 2006
Location: Riga, Latvia
Beans: 74
Ubuntu Karmic Koala (testing)
Send a message via MSN to kirsis Send a message via Skype™ to kirsis
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

Glad you like it, guys

The compiz effect differs from PC to PC. For me the screen turns black for a few seconds, but for my buddy, who is also using this trick + compiz, the screen doesn't turn black at any point.
kirsis is offline   Reply With Quote
Old April 15th, 2008   #7
MeURi
A Carafe of Ubuntu
 
MeURi's Avatar
 
Join Date: Mar 2008
Location: Vimercate (MI), Italy
Beans: 126
Ubuntu 8.10 Intrepid Ibex
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

I'm running Hardy, and I already get this "effect" out of the box, by just setting the login background as my desktop background (speaking of colors)

Instead, following your how-to just gives me a black screen until gnome is fully loaded

Btw: I too noticed that compiz turns the background black, but it happens just sometimes
__________________
2B OR (NOT 2B) That is the question. The answer is FF
MeURi is offline   Reply With Quote
Old April 15th, 2008   #8
kirsis
Just Give Me the Beans!
 
kirsis's Avatar
 
Join Date: Dec 2006
Location: Riga, Latvia
Beans: 74
Ubuntu Karmic Koala (testing)
Send a message via MSN to kirsis Send a message via Skype™ to kirsis
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

Setting the log in screen background to your desktop doesnt work as nicely for multiple users on one computer. This way every user sees his/her wallpaper + you dont have to think about matching gdm themes/backgrounds

It's odd that you got a persistent black screen. Is your desktop background color set to black (if its not using a wallpaper)? It appears to me that xsetbg fails to find your wallpaper and instead sets your desktop to the primary background color.

If your background color is not black, then it must be some external effect, because AFAIK if xsetbg failed, you should be seeing what you always saw before it.


At any rate, you can revert to your previous configuration with:

Code:
sudo rm /etc/gdm/PostLogin/Default
sudo mv /etc/gdm/PreSession/Default.bak /etc/gdm/PreSession/Default
kirsis is offline   Reply With Quote
Old April 15th, 2008   #9
gsiliceo
Ubuntu Extra Shot
 
Join Date: Mar 2007
My beans are hidden!
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

Why is this nasty hack needed when in feisty the wallpaper worked right?
gsiliceo is offline   Reply With Quote
Old April 16th, 2008   #10
kirsis
Just Give Me the Beans!
 
kirsis's Avatar
 
Join Date: Dec 2006
Location: Riga, Latvia
Beans: 74
Ubuntu Karmic Koala (testing)
Send a message via MSN to kirsis Send a message via Skype™ to kirsis
Re: HOWTO: (GDM) Show the user wallpaper/background color, while logging in

Quote:
Originally Posted by gsiliceo View Post
Why is this nasty hack needed when in feisty the wallpaper worked right?
Well if the wallpaper works just right for you, then why are you in this thread in the first place? Obviously it doesn't work "just right" for everybody.

Quote:
Worked for me like a dream
Glad to hear that
kirsis is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:40 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry