snippets / change aléatoirement le fond d'écran de gnome

Language: Shell - First posted by mobidyc on 2007-10-3 22:46 (1 year, 1 month)
Link to the snippet: http://www.friendsnippets.org/snippet/45/

le fichier /tmp/picture_bg contient l'historique des fonds d'écrans utilisés.

 1 #! /bin/bash
2
3 # can be : none wallpaper stretched scaled centered
4 picture_options="scaled"
5
6 bgpath="${1:-/home/mobidyc/perso/artgallery/desktop/}"
7 num="0"
8 total_pix="0"
9 pix_tmp="${2:-/tmp/rotate_background_gnome.tmp}"
10
11 find $bgpath ! -type d > ${pix_tmp}
12 if [[ "$?" != "0" ]]
13 then
14 echo "$(basename) - find est tombe en erreur"
15 exit 1
16 fi
17
18 total_pix="$(wc -l ${pix_tmp} | awk '{print $1}')"
19 if [[ "$?" != "0" ]]
20 then
21 echo "$(basename) - wc est tombe en erreur"
22 exit 1
23 fi
24
25 let rand_pic="${RANDOM}%${total_pix}"
26
27 while read picture_bg
28 do
29 num="$((${num}+1))"
30 if [[ "${num}" = "${rand_pic}" ]]
31 then
32 /usr/X11R6/bin/gconftool-2 --type string --set /desktop/gnome/background/picture_filename "${picture_bg}"
33 test "$?" = "0" && {
34 echo "$(date): ${picture_bg}" >> /tmp/picture_bg
35 }
36 /usr/X11R6/bin/gconftool-2 --type string --set /desktop/gnome/background/picture_options "${picture_options}"
37 fi
38 done <${pix_tmp}
39
40 rm $pix_tmp
41
42 exit 0
In order to post a comment, you should have a friendsnippet account. Please sign-in.

1 comments

  • October 3rd 2007 at 22:50

    la selection des backgrounds est récursive.

    usage: rotate_background [chemin_des_images]

Oct '07
  • le fichier /tmp/picture_bg contient l'historique des fonds d'écrans utilisés.

Common Tags



snippet History

Oct '07