xfce "set as desktop" and random desktop background wallpaper option

[EDIT (19/04/11)] You may use my modified script: http://gist.github.com/921514
This changes wallpaper on gnome/xfce (ubuntu/xubuntu) without any hassles. Can be easily used with the cron as well. Uses nautilus or feh depending on your choice of managing desktop with nautilus (Mine is not to do so).
In xubuntu, it does much more: It actually makes your splash same as your wallpaper, giving an effect of a wallpaper just as you login, while your session boots up. Random splash every time. Cool, huh? What you have to do is use the Balou login screen and change the configuration to use the $HOME/.tmp/splash.img as the splash image. It uses imagemagick to alter your wallpapers size to accommodate the texts (Starting session). It is optimized for my desktop (single bottom xfce4-panel – 24px). You can modify the corresponding line (search for ‘convert’).
Another advantage it has is the option of deleting a wallpaper if you don’t like it. Use ‘ranbg –rm’ and it will prompt you for the deletion. If you press y, it will delete and use another random wallpaper.
Enjoy!
[/EDIT]
now these two options were what i missed much in my xfce desktop. so i tried to google and came up with a trick solution.

as u can easily google out “killall -USR1 xfdesktop” works as charm for changing the desktop bg from the list of images (set in the desktop settings wizard. so here’s what i did-

1. set as desktop context menu – put this in a new custom action of thunar

====================================
Name: Set as Desktop
Command: echo ‘# xfce backdrop list\n%f’>$HOME/.config/xfce4/desktop/backdrops.list;killall -USR1 xfdesktop
File pattern: *
Appears if selection contains: Image Files

====================================

Note: u can also put it into mirage custom actions – if u use mirage as ur image viewer. btw, mirage is a very light weight decent image viewer much better than eog etc…

2. script for choosing random wallpaper in xfce: this script was actually written for gnome by someone else (David Loschavio, Steven Ingelgem). I modified it for xfce.

====================================
#!/bin/bash
# script: change_backgrounds.sh – bash version
# version 2007.3.7
# description: randomly replace gnome background with one from a directory
# credits: David Loschiavo [http://www.djlosch.com], Steven Van Ingelgem, Sudhanshu [http://home.iitk.ac.in/~sudhansh]
# license: GPL
# change bg_path to ur wallpapers folder. the subfolders are automatically added.

bg_path=”/media/D/XTRA/wallpapers”
extensions=”jpg png gif jpeg JPG GIF PNG”
temp_bg_list=/tmp/bg_change_list

rm -f $temp_bg_list

for extension in $extensions
do
find $bg_path -iregex “.*.$extension” “$temp_bg_list”
done

cnt=`wc -l “$temp_bg_list” | cut -f1 -d” “`
all_bgs=`echo \`expr $RANDOM % $cnt\“

selected_bg=`head -n$all_bgs “$temp_bg_list” | tail -n1`
echo “Changed desktop to: $selected_bg”

# use the follwing command if u want the script for gnome.
#gconftool-2 -t string -s /desktop/gnome/background/picture_filename “$selected_bg”

echo -e “# xfce backdrop list\n$selected_bg”>$HOME/.config/xfce4/desktop/backdrops.list
killall -USR1 xfdesktop

exit 0
=====================================

so just copy this into a bash executable file (say .ranbg.sh). make the file executable (chmod a+x .ranbg.sh) and run it whenever u need to get a new wallpaper. u can put it in ur sttartup applications to get a new wallpaper on every logon.

howzzat!!
njoi!

Advertisements

2 thoughts on “xfce "set as desktop" and random desktop background wallpaper option

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s