Wednesday, April 18, 2007

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

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!



1 comment:

Unknown said...

Hi

You can use xfdestop --reload instead of killall -USR1 xfdesktop