summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/fbsetbg168
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
48wpsetters='chbg Esetroot wmsetbg display qiv xv xsri xli xsetbg' # broken icewmbg' 48wpsetters='feh Esetroot wmsetbg chbg display qiv xv xsri xli xsetbg' # broken icewmbg'
49lastwallpaper=${HOME}/.fluxbox/lastwallpaper 49lastwallpaper=${HOME}/.fluxbox/lastwallpaper
50 50
51 51
@@ -83,8 +83,9 @@ Options:
83 -p Tips 83 -p Tips
84 84
85Files: 85Files:
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
89EOF 90EOF
90} 91}
@@ -92,7 +93,8 @@ EOF
92display_tips() { 93display_tips() {
93 cat << EOF 94 cat << EOF
94 95
951) To replace all occurrences of bsetbg in a file use this command: 961) 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 ;;
131esac 133esac
132 134
133
134message() { 135message() {
135 xmessage -center "$@" 136 xmessage -center "$@"
136} 137}
@@ -169,13 +170,79 @@ or Esetroot (from Eterm)"
169standardok=\ 170standardok=\
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
173unset 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
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 ;;
236esac
237
238
172case $WPSETTER in 239case $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 ;;
252esac 326esac
253 327
254#Get options. 328if [ "$debug" = true ];then
255getopts ":a:f:c:t:A:F:C:T:pdlh-" COMMAND_LINE_ARGUMENT 329 debugfbsetbg
256case "${COMMAND_LINE_ARGUMENT}" in 330 exit 0
257 d) debugfbsetbg 331fi
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 ;;
317esac
318 332
319option=${option:=$full} 333option=${option:='$full'}
320wallpaper=${wallpaper:=$1} 334wallpaper=${wallpaper:=$1}
321 335
322
323if [ ! -r "$wallpaper" ]; then 336if [ ! -r "$wallpaper" ]; then
324 message "Can't find wallpaper $wallpaper" 337 message "Can't find wallpaper $wallpaper"
325 exit 1 338 exit 1
326fi 339fi
327 340
328$WPSETTER $option "$wallpaper" || message "Something went wrong while setting the wallpaper 341eval $WPSETTER $option "$wallpaper"
342if [ $? -ne 0 ]; then
343 message "Something went wrong while setting the wallpaper.
329Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what." 344Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what."
345 exit 1
346fi
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.