-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwallpaper
executable file
·95 lines (72 loc) · 2.03 KB
/
wallpaper
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
# DESCRIPTION:
# * set image as a wallpaper
#
# ARGUMENTS:
# * image path
#
# DEPENDENCIES:
# * Interpreter: POSIX shell + coreutils
# * Wallpaper setter: xwallpaper | hsetroot | nitrogen | feh | Esetroot |
# (xdpyinfo | xwininfo | xrdb) + (graphicsmagick | imagemagick)
#
set -o errexit # exit on fail
set -o nounset # exit on undeclared variable
# set -o xtrace # trace execution
if [ -d "${1}" ]; then
wp=$(shuf --echo --head-count=1 -- "${1}"/*)
else
wp=${1}
fi
if command -v xwallpaper >/dev/null; then
xwallpaper --stretch "${wp}"
exit 0
elif command -v hsetroot >/dev/null; then
hsetroot -fill "${wp}"
exit 0
elif command -v nitrogen >/dev/null; then
nitrogen --set-scaled -- "${wp}"
exit 0
elif command -v feh >/dev/null; then
feh --bg-scale --no-fehbg -- "${wp}"
exit 0
elif command -v Esetroot >/dev/null; then
Esetroot -scale "${wp}"
exit 0
fi
if command -v xdpyinfo >/dev/null; then
dimensions=$(
xdpyinfo | grep dimensions |
tr --squeeze-repeats ' ' | cut --delimiter=' ' --fields=3
)
elif command -v xwininfo >/dev/null; then
dimensions=$(
xwininfo -root | grep geometry | tr '+' ' ' |
tr --squeeze-repeats ' ' | cut --delimiter=' ' --fields=3
)
elif command -v xrdb >/dev/null; then
width=$(
echo 'SKIP: WIDTH'| xrdb -n |
tr '\t' ' ' | cut --delimiter=' ' --fields=2
)
height=$(
echo 'SKIP: HEIGHT'| xrdb -n |
tr '\t' ' ' | cut --delimiter=' ' --fields=2
)
dimensions=${width}x${height}
else
echo "Could not get the screen geometry"
exit 1
fi
if command -v gm >/dev/null; then
gm display -geometry "${dimensions}!" -window root "${wp}"
exit 0
elif command -v display >/dev/null; then
display -resize "${dimensions}!" -window root -- "${wp}"
exit 0
else
# xloadimage/xsetbg and xli all suck bc they can't resize some files
# xsetroot suck bc it can't set jpeg/png as a wallpaper
echo "No appropriate wallpaper setter installed"
exit 1
fi