diff options
author | fluxgen <fluxgen> | 2003-09-18 12:15:17 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-09-18 12:15:17 (GMT) |
commit | d539b5257e5ae36f8859e6ddd3b707c0aaef7991 (patch) | |
tree | 7aeefb796368b123f9d8139e0242a9d01a94d12b /util | |
parent | f99e1c6091591bc6ee46d14de25091bac55975c9 (diff) | |
download | fluxbox-d539b5257e5ae36f8859e6ddd3b707c0aaef7991.zip fluxbox-d539b5257e5ae36f8859e6ddd3b707c0aaef7991.tar.bz2 |
update from Han
Diffstat (limited to 'util')
-rw-r--r-- | util/fbsetbg | 168 |
1 files changed, 93 insertions, 75 deletions
diff --git a/util/fbsetbg b/util/fbsetbg index c3405bb..b406a63 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.17 2003/09/03 11:55:29 fluxgen Exp $ | 26 | # $Id: fbsetbg,v 1.18 2003/09/18 12:15:17 fluxgen 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 |
@@ -45,7 +45,7 @@ | |||
45 | 45 | ||
46 | 46 | ||
47 | # The wallpapersetter is selected in this order | 47 | # The wallpapersetter is selected in this order |
48 | wpsetters='chbg Esetroot wmsetbg display qiv xv xsri xli xsetbg' # broken icewmbg' | 48 | wpsetters='feh Esetroot wmsetbg chbg display qiv xv xsri xli xsetbg' # broken icewmbg' |
49 | lastwallpaper=${HOME}/.fluxbox/lastwallpaper | 49 | lastwallpaper=${HOME}/.fluxbox/lastwallpaper |
50 | 50 | ||
51 | 51 | ||
@@ -83,8 +83,9 @@ Options: | |||
83 | -p Tips | 83 | -p Tips |
84 | 84 | ||
85 | Files: | 85 | Files: |
86 | In this file the wallpaper you set will be stored, for the -l option: | 86 | |
87 | ~/.fluxbox/lastwallpaper | 87 | ~/.fluxbox/lastwallpaper In this file the wallpaper you set |
88 | will be stored, for the -l option: | ||
88 | 89 | ||
89 | EOF | 90 | EOF |
90 | } | 91 | } |
@@ -92,7 +93,8 @@ EOF | |||
92 | display_tips() { | 93 | display_tips() { |
93 | cat << EOF | 94 | cat << EOF |
94 | 95 | ||
95 | 1) To replace all occurrences of bsetbg in a file use this command: | 96 | 1) To replace all occurrences of bsetbg with fbsetbg in a file use this |
97 | command: | ||
96 | 98 | ||
97 | perl -pi -e 's,([^f]|^)bsetbg,fbsetbg,' filename | 99 | perl -pi -e 's,([^f]|^)bsetbg,fbsetbg,' filename |
98 | 100 | ||
@@ -130,7 +132,6 @@ case `uname` in | |||
130 | ;; | 132 | ;; |
131 | esac | 133 | esac |
132 | 134 | ||
133 | |||
134 | message() { | 135 | message() { |
135 | xmessage -center "$@" | 136 | xmessage -center "$@" |
136 | } | 137 | } |
@@ -169,13 +170,79 @@ or Esetroot (from Eterm)" | |||
169 | standardok=\ | 170 | standardok=\ |
170 | "$WPSETTER is a nice wallpapersetter. You won't have any problems." | 171 | "$WPSETTER is a nice wallpapersetter. You won't have any problems." |
171 | 172 | ||
173 | unset debug | ||
174 | #Get options. | ||
175 | getopts ":a:f:c:t:A:F:C:T:pdlh-" COMMAND_LINE_ARGUMENT | ||
176 | case "${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 | |||
208 | l) | ||
209 | if [ -r $lastwallpaper ]; then | ||
210 | option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1` | ||
211 | wallpaper=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f2` | ||
212 | else | ||
213 | message "No previous wallpaper recorded for display ${DISPLAY}" | ||
214 | exit 1 | ||
215 | fi | ||
216 | remember=false | ||
217 | ;; | ||
218 | h) display_help ; exit 0 ;; | ||
219 | p) display_tips ; exit 0 ;; | ||
220 | -) echo "fbsetbg doesn't recognize -- gnu-longopts." | ||
221 | echo 'Use fbsetbg -h for a help message.' | ||
222 | display_usage | ||
223 | exit 1 | ||
224 | ;; | ||
225 | *) if [ ! -r "$1" ]; then | ||
226 | echo "$1 isn't an existing wallpaper or a valid option." >&2 | ||
227 | display_usage | ||
228 | exit 1 | ||
229 | fi | ||
230 | if [ -z "$1" ]; then | ||
231 | message 'No wallpaper to set' >&2 | ||
232 | display_usage | ||
233 | exit 1 | ||
234 | fi | ||
235 | ;; | ||
236 | esac | ||
237 | |||
238 | |||
172 | case $WPSETTER in | 239 | case $WPSETTER in |
173 | chbg) | 240 | chbg) |
174 | full='-once -mode maximize' | 241 | full='-once -mode maximize' |
175 | tile='-once -mode tile' | 242 | tile='-once -mode tile' |
176 | center='-once -mode center' | 243 | center='-once -mode center' |
177 | aspect='-once -mode smart -max_grow 100 -max_size 100' | 244 | aspect='-once -mode smart -max_grow 100 -max_size 100' |
178 | debugstory=$standardok | 245 | debugstory="chbg supports all features but it doesn't report errors. I reported this bug to the chbg developers." |
179 | ;; | 246 | ;; |
180 | xsri) | 247 | xsri) |
181 | full='--center-x --center-y --scale-width=100 --scale-height=100' | 248 | full='--center-x --center-y --scale-width=100 --scale-height=100' |
@@ -217,7 +284,7 @@ case $WPSETTER in | |||
217 | center='-center -onroot -quiet -border black' | 284 | center='-center -onroot -quiet -border black' |
218 | aspect='-fullscreen -onroot -quiet -border black' | 285 | aspect='-fullscreen -onroot -quiet -border black' |
219 | full=$aspect #broken | 286 | full=$aspect #broken |
220 | debugstory='The fillscreen option (-f) is broken, defaults to (-a). $standardrant' | 287 | debugstory="The fillscreen option (-f) is broken, defaults to (-a). $standardrant" |
221 | ;; | 288 | ;; |
222 | qiv) | 289 | qiv) |
223 | full='--root_s' | 290 | full='--root_s' |
@@ -233,6 +300,13 @@ case $WPSETTER in | |||
233 | aspect='-maxpect -smooth -root -quit' | 300 | aspect='-maxpect -smooth -root -quit' |
234 | debugstory=$standardrant | 301 | debugstory=$standardrant |
235 | ;; | 302 | ;; |
303 | feh) | ||
304 | full='--bg-scale' | ||
305 | tile='--bg-tile' | ||
306 | center='--bg-center' | ||
307 | aspect=$full | ||
308 | debugstory=$standardok | ||
309 | ;; | ||
236 | icewmbg) | 310 | icewmbg) |
237 | tile='-s' | 311 | tile='-s' |
238 | full=$tile | 312 | full=$tile |
@@ -251,82 +325,26 @@ recommend you install the package provided by your distro." | |||
251 | ;; | 325 | ;; |
252 | esac | 326 | esac |
253 | 327 | ||
254 | #Get options. | 328 | if [ "$debug" = true ];then |
255 | getopts ":a:f:c:t:A:F:C:T:pdlh-" COMMAND_LINE_ARGUMENT | 329 | debugfbsetbg |
256 | case "${COMMAND_LINE_ARGUMENT}" in | 330 | exit 0 |
257 | d) debugfbsetbg | 331 | fi |
258 | exit 0 | ||
259 | ;; | ||
260 | a) option=$aspect | ||
261 | wallpaper=$OPTARG | ||
262 | ;; | ||
263 | f) option=$full | ||
264 | wallpaper=$OPTARG | ||
265 | ;; | ||
266 | c) option=$center | ||
267 | wallpaper=$OPTARG | ||
268 | ;; | ||
269 | t) option=$tile | ||
270 | wallpaper=$OPTARG | ||
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 | |||
289 | l) | ||
290 | if [ -r $lastwallpaper ]; then | ||
291 | option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1` | ||
292 | wallpaper=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f2` | ||
293 | else | ||
294 | message 'No previous wallpaper recorded. You have never used fbsetbg before.' | ||
295 | exit 1 | ||
296 | fi | ||
297 | remember=false | ||
298 | ;; | ||
299 | h) display_help ; exit 0 ;; | ||
300 | p) display_tips ; exit 0 ;; | ||
301 | -) echo "fbsetbg doesn't recognize -- gnu-longopts." | ||
302 | echo 'Use fbsetbg -h for a long help message.' | ||
303 | display_usage | ||
304 | exit 1 | ||
305 | ;; | ||
306 | *) if [ ! -r "$1" ]; then | ||
307 | echo "$1 isn't an existing wallpaper or a valid option." >&2 | ||
308 | display_usage | ||
309 | exit 1 | ||
310 | fi | ||
311 | if [ -z "$1" ]; then | ||
312 | message 'No wallpaper to set' >&2 | ||
313 | display_usage | ||
314 | exit 1 | ||
315 | fi | ||
316 | ;; | ||
317 | esac | ||
318 | 332 | ||
319 | option=${option:=$full} | 333 | option=${option:='$full'} |
320 | wallpaper=${wallpaper:=$1} | 334 | wallpaper=${wallpaper:=$1} |
321 | 335 | ||
322 | |||
323 | if [ ! -r "$wallpaper" ]; then | 336 | if [ ! -r "$wallpaper" ]; then |
324 | message "Can't find wallpaper $wallpaper" | 337 | message "Can't find wallpaper $wallpaper" |
325 | exit 1 | 338 | exit 1 |
326 | fi | 339 | fi |
327 | 340 | ||
328 | $WPSETTER $option "$wallpaper" || message "Something went wrong while setting the wallpaper | 341 | eval $WPSETTER $option "$wallpaper" |
342 | if [ $? -ne 0 ]; then | ||
343 | message "Something went wrong while setting the wallpaper. | ||
329 | Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what." | 344 | Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what." |
345 | exit 1 | ||
346 | fi | ||
347 | |||
330 | #remember previous wallpaper | 348 | #remember previous wallpaper |
331 | [ ! "$remember" = false ] && remembercommand | 349 | [ ! "$remember" = false ] && remembercommand |
332 | # Off course this returns 1 most of the time. | 350 | # Off course this returns 1 most of the time. |