Posted by oblek - xfce desktop on Sat 1 Dec 05:52 (modification of post by view diff)
report abuse | download | new post
- #!/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.
- # where the wallpaper reside, see more at http://vladstudio.com
- bg_path="/usr/share/xfce4/backdrops/vladstudio"
- extensions="jpg png gif jpeg JPG GIF PNG"
- temp_bg_list=/tmp/backdrop.list.$$
- # try to remove the old list, bail out if failed
- rm -f $temp_bg_list.$$ || exit 1
- 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 -e "# xfce backdrop list\n$selected_bg">/etc/backdrops.list
- #get the pid for xfdesktop
- pid=`ps -e | grep xfdesktop | awk '{print $1}'`
- #a regular expression containing the names of the processes
- #that will defer the switching, since killing with USR1 will lockup the program
- deferred='(mplayer|vlc)'
- if [[ -z $pid ]] && [[ -n `ps -e | egrep $deferred` ]]; then
- echo "" &> /dev/null
- else
- renice 19 -p $pid &> /dev/null
- kill -USR1 $pid
- renice 0 -p $pid &> /dev/null
- fi
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.