audax321
July 21st, 2005, 06:39 AM
I hate Gnome's wallpaper changer only because you have to add images to it manually. I think it would be so much better if it functioned like a music player and just indexed all the images in a given directory instead. So, I thought to myself, why not put Nautilus's thumbnails to good use and just use it as a wallpaper changer. To do this I wrote a very simple script that sets an image as wallpaper and put it in the Scripts folder.
STEP 1: Open up terminal.
STEP 2: Go to the Nautilus Scripts folder:
cd ~/.gnome2/nautilus-scripts
STEP 3: Create a text document here and name it:
gedit "Set as Wallpaper"
STEP 4: Stick the following inside of the text document, depending on how you want to set up the wallpaper:
METHOD 1: Simple script with no user interaction...
#!/bin/sh
# Sets selected image as Gnome background:
image="$(pwd)/$1"
if [ -f "$image" -a -r "$image" ]; then
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$image"
gconftool-2 -t str --set /desktop/gnome/background/picture_options "stretched"
fi
The above code uses "stretched" to fill the screen with the image. Other options include "centered" to center the image, "tiled" to tile the image, and "scaled" to scale the image until either the vertical or horizontal edges reach the end of the screen.
METHOD 2: Simple script with user interaction...
#!/bin/sh
# Sets selected image as Gnome background:
image="$(pwd)/$1"
if [ -f "$image" -a -r "$image" ]; then
stretched_option="FALSE"
centered_option="FALSE"
scaled_option="FALSE"
wallpaper_option="FALSE"
case $(gconftool-2 --get /desktop/gnome/background/picture_options) in
"stretched" )
stretched_option="TRUE"
;;
"centered" )
centered_option="TRUE"
;;
"scaled" )
scaled_option="TRUE"
;;
"wallpaper" )
wallpaper_option="TRUE"
;;
esac
image_option=$(zenity --title="How would you like the image displayed?" --list --list-text="Please choose how to display '$1' or press CANCEL to exit." --radiolist --column "Item" --column "Types" --column "Description" "$stretched_option" "Fill Screen" "Stretch the image to fill the screen." "$centered_option" "Centered" "Center the image on the screen." "$scaled_option" "Scaled" "Scale the image without stretching." "$wallpaper_option" "Tiled" "Tile the image on the screen.")
if [ "$image_option" != "" ]; then
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$image"
case "$image_option" in
"Fill Screen" )
gconftool-2 -t str --set /desktop/gnome/background/picture_options "stretched"
;;
"Centered" )
gconftool-2 -t str --set /desktop/gnome/background/picture_options "centered"
;;
"Scaled" )
gconftool-2 -t str --set /desktop/gnome/background/picture_options "scaled"
;;
"Tiled" )
gconftool-2 -t str --set /desktop/gnome/background/picture_options "wallpaper"
;;
esac
fi
fi
Method 2 requires that you have zenity installed (which it should be since it is required by ubuntu-desktop) and will actually prompt you to determine how you would like the image displayed. In my opinion this way is much nicer since you have more options.
STEP 5: Save and exit gedit as well as terminal.
STEP 6: Open nautilus and navigate to: ~/.gnome2/nautilus-scripts
STEP 7: Right click on the script that you created and go to Properties. Next, go to the Permissions tab and do the following:
Check all the boxes for Read
Check the top checkbox (owner) for Write
Check all the boxes for Execute
That's it... now you can right-click on any image inside of Nautilus, go to the Scripts menu, and Set as Wallpaper! If you look at how the script sets the background image you'll notice you could also write other scripts that change settings in the Gnome Configuration Editor.
:)
STEP 1: Open up terminal.
STEP 2: Go to the Nautilus Scripts folder:
cd ~/.gnome2/nautilus-scripts
STEP 3: Create a text document here and name it:
gedit "Set as Wallpaper"
STEP 4: Stick the following inside of the text document, depending on how you want to set up the wallpaper:
METHOD 1: Simple script with no user interaction...
#!/bin/sh
# Sets selected image as Gnome background:
image="$(pwd)/$1"
if [ -f "$image" -a -r "$image" ]; then
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$image"
gconftool-2 -t str --set /desktop/gnome/background/picture_options "stretched"
fi
The above code uses "stretched" to fill the screen with the image. Other options include "centered" to center the image, "tiled" to tile the image, and "scaled" to scale the image until either the vertical or horizontal edges reach the end of the screen.
METHOD 2: Simple script with user interaction...
#!/bin/sh
# Sets selected image as Gnome background:
image="$(pwd)/$1"
if [ -f "$image" -a -r "$image" ]; then
stretched_option="FALSE"
centered_option="FALSE"
scaled_option="FALSE"
wallpaper_option="FALSE"
case $(gconftool-2 --get /desktop/gnome/background/picture_options) in
"stretched" )
stretched_option="TRUE"
;;
"centered" )
centered_option="TRUE"
;;
"scaled" )
scaled_option="TRUE"
;;
"wallpaper" )
wallpaper_option="TRUE"
;;
esac
image_option=$(zenity --title="How would you like the image displayed?" --list --list-text="Please choose how to display '$1' or press CANCEL to exit." --radiolist --column "Item" --column "Types" --column "Description" "$stretched_option" "Fill Screen" "Stretch the image to fill the screen." "$centered_option" "Centered" "Center the image on the screen." "$scaled_option" "Scaled" "Scale the image without stretching." "$wallpaper_option" "Tiled" "Tile the image on the screen.")
if [ "$image_option" != "" ]; then
gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$image"
case "$image_option" in
"Fill Screen" )
gconftool-2 -t str --set /desktop/gnome/background/picture_options "stretched"
;;
"Centered" )
gconftool-2 -t str --set /desktop/gnome/background/picture_options "centered"
;;
"Scaled" )
gconftool-2 -t str --set /desktop/gnome/background/picture_options "scaled"
;;
"Tiled" )
gconftool-2 -t str --set /desktop/gnome/background/picture_options "wallpaper"
;;
esac
fi
fi
Method 2 requires that you have zenity installed (which it should be since it is required by ubuntu-desktop) and will actually prompt you to determine how you would like the image displayed. In my opinion this way is much nicer since you have more options.
STEP 5: Save and exit gedit as well as terminal.
STEP 6: Open nautilus and navigate to: ~/.gnome2/nautilus-scripts
STEP 7: Right click on the script that you created and go to Properties. Next, go to the Permissions tab and do the following:
Check all the boxes for Read
Check the top checkbox (owner) for Write
Check all the boxes for Execute
That's it... now you can right-click on any image inside of Nautilus, go to the Scripts menu, and Set as Wallpaper! If you look at how the script sets the background image you'll notice you could also write other scripts that change settings in the Gnome Configuration Editor.
:)