-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfeh-slides
101 lines (84 loc) · 2.67 KB
/
feh-slides
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
96
97
98
99
100
101
#!/bin/bash
#----------------------------------------------------------------------------------
# Project Name - miscellaneous/feh-slides
# Started On - Sun 5 Nov 12:04:09 GMT 2017
# Last Change - Sun 15 Apr 11:51:20 BST 2018
# Author E-Mail - [email protected]
# Author GitHub - https://github.com/terminalforlife
#----------------------------------------------------------------------------------
_VERSION_="2018-04-15"
XERR(){ printf "[L%0.4d] ERROR: %s\n" "$1" "$2" 1>&2; exit 1; }
ERR(){ printf "[L%0.4d] ERROR: %s\n" "$1" "$2" 1>&2; }
USAGE(){
while read -r; do
printf "%s\n" "$REPLY"
done <<-EOF
FEH-SLIDES ($_VERSION_)
Written by terminalforlife ([email protected])
A super-simple desktop wallpaper slideshow.
SYNTAX: feh-slides [OPTS] [PATH]
OPTS: --help|-h|-? - Displays this help information.
--version|-v - Output only the version datestamp.
--debug|-D - Enables the built-in bash debugging.
--interval|-i N - Change wallpaper every N seconds.
--trap|-T - Trap SIGUSR1 for a cleaner exit. This is more
of a placeholder for future expansion.
NOTE: Where PATH is the directory in which your chosen wallpapers are stored.
EOF
}
while [ "$1" ]; do
case "$1" in
--help|-h|-\?)
USAGE; exit 0 ;;
--version|-v)
printf "%s\n" "$_VERSION_"
exit 0 ;;
--debug|-D)
DEBUGME="true" ;;
--interval|-i)
shift; INTERVAL="$1" ;;
--trap|-T)
TRAP="true" ;;
-*)
XERR "$LINENO" "Incorrect argument(s) specified." ;;
*)
break ;;
esac
shift
done
if [ $# -gt 1 ]; then
XERR "$LINENO" "Only one wallpaper directory may be specified."
elif [ $# -eq 0 ]; then
XERR "$LINENO" "A wallpaper directory must be specified."
fi
[ -x /bin/sleep ] || XERR "$LINENO" "Dependency '/bin/sleep' not met."
[ "$DEBUGME" == "true" ] && set -x
# Room for easy expansion.
EXIT(){
kill $$
exit 0
}
if [ -d "$1" ]; then
if [ "$TRAP" == "true" ]; then
trap 'EXIT' 10 # SIGUSR1
fi
while :; do
for FILE in "${1%\/}"/*; {
if [ -f "$FILE" ]; then
if [ -x /usr/bin/feh ]; then
/usr/bin/feh --no-fehbg --bg-center "$FILE"
elif [ -x /usr/bin/nitrogen ]; then
/usr/bin/nitrogen --replace "$FILE"
else
XERR "$LINENO" "Currently, only feh are nitrogen are supported."
fi
if ! /bin/sleep ${INTERVAL:-5}s; then
XERR "$LINENO" "Invalid interval time specified."
fi
fi
}
done
else
XERR "$LINENO" "Directory '$1' not found."
fi
# vim: ft=sh noexpandtab colorcolumn=84 tabstop=8 noswapfile nobackup