aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-10-08 14:00:47 (GMT)
committerrathnor <rathnor>2003-10-08 14:00:47 (GMT)
commitae729342e964c7b6d3571884b55ce14ff27fa553 (patch)
tree2f3ad9e2441e936095821a917c0bd4b9dfdd699f
parent29a69a69c1a2f51d6fb790534a0da8683ee24eb9 (diff)
downloadfluxbox-ae729342e964c7b6d3571884b55ce14ff27fa553.zip
fluxbox-ae729342e964c7b6d3571884b55ce14ff27fa553.tar.bz2
avoid using getopts in fbsetbg, plus other tweaks
-rw-r--r--ChangeLog3
-rw-r--r--util/fbsetbg182
2 files changed, 108 insertions, 77 deletions
diff --git a/ChangeLog b/ChangeLog
index eaa24fd..0556dbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.6: 2Changes for 0.9.6:
3*03/10/08:
4 * fbsetbg updates from Han, and some tweaking (Simon)
5 fbsetbg
3*03/10/06: 6*03/10/06:
4 * Fix rendering of offscreen windows (remove if !visible tests) (Simon) 7 * Fix rendering of offscreen windows (remove if !visible tests) (Simon)
5 FbWinFrame.cc 8 FbWinFrame.cc
diff --git a/util/fbsetbg b/util/fbsetbg
index 4cd0ab3..fccf90b 100644
--- a/util/fbsetbg
+++ b/util/fbsetbg
@@ -23,7 +23,7 @@
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.20 2003/09/29 11:59:35 fluxgen Exp $ 26# $Id: fbsetbg,v 1.21 2003/10/08 14:00:47 rathnor Exp $
27 27
28# Portability notes: 28# Portability notes:
29# To guarantee this script works on all platforms that support fluxbox 29# To guarantee this script works on all platforms that support fluxbox
@@ -40,9 +40,9 @@
40# the version you have. for example grep '\W' only works on gnu-grep. 40# the version you have. for example grep '\W' only works on gnu-grep.
41# Keep this in mind, use bare basic defaults. 41# Keep this in mind, use bare basic defaults.
42# - Do _NOT_ suggest to use #!/bin/bash. Not everybody uses bash. 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 43
44# TODO purheps: xprop -root _WIN_WORKSPACE
45# _NET_CURRENT_DESKTOP
46 46
47# The wallpapersetter is selected in this order 47# The wallpapersetter is selected in this order
48wpsetters='Esetroot wmsetbg feh chbg display qiv xv xsri xli xsetbg' # broken icewmbg' 48wpsetters='Esetroot wmsetbg feh chbg display qiv xv xsri xli xsetbg' # broken icewmbg'
@@ -52,11 +52,14 @@ lastwallpaper=${HOME}/.fluxbox/lastwallpaper
52WHOAMI=`whoami` 52WHOAMI=`whoami`
53[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin/:/usr/local/bin:/usr/X11R6/bin 53[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin/:/usr/local/bin:/usr/X11R6/bin
54 54
55command="`basename \"$0\"`"
56
55 57
56# Functions 58# Functions
57display_usage() { 59display_usage() {
58 cat << EOF 60 cat << EOF
59Usage: fbsetbg [ -fFcCtTaA /path/to/wallpaper ] [ -l ] [ -h ] [ -d ] [ -p ] 61Usage: $command [ -fFcCtTaA /path/to/wallpaper ] [ -l ] [ -h ] [ -i ] [ -p ]
62Use $command -h for a complete help message.
60EOF 63EOF
61} 64}
62 65
@@ -71,7 +74,7 @@ Options:
71 -t Set tiled wallpaper 74 -t Set tiled wallpaper
72 -a Set maximized wallpaper, preserving aspect. 75 -a Set maximized wallpaper, preserving aspect.
73 ( if your bgsetter doesn't support this 76 ( if your bgsetter doesn't support this
74 fbsetbg falls back to -f ) 77 we fall back to -f )
75 78
76 -F,-C,-T,-A same as uncapsed but without remembering. 79 -F,-C,-T,-A same as uncapsed but without remembering.
77 80
@@ -79,7 +82,8 @@ Options:
79 82
80 -l Set previous wallpaper 83 -l Set previous wallpaper
81 84
82 -d Debug fbsetbg 85 -i Information about selected wallpaper command
86 -d (deprecated, use -i) Debug info
83 -p Tips 87 -p Tips
84 88
85Files: 89Files:
@@ -92,19 +96,20 @@ EOF
92 96
93display_tips() { 97display_tips() {
94 cat << EOF 98 cat << EOF
99Common tips to use with $command:
95 100
961) To replace all occurrences of bsetbg with fbsetbg in a file use this 1011) To replace all occurrences of bsetbg with $command in a file use this
97 command: 102 command:
98 103
99 perl -pi -e 's,([^f]|^)bsetbg,fbsetbg,' filename 104 perl -pi -e 's,([^f]|^)bsetbg,$command,' filename
100 105
1012) If you want the style to set the wallpaper and you want fbsetbg to 1062) If you want the style to set the wallpaper and you want $command to
102 remember the previous wallpaper put this in your ~/.fluxbox/init 107 remember the previous wallpaper put this in your ~/.fluxbox/init
103 108
104 session.screen0.rootCommand: fbsetbg -l 109 session.screen0.rootCommand: $command -l
105 110
1063) Use fbsetbg -d to find out what wallpapersetter fbsetbg will use and 1113) Use $command -i to find out what wallpapersetter $command will be
107 what he thinks about it. 112 used and what I think about it.
108 113
109EOF 114EOF
110} 115}
@@ -133,7 +138,13 @@ case `uname` in
133esac 138esac
134 139
135message() { 140message() {
136 xmessage -center "$@" 141 # echo if we have terminal output, otherwise
142 # pop up a window
143 if [ -t 1 ]; then
144 echo "$command: $@"
145 else
146 xmessage -center "$command: $@"
147 fi
137} 148}
138 149
139remembercommand() { 150remembercommand() {
@@ -163,77 +174,94 @@ for wpsetter in $wpsetters; do
163done 174done
164 175
165standardrant=\ 176standardrant=\
166"$WPSETTER sets the 'wrong' wallpaper. Transparency for fluxbox and apps like aterm 177"$WPSETTER sets the 'wrong' wallpaper. Transparency for fluxbox and
167and xchat won't work right with it. Consider using chbg, wmsetbg (from windowmaker) 178apps like aterm and xchat won't work right with it. Consider installing
168or Esetroot (from Eterm)" 179chbg, wmsetbg (from windowmaker) or Esetroot (from Eterm) and I'll use
180them instead."
169 181
170standardok=\ 182standardok=\
171"$WPSETTER is a nice wallpapersetter. You won't have any problems." 183"$WPSETTER is a nice wallpapersetter. You won't have any problems."
172 184
173unset debug 185unset debug
174#Get options.
175getopts ":a:f:c:t:A:F:C:T:pdlh-" COMMAND_LINE_ARGUMENT
176case "${COMMAND_LINE_ARGUMENT}" in
177 d) debug=true
178 ;;
179 a) option='$aspect'
180 wallpaper=$OPTARG
181 ;;
182 f) option='$full'
183 wallpaper=$OPTARG
184 ;;
185 c) option='$center'
186 wallpaper=$OPTARG
187 ;;
188 t) option='$tile'
189 wallpaper=$OPTARG
190 ;;
191 A) option='$aspect'
192 wallpaper=$OPTARG
193 remember=false
194 ;;
195 F) option='$full'
196 wallpaper=$OPTARG
197 remember=false
198 ;;
199 C) option='$center'
200 wallpaper=$OPTARG
201 remember=false
202 ;;
203 T) option='$tile'
204 wallpaper=$OPTARG
205 remember=false
206 ;;
207 186
208 l) 187if [ $# -eq 0 ]; then
209 if [ -r $lastwallpaper ]; then 188 message "no options given"
210 option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1` 189 display_help
211 wallpaper=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f2` 190 exit 1
212 else 191fi
213 message "No previous wallpaper recorded for display ${DISPLAY}" 192
193# Parse command-line options
194while :; do
195 case "$1" in
196 -d|-i) debug=true
197 break ;;
198 -a) option='$aspect'
199 wallpaper=$2
200 break ;;
201 -f) option='$full'
202 wallpaper=$2
203 break ;;
204 -c) option='$center'
205 wallpaper=$2
206 break ;;
207 -t) option='$tile'
208 wallpaper=$2
209 break ;;
210 -A) option='$aspect'
211 wallpaper=$2
212 remember=false
213 break ;;
214 -F) option='$full'
215 wallpaper=$2
216 remember=false
217 break ;;
218 -C) option='$center'
219 wallpaper=$2
220 remember=false
221 break ;;
222 -T) option='$tile'
223 wallpaper=$2
224 remember=false
225 break ;;
226 -l)
227 if [ -r "$lastwallpaper" ]; then
228 option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1`
229 wallpaper=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f2`
230 if [ -z "$wallpaper" ]; then
231 message "No previous wallpaper recorded for display ${DISPLAY}"
232 exit 1
233 fi
234 fi
235 remember=false
236 break
237 ;;
238 -p) display_tips ; exit 0 ;;
239 -h) display_help ; exit 0 ;;
240 --)
241 echo "$command doesn't recognize -- gnu-longopts."
242 echo 'Use $command -h for a help message.'
243 display_usage
244 exit 1 ;;
245 -*)
246 echo 1>&2 "$command: unrecognized option "\`"$1'"
247 display_usage
214 exit 1 248 exit 1
215 fi 249 ;;
216 remember=false 250 *)
217 ;; 251 if [ ! -r "$1" ]; then
218 h) display_help ; exit 0 ;; 252 echo "$1 isn't an existing wallpaper or a valid option." >&2
219 p) display_tips ; exit 0 ;; 253 display_usage
220 -) echo "fbsetbg doesn't recognize -- gnu-longopts." 254 exit 1
221 echo 'Use fbsetbg -h for a help message.' 255 elif [ -z "$1" ]; then
222 display_usage 256 message 'No wallpaper to set' >&2
223 exit 1 257 display_usage
224 ;; 258 exit 1
225 *) if [ ! -r "$1" ]; then 259 else
226 echo "$1 isn't an existing wallpaper or a valid option." >&2 260 break
227 display_usage 261 fi
228 exit 1 262 ;;
229 fi 263 esac
230 if [ -z "$1" ]; then 264done
231 message 'No wallpaper to set' >&2
232 display_usage
233 exit 1
234 fi
235 ;;
236esac
237 265
238 266
239case $WPSETTER in 267case $WPSETTER in