blob: 2588b4b63d2c66b336d5f1eb320eb41452abdfd4 (
plain)
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/sh
. slib
help() {
cat << EOF
${0}: Wrapper script to set wallpapers
options:
-d [File] Select a wallpaper or a directory
-c Remove the current wallpaper
-h Print this message and exit
NOTE: default directory is ~/.config/wallpapers
EOF
exit 0
}
check_program "xwallpaper"
if [ "${#}" = 0 ]; then
#FIXME: use XDG_CONFIG
input="${HOME}/.config/wallpapers"
elif [ "${#}" != 1 ] && [ "${#}" != 2 ]; then
invalid_use
fi
while getopts "hcd:" option; do
case "${option}" in
c) run "xwallpaper --clear" ;;
d) input="${OPTARG}" ;;
h) help ;;
*) invalid_use -h ;;
esac
done
shift $((OPTIND - 1))
[ "${#}" != 0 ] && invalid_use
if [ -n "${input}" ]; then
case $(file -L -b --mime-type "${input}") in
image/*) image="${input}" ;;
inode/directory) waldir="${input}" ;;
*) err "Couldn't read given file" ;;
esac
fi
if [ -n "${waldir}" ]; then
image=$(find "${waldir}" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' 2>/dev/null \
| shuf -n 1 )
fi
[ -z "${image}" ] && err "No image file found"
run "xwallpaper --zoom ${image}" "${image}"
|