Posted By

webonomic on 01/20/09


Tagged

linux Switch workspace wallpaper


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

figure8labs


Unique Background Wallpapers for Workspaces on Linux


 / Published in: Bash
 

URL: http://jaredprins.squarespace.com/ubducted/2009/1/19/unique-background-wallpapers-for-workspaces-on-ubuntu-linux.html

Bash shell scripts to control wallpaper backgrounds when switching between Ubuntu workspaces. (Other distributions can use it too).

Take the below 2 scripts to make 2 separate files. Use gconf-editor to attach keybindings to runcommand1 and runcommand2. Set command1 and command2 to point to the appropriate files.

See the URL for more details.

  1. -> Save this to left_workspace.sh
  2.  
  3. #!/bin/bash
  4. #left_workspace.sh
  5.  
  6. #get number of workspaces
  7. ws=$(wmctrl -d | wc -l)
  8.  
  9. #current workspace index
  10. cws=$(wmctrl -d | awk '/\*/ {print $1}')
  11.  
  12. #work space on left
  13. lws=$(($cws-1))
  14.  
  15. #wrap if required
  16. if [ $lws = -1 ]; then
  17. lws=$(($ws-1))
  18. fi
  19. echo $lws
  20.  
  21. #change to next workspace
  22. wmctrl -s $lws
  23.  
  24. #set wallpaper depending on workspace number
  25. case $lws in
  26. ("0") gconftool -t string -s /desktop/gnome/background/picture_filename /home/jp/Pictures/100.jpg;
  27. ;;
  28. ("1") gconftool -t string -s /desktop/gnome/background/picture_filename /home/jp/Pictures/200.jpg;
  29. ;;
  30. ("2") gconftool -t string -s /desktop/gnome/background/picture_filename /home/jp/Pictures/300.jpg;
  31. ;;
  32. ("3") gconftool -t string -s /desktop/gnome/background/picture_filename /home/jp/Pictures/400.jpg;
  33. ;;
  34. #follow the above format to set as many desktops as you have specified in the workspace applet
  35. esac
  36.  
  37.  
  38.  
  39. -> Save this next bit to right_workspace.sh
  40.  
  41. #!/bin/bash
  42.  
  43. #right_workspace.sh
  44.  
  45. #get number of workspaces
  46. ws=$(wmctrl -d | wc -l)
  47.  
  48. #current workspace index
  49. cws=$(wmctrl -d | awk '/\*/ {print $1}')
  50.  
  51. #work space on right
  52. rws=$(($cws+1))
  53.  
  54. #wrap if required
  55. if [ $rws = $ws ]; then
  56. rws=0
  57. fi
  58.  
  59. #change to next workspace
  60. wmctrl -s $rws
  61.  
  62. #set wallpaper depending on workspace number
  63. case $rws in
  64. ("0") gconftool -t string -s /desktop/gnome/background/picture_filename /home/jp/Pictures/100.jpg;
  65. ;;
  66. ("1") gconftool -t string -s /desktop/gnome/background/picture_filename /home/jp/Pictures/200.jpg;
  67. ;;
  68. ("2") gconftool -t string -s /desktop/gnome/background/picture_filename /home/jp/Pictures/300.jpg;
  69. ;;
  70. ("3") gconftool -t string -s /desktop/gnome/background/picture_filename /home/jp/Pictures/400.jpg;
  71. ;;
  72. #follow the above format to set as many desktops as you have specified in the workspace applet
  73. esac

Report this snippet  

You need to login to post a comment.