File: setup-background

package info (click to toggle)
fvwm2 2.0.46-BETA-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 5,172 kB
  • ctags: 5,559
  • sloc: ansic: 52,902; cpp: 2,465; perl: 2,275; python: 779; sh: 604; makefile: 221
file content (62 lines) | stat: -rw-r--r-- 1,597 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
#
# setup-background
# by Lars Wirzenius
# "@(#):$Id$"
#
# Set the X root window to what the user prefers:
#
#	if ~/.fvwm2/background.xpm exists, do xpmroot for it,
#	else if ~/.fvwm2/background.{gif,jpg} exists, do xsetbg for it,
#	else if ~/.fvwm2/background.color exists, do xsetroot -solid for it,
#	else do the same tests for /etc/X11/fvwm2
#

xpmfile="$HOME/.fvwm2/background.xpm"
giffile="$HOME/.fvwm2/background.gif"
jpgfile="$HOME/.fvwm2/background.jpg"
colorfile="$HOME/.fvwm2/background.color"
listfile="$HOME/.fvwm2/background.list"

available()
{
  type -path $1 1>/dev/null 2>&1
}

randline()
{
  filename=$1

  set `wc -l $filename`
  lines=$1

  line=$[ ( $RANDOM % $lines ) + 1 ]

  head -$line $filename | tail -1
}

if available xsetbg; then
  viewer=xsetbg
elif available xv; then
  viewer="xv -root -quit"
else
  viewer="exit 1;"
fi

[ -s $xpmfile ] && xpmroot $xpmfile && exit 0
[ -s $giffile ] && $viewer $giffile && exit 0
[ -s $jpgfile ] && $viewer $jpgfile && exit 0
[ -s $colorfile ] && xsetroot -solid `cat $colorfile` && exit 0
[ -s $listfile ] && $viewer `randline $listfile` && exit 0

xpmfile="/etc/X11/fvwm2/background.xpm"
giffile="/etc/X11/fvwm2/background.gif"
jpgfile="/etc/X11/fvwm2/background.jpg"
colorfile="/etc/X11/fvwm2/background.color"
listfile="/etc/X11/fvwm2/background.list"

[ -s $xpmfile ] && xpmroot $xpmfile && exit 0
[ -s $giffile ] && $viewer $giffile && exit 0
[ -s $jpgfile ] && $viewer $jpgfile && exit 0
[ -s $colorfile ] && xsetroot -solid `cat $colorfile` && exit 0
[ -s $listfile ] && $viewer `randline $listfile` && exit 0