-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstm
More file actions
executable file
·184 lines (174 loc) · 3.46 KB
/
stm
File metadata and controls
executable file
·184 lines (174 loc) · 3.46 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
#
# rotsix - (c) wtfpl 2016
# a small script to manage simply some easy tasks as volume or backlight
usage () {
echo -e "${0}"
echo -e "Simple Task Manager"
echo -e " usage : "
echo -e "\t$(basename "$0") backlight|bl +|-|up|down|get [value]"
echo -e "\t$(basename "$0") vol|volume|v +|-|up|toggle|down [value]"
echo -e "\t$(basename "$0") bluetooth|bt start|up|stop|kill|restart|on|off|down"
echo -e "\t$(basename "$0") mysql|sql|sqld|mysqld start|up|stop|kill|restart|on|stop|off"
echo -e "\t$(basename "$0") http|httpd start|up|stop|kill|restart|on|stop|off"
echo -e "\t$(basename "$0") lamp|LAMP start|up|stop|kill|restart|on|stop|off"
}
if [ -z "$1" ]; then
usage
exit 1
fi
if [ -z "$2" ] && [ "$1" != "help" ] && [ "$1" != "h" ] && [ "$1" != "-h" ] && [ "$1" != "--help" ]; then
usage
exit 1
fi
case $1 in
help|h|-h|--help)
usage
exit 0
;;
vol|volume|v)
# card name can be obtained via `pactl list sinks`
card_laptop="alsa_output.pci-0000_00_1f.3.analog-stereo"
card_soundcard="alsa_output.usb-Audient_iD4-00.iec958-stereo"
soundcard_name="usb-Audient_iD4-00.iec958-stereo"
test -n "$(pactl list sinks | grep $soundcard_name)" && card=$card_soundcard || card=$card_laptop
echo $card
test -n "$3" && perc="$3" || perc="3"
case $2 in
up|+)
pactl set-sink-mute "${card}" false
pactl set-sink-volume "${card}" +${perc}%
;;
toggle)
pactl set-sink-mute ${card} toggle
;;
down|-)
pactl set-sink-mute "${card}" false
pactl set-sink-volume "${card}" -${perc}%
;;
*)
usage
exit 1
;;
esac
# set the sound you prefer
aplay "$HOME/.sounds/popup.wav"
;;
mic|micro|microphone|m)
card_laptop="alsa_input.pci-0000_00_1f.3.analog-stereo"
card=$card_laptop
case $2 in
toggle)
pactl set-source-mute "${card}" toggle
;;
*)
usage
exit 1
;;
esac
;;
backlight|bl)
test -n "$3" && perc="$3" || perc="2"
#actual="$(brightnessctl get | grep "Current" | cut -d '(' -f 2 | cut -d '%' -f 1)"
case $2 in
+|up)
brightnessctl set "$perc"%+
;;
-|down)
brightnessctl set "$perc"%-
;;
get)
brightnessctl get
;;
*)
usage
exit 1
;;
esac
;;
bluetooth|bt)
case $2 in
up|start|on)
sudo systemctl start bluetooth
echo "Bluetooth started"
;;
stop|kill|down|off)
sudo systemctl stop bluetooth
echo "Bluetooth stopped"
;;
restart)
sudo systemctl restart bluetooth
echo "Bluetooth restarted"
;;
*)
usage
exit 1
;;
esac
;;
mysql|sql|mysqld|sqld)
case $2 in
up|start|on)
sudo systemctl start mysqld
echo "MySQL daemon started"
;;
stop|kill|down|off)
sudo systemctl stop mysqld
echo "MySQL daemon stopped"
;;
restart)
sudo systemctl restart mysqld
echo "MySQL daemon restarted"
;;
*)
usage
exit 1
;;
esac
;;
http|httpd)
case $2 in
up|start|on)
sudo systemctl start httpd
echo "HTTP daemon started"
;;
stop|kill|down|off)
sudo systemctl stop httpd
echo "HTTP daemon stopped"
;;
restart)
sudo systemctl restart httpd
echo "HTTP daemon restarted"
;;
*)
usage
exit 1
;;
esac
;;
lamp|LAMP)
case $2 in
up|start|on)
stm sql start
stm http start
;;
stop|kill|down|off)
stm sql stop
stm http stop
;;
restart)
stm sql restart
stm httm restart
;;
*)
usage
exit 1
;;
esac
;;
*)
usage
exit 1
;;
esac
exit 0