-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcutsBar.sh
executable file
·89 lines (76 loc) · 1.97 KB
/
shortcutsBar.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
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
#!/bin/sh
SHORTCUTBAR_FILE="/tmp/shortcutBar"
cWhite="#ffffff"
cGray="#a0a0a0"
cGreen="#20c020"
cOrange="#ffe000"
cRed="#c00000"
names=( "Mount Bridge" "Turn on ethernet" "Turn on wifi" "Turn on laptop_mode" "Suspend")
exes=( "mount /mnt/Bridge" "sudo rc-service net.enp0s10 start; sudo rc-service privoxy start" "sudo rc-service net.wlan0 start && sudo rc-service privoxy start" "sudo rc-service laptop_mode start" "sudp pm-suspend")
selected=''
if [ -f "$SHORTCUTBAR_FILE" ]; then
selected="$(cat $SHORTCUTBAR_FILE)"
fi
if [ "$(cat /etc/mtab | grep Bridge)" ]; then
names[0]="Umount Bridge"
exes[0]="umount /mnt/Bridge"
fi
if [ "$(ifconfig | grep enp0s10)" ]; then
names[1]="Turn off ethernet"
exes[1]="sudo rc-service net.enp0s10 stop"
fi
if [ "$(ifconfig | grep wlan0)" ]; then
names[2]="Turn off wifi"
exes[2]="sudo rc-service net.wlan0 stop"
fi
function toggleNetService {
status="$(rc-status | grep "net.$1" | cut -d [ -f 2 | cut -d ] -f 1)"
if [ "$status" == " stopped " ]; then
sudo rc-service net.$1 start > /dev/null
else
sudo rc-service net.$1 stop > /dev/null
fi
}
function block {
echo '{"name": "asdf", "color": "'"$1"'", "full_text": "'"$2"'", "short_text": "'"$3"'"}'
}
if [ -z "$1" ]; then
if [ -z "$selected" ]; then
exit 1
fi
line=""
i=0
for name in "${names[@]}"; do
if [ $i == $selected ]; then
line="$line$(block "$cWhite" "$name" "we"),"
else
line="$line$(block "$cGray" "$name" "we"),"
fi
i=$(($i+1))
done
echo "${line%?}"
exit 0
fi
case "$1" in
'enable')
echo 0 > $SHORTCUTBAR_FILE
killall -USR1 i3status
exit 1;;
'disable')
echo '' > $SHORTCUTBAR_FILE
killall -USR1 i3status
exit 1;;
'+')
echo $(($selected + 1)) > $SHORTCUTBAR_FILE
killall -USR1 i3status
exit 1;;
'-')
echo $(($selected - 1)) > $SHORTCUTBAR_FILE
killall -USR1 i3status
exit 1;;
'select')
${exes[$selected]} || ~/.i3/i3status.sh notify "${names[$selected]} failed"
echo '' > $SHORTCUTBAR_FILE
killall -USR1 i3status
exit 1;;
esac