-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconky.sh
executable file
·53 lines (44 loc) · 1.17 KB
/
conky.sh
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
#!/bin/bash
# Global Variables
# ===============================================
_pid=$(pidof conky)
_workdir='~/.conky'
# Functions
# ===============================================
function init() {
if [ ! -z ${_pid} ]; then
echo "[ ERROR ]: Conky is still running, please use restart argument."
exit 1
fi
conky -d -c ${_workdir}/conky.conf &> /dev/null && echo "[ OK ]: Conky started."
}
function reinit() {
if [ -z ${_pid} ]; then
echo "[ ERROR ]: Conky is not running."
conky -d -c ${_workdir}/conky.conf &> /dev/null && echo "[ OK ]: Conky started."
else
kill ${_pid} && echo "[ OK ]: Conky stoped."
sleep 1
conky -d -c ${_workdir}/conky.conf &> /dev/null && echo "[ OK ]: Conky started."
fi
}
function destroy() {
if [ -z ${_pid} ]; then
echo "[ ERROR ]: Conky is not running."
exit 1
fi
kill ${_pid} && echo "[ OK ]: Conky stoped."
}
# Main script
# ===============================================
if [ -z ${1} ]; then
echo "Usage: ${0} <start | restart | stop>"
exit 1
fi
case ${1} in
start) init ;;
restart) reinit ;;
stop) destroy ;;
*) echo "Usage: ${0} <start | restart | stop>"; exit 1;;
esac
exit 0