aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-04-27 15:33:26 (GMT)
committerfluxgen <fluxgen>2003-04-27 15:33:26 (GMT)
commitf28ac3b625558cffd63dbf7221967f9fc21627d0 (patch)
treeb3e4c3a374319bb9a6de84e879d4af3b5f0c47de /util
parent63ac5deee691f7b528399c0f03e100e983a8cb55 (diff)
downloadfluxbox-f28ac3b625558cffd63dbf7221967f9fc21627d0.zip
fluxbox-f28ac3b625558cffd63dbf7221967f9fc21627d0.tar.bz2
replacing bsetbg
Diffstat (limited to 'util')
-rw-r--r--util/fbsetbg282
1 files changed, 282 insertions, 0 deletions
diff --git a/util/fbsetbg b/util/fbsetbg
new file mode 100644
index 0000000..3080846
--- /dev/null
+++ b/util/fbsetbg
@@ -0,0 +1,282 @@
1#!/bin/sh
2#
3# Set wallpaper for fluxbox.
4#
5# Copyright (c) 2003 Han Boetes <han@mijncomputer.nl>
6#
7# Permission is hereby granted, free of charge, to any person obtaining
8# a copy of this software and associated documentation files (the
9# "Software"), to deal in the Software without restriction, including
10# without limitation the rights to use, copy, modify, merge, publish,
11# distribute, sublicense, and/or sell copies of the Software, and to
12# permit persons to whom the Software is furnished to do so, subject to
13# the following conditions:
14#
15# The above copyright notice and this permission notice shall be
16# included in all copies or substantial portions of the Software.
17#
18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25#
26# $Id: fbsetbg,v 1.1 2003/04/27 15:33:26 fluxgen Exp $
27
28#
29# Portability notes:
30# To guarantee this script works on all platforms that support fluxbox
31# please keep the following restrictions in mind:
32#
33# don't use [ -e file ] use [ -r file ]
34# don't use $(), use ``
35# don't use ~, use ${HOME}
36# don't use id -u, use whoami
37# getopts won't work on all platforms, but the config-file can
38# compensate for that.
39#
40
41wpsetters='wmsetbg Esetroot xli xsetbg display qiv xv xsri'
42lastwallpaper=${HOME}/.fluxbox/lastwallpaper
43
44WHOAMI=`whoami`
45[ "$WHOAMI" = "root" ] && PATH=/bin:/usr/bin/:/usr/local/bin:/usr/X11R6/bin
46
47
48# Functions
49display_usage() {
50 cat <<EOF
51Usage: fbsetbg [-fct /path/to/wallpaper ] [ -l ] [ -h ]
52EOF
53}
54
55display_help() {
56 display_usage
57 cat <<EOF
58
59Options:
60
61 -f Set fullscreen wallpaper
62 -c Set centered wallpaper
63 -t Set tiled wallpaper
64
65 -h Display this help
66
67 -l Set previous wallpaper
68
69 -d Debug fbsetbg
70 -T Tips
71
72Files:
73
74 ~/.fluxbox/lastwallpaper
75
76EOF
77}
78
79display_tips(){
80cat<<EOF
81
82To replace all occurances of bsetbg in a file use this command:
83
84 perl -pi -e 's, bsetbg, fbsetbg,'
85
86If you want to choose your own wallpapers and you want fbsetbg to
87remember the previous wallpaper put this in your ~/.fluxbox/init
88
89 session.screen0.rootCommand: fbsetbg -l
90
91
92EOF
93}
94
95# ugly code for solaris compat.
96find_it() {
97 file=`which $1 2> /dev/null`
98 if [ -x "$file" ]; then
99 if [ $# -gt 1 ]; then
100 shift
101 $*
102 fi
103 return 0
104 else
105 return 1
106 fi
107}
108
109message() {
110 xmessage -center "$@"
111}
112
113debugfbsetbg (){
114
115 standardrant (){
116 cat <<EOF
117
118$WPSETTER sets the 'wrong' wallpaper. transparant apps like aterm and
119xchat wont work right with it. Consider using wmsetbg (from windowmaker)
120or Esetroot (from Eterm)
121
122EOF
123 }
124
125 for wpsetter in $wpsetters; do
126 if find_it $wpsetter; then
127 WPSETTER=$wpsetter
128 break
129 fi
130 done
131
132 case $WPSETTER in
133 xsri)
134 echo 'Actually I never heard of this app.'
135 ;;
136 display)
137 standardrant
138 ;;
139 Esetroot)
140 echo 'Esetroot is a nice app :)'
141 echo "You won't have any problems"
142 ;;
143 wmsetbg)
144 echo 'wmsetbg is my favourite :)'
145 echo "You won't have any problems"
146 ;;
147 xsetbg)
148 standardrant
149 ;;
150 xli)
151 standardrant
152 ;;
153 qiv)
154 standardrant
155 ;;
156 xv)
157 standardrant
158 ;;
159 '')
160 cat <<EOF
161
162I Can't find and app to set the wallpaper with. You can install one in
163many many ways but I will give you some simple advice: install Eterm and
164your set. Eterm provides Esetroot and thats a great wallpapersetter. I
165recommend you install the package provided by your distro.
166
167EOF
168 esac
169 exit 0
170}
171
172if [ $1 = -d ];then
173 debugfbsetbg
174fi
175
176# Find the default wallpapersetter
177# The precise order is up for debate.
178for wpsetter in $wpsetters; do
179 if find_it $wpsetter; then
180 WPSETTER=$wpsetter
181 break
182 fi
183done
184
185case $WPSETTER in
186 xsri)
187 full='--center-x --center-y --scale-width=100 --scale-width=100'
188 tile='--tile'
189 center='--center-x --center-y'
190 ;;
191 display)
192 full='-geometry 800x600 -window root'
193 tile='-window root'
194 center='-backdrop -window root'
195 ;;
196 Esetroot)
197 full='-scale'
198 tile=''
199 center='-c'
200 ;;
201 wmsetbg)
202 full='-s -S'
203 tile='-t'
204 center='-b black -e'
205 ;;
206 xsetbg)
207 full='-fillscreen'
208 tile=''
209 center='-center'
210 ;;
211 xli)
212 full='-fillscreen -onroot -quiet'
213 tile='-onroot -quiet'
214 center='-center -onroot quiet'
215 ;;
216 qiv)
217 full='--root_s'
218 tile='--root_t'
219 center='--root'
220 ;;
221 xv)
222 full='-max -smooth -root -quit'
223 tile='-root -quit'
224 center='-rmode 5 -root -quit'
225 ;;
226 '')
227 message "Can't find and app to set the wallpaper with.
228Use fbsetbg -d to find out what to do next"
229 exit 1
230esac
231
232#Get options.
233getopts ":f:c:t:Tlh-" COMMAND_LINE_ARGUMENT
234case "${COMMAND_LINE_ARGUMENT}" in
235 f) option=$full
236 wallpaper=$OPTARG
237 echo $option > $lastwallpaper
238 echo $wallpaper >> $lastwallpaper
239 ;;
240 c) option=$center
241 wallpaper=$OPTARG
242 echo $option > $lastwallpaper
243 echo $wallpaper >> $lastwallpaper
244 ;;
245 t) option=$tile
246 wallpaper=$OPTARG
247 echo $option > $lastwallpaper
248 echo $wallpaper >> $lastwallpaper
249 ;;
250 l)
251 if [ -r $lastwallpaper ];then
252 option=$(head -n1 $lastwallpaper)
253 wallpaper=$(tail -n1 $lastwallpaper)
254 else
255 message 'No previous wallpaper recorded.'
256 fi
257 ;;
258 h) display_help ; exit 0 ;;
259 T) display_tips ; exit 0 ;;
260 -) echo "fbsetbg doesn't recognize -- gnu-longopts."
261 echo "Use fbsetbg -h for a long help message."
262 display_usage
263 exit 1
264 ;;
265esac
266
267option=${option:=$full}
268wallpaper=${wallpaper:=$1}
269
270if [ -z "$wallpaper" ];then
271 message 'No wallpaper to set'
272 exit 1
273fi
274
275if [ ! -r "$wallpaper" ];then
276 message "Can't find wallpaper $wallpaper"
277 exit 1
278fi
279
280$WPSETTER $option "$wallpaper" || message "Something went wrong while setting the wallpaper
281Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what."
282#remember previous wallpaper