aboutsummaryrefslogtreecommitdiff
path: root/util/fbsetbg
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-17 13:30:35 (GMT)
committerfluxgen <fluxgen>2003-08-17 13:30:35 (GMT)
commit5baf2304dfbe4b2f463b440568436c4178afd0da (patch)
tree67eb469bd9411e341984cc37dbc98bde53b4e2da /util/fbsetbg
parentd101fdb7704d1dd3d7ddefd6a02bbbc7325e83dc (diff)
downloadfluxbox-5baf2304dfbe4b2f463b440568436c4178afd0da.zip
fluxbox-5baf2304dfbe4b2f463b440568436c4178afd0da.tar.bz2
update from Han
Diffstat (limited to 'util/fbsetbg')
-rw-r--r--util/fbsetbg107
1 files changed, 73 insertions, 34 deletions
diff --git a/util/fbsetbg b/util/fbsetbg
index 592f513..45151bc 100644
--- a/util/fbsetbg
+++ b/util/fbsetbg
@@ -23,20 +23,26 @@
23# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25# 25#
26# $Id: fbsetbg,v 1.14 2003/08/04 16:49:25 fluxgen Exp $ 26# $Id: fbsetbg,v 1.15 2003/08/17 13:27:44 fluxgen Exp $
27 27
28#
29# Portability notes: 28# Portability notes:
30# To guarantee this script works on all platforms that support fluxbox 29# To guarantee this script works on all platforms that support fluxbox
31# please keep the following restrictions in mind: 30# please keep the following restrictions in mind:
32# 31#
33# don't use [ -e file ], use [ -r file ] 32# - don't use if ! command;, use command; if [ $? -ne 0 ];
34# don't use $(), use `` 33# - don't use [ -e file ] use [ -r file ]
35# don't use ~, use ${HOME} 34# - don't use $(), use ``
36# don't use id -u, use whoami 35# - don't use ~, use ${HOME}
37# getopts won't work on all platforms, but the config-file can 36# - don't use id -u, use whoami
38# compensate for that. 37# - getopts won't work on all platforms, but the config-file can
39# 38# compensate for that.
39# - various software like grep/sed/perl may be not present or not
40# the version you have. for example grep '\W' only works on gnu-grep.
41# Keep this in mind, use bare basic defaults.
42# - Do _NOT_ suggest to use #!/bin/bash. Not everybody uses bash.
43# Non portable features like getopts in this script can be achieved in
44# other ways.
45
40 46
41# The wallpapersetter is selected in this order 47# The wallpapersetter is selected in this order
42wpsetters='chbg Esetroot wmsetbg display qiv xv xsri xli xsetbg' # broken icewmbg' 48wpsetters='chbg Esetroot wmsetbg display qiv xv xsri xli xsetbg' # broken icewmbg'
@@ -50,7 +56,7 @@ WHOAMI=`whoami`
50# Functions 56# Functions
51display_usage() { 57display_usage() {
52 cat << EOF 58 cat << EOF
53Usage: fbsetbg [ -fcta /path/to/wallpaper ] [ -l ] [ -h ] [ -d ] 59Usage: fbsetbg [ -fFcCtTaA /path/to/wallpaper ] [ -l ] [ -h ] [ -d ] [ -p ]
54EOF 60EOF
55} 61}
56 62
@@ -67,49 +73,63 @@ Options:
67 ( if your bgsetter doesn't support this 73 ( if your bgsetter doesn't support this
68 fbsetbg falls back to -f ) 74 fbsetbg falls back to -f )
69 75
76 -F,-C,-T,-A same as uncapsed but without remembering.
77
70 -h Display this help 78 -h Display this help
71 79
72 -l Set previous wallpaper 80 -l Set previous wallpaper
73 81
74 -d Debug fbsetbg 82 -d Debug fbsetbg
75 -T Tips 83 -p Tips
76 84
77Files: 85Files:
78 86 In this file the wallpaper you set will be stored, for the -l option:
79 ~/.fluxbox/lastwallpaper 87 ~/.fluxbox/lastwallpaper
80 88
81EOF 89EOF
82} 90}
83 91
84display_tips(){ 92display_tips() {
85cat<< EOF 93 cat << EOF
86 94
87To replace all occurrences of bsetbg in a file use this command: 951) To replace all occurrences of bsetbg in a file use this command:
88 96
89 perl -pi -e 's,([^f]|^)bsetbg,fbsetbg,' filename 97 perl -pi -e 's,([^f]|^)bsetbg,fbsetbg,' filename
90 98
91If you want the style to set the wallpaper and you want fbsetbg to 992) If you want the style to set the wallpaper and you want fbsetbg to
92remember the previous wallpaper put this in your ~/.fluxbox/init 100 remember the previous wallpaper put this in your ~/.fluxbox/init
93 101
94 session.screen0.rootCommand: fbsetbg -l 102 session.screen0.rootCommand: fbsetbg -l
95 103
1043) Use fbsetbg -d to find out what wallpapersetter fbsetbg will use and
105 what he thinks about it.
96 106
97EOF 107EOF
98} 108}
99 109
100# ugly code for solaris compat. 110# ugly code for solaris compat.
101find_it() { 111case `uname` in
102 file=`which $1 2> /dev/null` 112 Linux|*BSD)
103 if [ -x "$file" ]; then 113 find_it() {
104 if [ $# -gt 1 ]; then 114 which $1 > /dev/null 2>&1 && shift && $*
105 shift 115 }
106 $* 116 ;;
107 fi 117 *)
108 return 0 118 find_it() {
109 else 119 file=`which $1 2> /dev/null`
110 return 1 120 if [ -x "$file" ]; then
111 fi 121 if [ $# -gt 1 ]; then
112} 122 shift
123 $*
124 fi
125 return 0
126 else
127 return 1
128 fi
129 }
130 ;;
131esac
132
113 133
114message() { 134message() {
115 xmessage -center "$@" 135 xmessage -center "$@"
@@ -126,7 +146,7 @@ remembercommand() {
126 esac 146 esac
127} 147}
128 148
129debugfbsetbg (){ 149debugfbsetbg() {
130 echo 150 echo
131 echo $debugstory 151 echo $debugstory
132 echo 152 echo
@@ -232,7 +252,7 @@ recommend you install the package provided by your distro."
232esac 252esac
233 253
234#Get options. 254#Get options.
235getopts ":a:f:c:t:Tdlh-" COMMAND_LINE_ARGUMENT 255getopts ":a:f:c:t:A:F:C:T:pdlh-" COMMAND_LINE_ARGUMENT
236case "${COMMAND_LINE_ARGUMENT}" in 256case "${COMMAND_LINE_ARGUMENT}" in
237 d) debugfbsetbg 257 d) debugfbsetbg
238 exit 0 258 exit 0
@@ -249,6 +269,23 @@ case "${COMMAND_LINE_ARGUMENT}" in
249 t) option=$tile 269 t) option=$tile
250 wallpaper=$OPTARG 270 wallpaper=$OPTARG
251 ;; 271 ;;
272 A) option=$aspect
273 wallpaper=$OPTARG
274 remember=false
275 ;;
276 F) option=$full
277 wallpaper=$OPTARG
278 remember=false
279 ;;
280 C) option=$center
281 wallpaper=$OPTARG
282 remember=false
283 ;;
284 T) option=$tile
285 wallpaper=$OPTARG
286 remember=false
287 ;;
288
252 l) 289 l)
253 if [ -r $lastwallpaper ]; then 290 if [ -r $lastwallpaper ]; then
254 option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1` 291 option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1`
@@ -260,7 +297,7 @@ case "${COMMAND_LINE_ARGUMENT}" in
260 remember=false 297 remember=false
261 ;; 298 ;;
262 h) display_help ; exit 0 ;; 299 h) display_help ; exit 0 ;;
263 T) display_tips ; exit 0 ;; 300 p) display_tips ; exit 0 ;;
264 -) echo "fbsetbg doesn't recognize -- gnu-longopts." 301 -) echo "fbsetbg doesn't recognize -- gnu-longopts."
265 echo 'Use fbsetbg -h for a long help message.' 302 echo 'Use fbsetbg -h for a long help message.'
266 display_usage 303 display_usage
@@ -292,3 +329,5 @@ $WPSETTER $option "$wallpaper" || message "Something went wrong while setting th
292Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what." 329Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what."
293#remember previous wallpaper 330#remember previous wallpaper
294[ ! "$remember" = false ] && remembercommand 331[ ! "$remember" = false ] && remembercommand
332# Off course this returns 1 most of the time.
333exit 0