forked from flaport/home
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdwm_status
executable file
·637 lines (551 loc) · 19.8 KB
/
dwm_status
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
#!/bin/sh
# _____ _ ____ ____ ____ ____ _____
# / // \ / _ \/ __\/ _ \/ __\/__ __\
# | __\| | | / \|| \/|| / \|| \/| / \
# | | | |_/\| |-||| __/| \_/|| / | |
# \_/ \____/\_/ \|\_/ \____/\_/\_\ \_/
# Widget selection
#--------------------------------------------------------------------------------
# the widget delimiter ascii code (ascii code should match with code defined in dwm config.h):
DELIM_ASCII_CODE=32 # 32: ascii code for space
# the delimiter is derived form the ascii code:
DELIM=$(printf "\x$(printf %x $DELIM_ASCII_CODE)")
# folder where widgets and status bar will be cached:
CACHEDIR="$HOME/.cache/dwm_status"
mkdir -p "$CACHEDIR"
# The widget array determines which widgets are included in the status bar.
# Each included widget needs to be defined below by a function with the same name.
setstatus(){
status \
network \
transmission \
playercontrol \
appointments \
syncthing \
sshd \
sshtunnel \
jellyfin \
jupyterhub \
openvpn \
openconnect \
cups \
gpg \
email \
pacmanstatus \
volume \
brightness \
battery \
alpha \
weather \
calendar \
clock \
# services \
# bluetooth \
# memory \
# cpu \
# disk \
# localip \
# publicip \
# wifi \
}
# Parse arguments
#--------------------------------------------------------------------------------
usage(){
>&2 echo "usage: dwm_status [widget-name|widget-index] [mouse-button-index 1|2|3]"
>&2 echo ""
>&2 echo "* without arguments: status bar is updated."
>&2 echo "* with arguments: when a widget name OR widget-index is specified, a mouse button index (1,2,3) MUST be specified as well."
>&2 echo ""
exit "$1"
}
[ "$1" = "-h" ] || [ "$1" = "--help" ] && usage 0
WIDGET="$1"
BUTTON="$2"
if [ -n "$WIDGET" ]; then
[ -z "$BUTTON" ] && usage 1
[ "$BUTTON" -ge 1 ] 2> /dev/null || usage 1
[ "$BUTTON" -le 3 ] 2> /dev/null || usage 1
fi
# Status Command
#--------------------------------------------------------------------------------
# the status function pastes the output of each widget (defined below) together
# into the status bar of dwm (by using xsetroot).
status(){
idx=0
rootname=""
tempdelim="#DELIM#" # temporary delimiter, will be replaced by $DELIM later on. Defining a temporary delimiter is necessary as it ensures one can use a normal space as delimiter.
if [ ! -z "$BUTTON" ]; then
"$WIDGET$BUTTON" 2> /dev/null && return # if widget name given
fi
for widget in "$@" # if no widget or widget index given
do
out=$($widget)
if [ -n "$out" ]; then
if [ -n "$BUTTON" ] && [ "$WIDGET" -eq "$idx" ]; then
"$widget$BUTTON" > /dev/null 2>/dev/null || usage 1
out="$("$widget")"
fi
rootname="$rootname $out$tempdelim"
idx=$((idx+1))
fi
done
# unicode space U+2000:
unicodespace=$(printf "$(printf '\\%o' $(printf %08x 0x2000 | sed 's/../0x& /g'))" | iconv -f UTF-32BE -t UTF-8)
# replace all normal spaces by the unicode space (ascii space is reserved as a possible delimiter):
rootname="$unicodespace$(echo "$rootname" | sed "s/[ ]/$unicodespace/g" | sed "s/$tempdelim/$DELIM/g" | sed "s/$DELIM\$//g" )$unicodespace"
xsetroot -name "$rootname" > /dev/null 2>/dev/null
echo "$rootname" > "$CACHEDIR/status" 2> /dev/null
}
# Helper functions
#--------------------------------------------------------------------------------
notifyservice(){
name="$1"
[ -z "$2" ] || icon="$2 "
dte="$(date +'%a %Y-%m-%d')"
tz="$(timedatectl | grep "Time zone" | sed 's/^[^(]*(\([^,]*\),.*/\1/g')"
title="$(echo "$name" | sed 's/org.cups.cupsd/CUPS printer/g' | sed 's/^[ ]*//g' )"
status="$(systemctl status "$name" | grep Active: | sed 's/^[^)]*)[ ]*//g' | sed "s/$dte //g" | sed "s/ $tz//g" | sed 's/;[ ]/\n/g' | sed 's/^[ ]*//g' )"
suffix="\n[ + + s: toggle any service ]"
if systemctl is-active "$name" > /dev/null 2>/dev/null; then
notify-send "$icon$title service 🔵" "\nactive $status\n\n[ middle click to stop ]$suffix"
else
notify-send "$icon$title service 🔴" "\ndead $status\n\n[ middle click to start ]$suffix"
fi
}
toggleservice(){
name=$1
if systemctl is-active "$name" > /dev/null 2>/dev/null; then
sudo -A -p "[sudo] password to stop $name.service" systemctl stop "$name"
else
sudo -A -p "[sudo] password to restart $name.service" systemctl start "$name"
fi
}
# Widgets
#--------------------------------------------------------------------------------
# -----------
# shows window transparency (defined in Xresources, enabled by picom)
alpha(){ # window transparency
if pidof picom > /dev/null; then
echo " $("$HOME/.scripts/x/alpha" get)%"
fi
}
alpha1(){ # mouse-button 1 action for alpha widget
notify-send "[α] window transparency" "\n[ + a: decrease transparency ]\n[ + + a: increase transparency ]"
}
# -----------
# shows battery percentage left
battery(){ # battery
pct=$(cat /sys/class/power_supply/BAT*/capacity 2> /dev/null | head -1) || return
[ -z "$pct" ] && return
batstatus=$(cat /sys/class/power_supply/BAT*/status | head -1)
if [ "$batstatus" = "Discharging" ] > /dev/null 2>/dev/null; then
[ "$pct" -gt 90 ] && echo " $pct%" && return
[ "$pct" -gt 60 ] && echo " $pct%" && return
[ "$pct" -gt 30 ] && echo " $pct%" && return
[ "$pct" -gt 5 ] && echo " $pct%" && return
echo " $pct%" && return
fi
echo " $pct%"
}
battery1(){ # mouse-button 1 action for battery widget
pct="$(cat /sys/class/power_supply/BAT*/capacity | head -1)"
batstatus=$(cat /sys/class/power_supply/BAT*/status | head -1)
timeleft=" $(acpi -b | sed 's/.*,//g' | sed 's/^[ ]*//g' | sed 's/^00://g')"
if [ "$batstatus" = "Discharging" ] > /dev/null 2>/dev/null; then
[ "$pct" -gt 95 ] && notify-send "🔋 battery fully charged." "$timeleft" && return
notify-send "🔋 battery discharging." "$timeleft"
return
fi
[ "$pct" -gt 95 ] && notify-send "🔌 battery fully charged." && return
notify-send "🔌 battery charging." "$timeleft"
}
# -----------
# control brightness
brightness(){ # screen brightness
light -L 2> /dev/null | grep backlight > /dev/null || return
printf " %.0f%%" "$(light)" 2> /dev/null
}
brightness1(){ # mouse-button 1 action for brightness widget
brightness=$(printf "%.0f%%" "$(light)")
notify-send "☀ brightness [$brightness]" "\n[ + F11: brightness up ]\n[ + F12: brightness down ]"
}
# -----------
# show if bluetooth is connected, otherwise
bluetooth(){ # bluetooth
[ ! -d /sys/class/bluetooth ] && echo "" && return
device=$(echo exit | bluetoothctl | grep -o -m 1 "\b\[.*\]" | sed "s/.*\[\(.*\)\].*/\1/g")
[ "$device" = "bluetooth" ] && echo || echo
}
bluetooth1(){ # mouse-button 1 action for bluetooth widget
device=$(echo exit | bluetoothctl | grep -o -m 1 "\b\[.*\]" | sed "s/.*\[\(.*\)\].*/\1/g")
if [ "$device" = "bluetooth" ]; then
notify-send " Bluetooth disconnected" "\n[ middle click / + b to connect ]"
else
notify-send " Bluetooth connected" "to $device\n\n[ middle click / + b to disconnect ]"
fi
}
bluetooth2(){ # mouse-button 1 action for bluetooth widget
dmenu_bluetooth
}
# -----------
# show time of current/next appointment.
appointments(){
hm="$(grep "$(date +'%m/%d/%Y')" "$HOME/.calcurse/apts" | sed 's/!/|/g' | sed 's/[^@]*@\ \([0-9]*:[0-9]*\)[^@]*@[^|]*|/\1: /g' | grep "$(date +'%H')" | sed 's/^\([0-9][0-9]:[0-9][0-9]\).*/\1/g')"
if [ -z "$hm" ]; then
next=$(calcurse --next | sed '/next.*/d')
[ -z "$next" ] && return
H=$(date +'%H' | sed 's/^0//g')
M=$(date +'%M' | sed 's/^0//g')
h=$(echo "$next" | sed 's/^[^0-9]*\([0-9]*\).*/\1/g' | sed 's/^0//g')
m=$(echo "$next" | sed 's/^[^:]*:[^0-9]*\([0-9]*\).*/\1/g' | sed 's/^0//g')
m=$((M+m))
h=$((H+h))
while [ "$m" -ge 60 ]; do
m=$((m-60))
h=$((h+1))
done
m=$(echo "0$m" | sed 's/^0\([0-9][0-9]$\)/\1/g')
while [ "$h" -ge 24 ]; do
h=$((h-24))
done
h=$(echo "0$h" | sed 's/^0\([0-9][0-9]$\)/\1/g')
hm=$h:$m
fi
echo " $hm"
}
appointments1(){
apt1="$(grep "$(date +'%m/%d/%Y')" "$HOME/.calcurse/apts" | sed 's/!/|/g' | sed 's/[^@]*@\ \([0-9]*:[0-9]*\)[^@]*@[^|]*|/\1: /g' | grep "$(date +'%H')" | sed 's/^[0-9][0-9]:[0-9][0-9]:\ //g')"
apt2="$(calcurse --next | sed '/next.*/d')"
echo "$apt2" | grep "$apt1" > /dev/null 2>/dev/null && apt1=""
[ -z "$apt1" ] || apt1=" [ now ] $apt1\n"
notify-send "📅 Appointment:" "$apt1$apt2\n\n[ middle click to open calcurse. ]"
}
appointments2(){
st -e calcurse
}
# -----------
# shows the current date
calendar(){ # date
date +' %Y-%m-%d'
}
calendar1(){ # mouse-button 1 action for date widget
notify-send "📅$(date +'%A, %B %d')" "\n$(cal | sed "s/\<$(date +%-d)\>//g")"
}
# -----------
# shows a clock
clock(){ # time
date +' %H:%M'
}
clock1(){ # mouse-button 1 action for time widget
notify-send "🕐 $(date +'%H:%M')"
calendar1
}
# -----------
# shows cpu usage
cpu(){ # cpu
read -r cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read -r cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
echo " $cpu%"
}
cpu1(){ # mouse-button 1 action for cpu widget
notify-send "$(cpu) cpu"
}
# -----------
# show icon if the CUPS printer service is running
cups(){ # CUPS printer status
systemctl is-active org.cups.cupsd > /dev/null 2>/dev/null && echo
}
cups1(){
notifyservice org.cups.cupsd 🖨
}
cups2(){
toggleservice org.cups.cupsd
}
# -----------
# uses same icon as memory. Know which one is which.
disk(){ # memory
usage=$(df -h . | grep -v Filesystem | awk '{print $5}')
echo " $usage"
}
disk1() { # mouse-button 1 action for memory widget
notify-send "💾 disk usage: $(df -h "$HOME")"
}
# -----------
# show icon if a gpg key password is currently cached
gpg(){ # cached gpg keys
gpg-connect-agent 'keyinfo --list' /bye | grep "1 P" > /dev/null 2>/dev/null \
&& echo
}
gpg1(){ # mouse-button 1 to display cached keys
key=$(gpg-connect-agent 'keyinfo --list' /bye | grep "1 P" | sed 's/.*KEYINFO\ *\([^\ !]*\).*/\1/g')
notify-send "🔑 passwords cached for these gpg keys:" "$key\n\n[ middle click to empty cache ]"
}
gpg2(){ # mouse-button 2 to empty gpg password cache
kill -SIGHUP "$(pidof gpg-agent)"
}
# -----------
# show icon if jupyterhub service is active
jupyterhub(){ # jupyterhub status
systemctl is-active jupyterhub > /dev/null 2>/dev/null && echo
}
jupyterhub1(){ # mouse-button 1 action for jupyterhub widget
notifyservice jupyterhub 🪐
}
jupyterhub2(){
toggleservice jupyterhub
}
# -----------
# show icon if jellyfin service is active
jellyfin(){ # jupyterhub status
systemctl is-active jellyfin > /dev/null 2>/dev/null && echo
}
jellyfin1(){ # mouse-button 1 action for jupyterhub widget
notifyservice jellyfin 📺
}
jellyfin2(){
toggleservice jellyfin
}
# -----------
# number of unread emails
email(){ # number of unread emails
[ -f "$HOME/.msmtprc" ] || return
if gpg-connect-agent 'keyinfo --list' /bye | grep "1 P" > /dev/null 2>/dev/null;
then
num_unread=$(find "$HOME"/.local/share/email/*/INBOX/new/ -type f | wc -l 2> /dev/null)
echo " $num_unread"
else
echo " "
fi
}
email1(){ # give more email info
num_unread=$(find "$HOME/.local/share/email/*/INBOX/new/" -type f | wc -l 2> /dev/null)
if gpg-connect-agent 'keyinfo --list' /bye | grep "1 P" > /dev/null 2>/dev/null;
then
notify-send "📧 $num_unread unread emails" "\n[ middle click to sync now. ]\n[ + + r: sync now ]"
else
notify-send "📧 emails not syncing." "($num_unread unread emails)\n\n[ middle click to unlock gpg key and sync now ]"
fi
}
email2(){ # start syncing emails
"$HOME/.scripts/email/syncmail"
}
# -----------
# same info after clicking network icon
localip(){ # local ip address
nmcli -a | grep inet4 | sed 's/^[^ ]*[ ]\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/g' | head -1
}
localip1(){
network1
}
# -----------
# uses same icon as disk. Know which one is which.
memory(){ # memory
used=$(free | awk '/Mem/ {print $3 }')
total=$(free | awk '/Mem/ {print $2 }')
percentage=$(python -c "print(f'{100*$used/$total:.0f}%')")
echo " $percentage"
}
memory1() { # mouse-button 1 action for memory widget
mem=$(free | awk '/Mem/ {printf "%d MiB/%d MiB\n", $3 / 1024.0, $2 / 1024.0 }')
notify-send "💾 free RAM $mem"
}
# -----------
# shows a clickable globe icon.
network(){
echo
}
network1(){
notify-send "🌐 Network:" "connected to: $(wifi)\nlocal ip: $(localip)\npublic ip: $(publicip)"
}
# -----------
# show icon if openconnect is connected
openconnect(){ # openconnect
pidof openconnect > /dev/null 2>/dev/null && echo #|| echo ""
}
openconnect1(){ # mouse-button 1 action for openconnect widget
if pidof openconnect > /dev/null 2>/dev/null; then
notify-send "🔐 openconnect" "running.\n\n[ middle click to stop ]"
else
notify-send "🔐 openconnect" "stopped.\n\n[ middle click to start ]"
fi
}
openconnect2(){ # mouse-button 1 action for openconnect widget
pidof openconnect > /dev/null 2>/dev/null && sudo -A killall openconnect
}
# -----------
# show icon if openvpn is connected
openvpn(){ # openvpn
systemctl is-active openvpn > /dev/null 2>/dev/null && echo || echo ""
}
openvpn1(){ # mouse-button 1 action for openvpn widget
notifyservice openvpn 🔐
}
openvpn2(){ # mouse-button 2 action for openvpn widget
toggleservice openvpn
}
# -----------
# number of updatable packages
pacmanstatus(){ # pacman
num=$(pacman -Qu | wc -l)
[ "$num" -gt 0 ] && echo " $num"
}
pacmanstatus1(){ # pacman
num=$(pacman -Qu | wc -l)
notify-send "📦 pacman" "$num packages can be updated\n\n[ middle click to update with \"pacman -Syu\" ]"
}
pacmanstatus2(){ # update packages
sudo -A -p "[sudo] password for 'pacman -Syu'" st -n float -e pacman -Syu
}
# -----------
# status of currently open media player (pause/play)
playercontrol(){ # toggle a service
# the icon needs to be cached as sometimes playerctl gives Stopped when nothing has happened.
previous_icon=$(cat "$CACHEDIR/playercontrol") 2> /dev/null
[ -z "$previous_icon" ] && previous_icon=
icon=$(timeout 1s playerctl status 2> /dev/null | sed 's/Playing//g' | sed 's/Paused//g' | sed "s/Stopped/$previous_icon/g") || icon=""
echo "$icon" > "$CACHEDIR/playercontrol"
echo "$icon"
}
playercontrol1(){ # toggle a service
timeout 1s playerctl play-pause
icon1=$(cat "$CACHEDIR/playercontrol")
[ "$icon1" = "" ] && icon2= && notify-send "⏯"
[ "$icon1" = "" ] && icon2= && notify-send "⏯"
echo $icon2 > "$CACHEDIR/playercontrol"
sed -i "s/$icon1/$icon2/g" "$CACHEDIR/status"
xsetroot -name "$(cat "$CACHEDIR/status")"
}
# -----------
# introduces lag due to curl call better not to place in status bar.
publicip(){ # local ip address
curl -s https://ipinfo.io/ip | head -1
}
publicip1(){
network1
}
# -----------
# clickable icon to start/stop services
services(){ # toggle a service
echo
}
services1(){
dmenu_services
}
# -----------
# show icon if sshd service is active
sshd(){ # ssh daemon
systemctl is-active sshd > /dev/null 2>/dev/null && echo # ⛓
}
sshd1(){ # mouse-button 1 action for ssh daemon widget
notifyservice sshd ⛓
}
sshd2(){
toggleservice sshd
}
# -----------
# show icon if sshtunnel service is active
sshtunnel(){ # ssh tunnels
systemctl is-active sshtunnel > /dev/null 2>/dev/null && echo || echo "" # ⛓
}
sshtunnel1(){ # mouse-button 1 action for ssh tunnel widget
notifyservice sshtunnel 🔗
}
sshtunnel2(){
toggleservice sshtunnel
}
# -----------
# show icon if syncthing service is active
syncthing(){ # jupyterhub status
systemctl is-active syncthing > /dev/null 2>/dev/null && echo
}
syncthing1(){ # mouse-button 1 action for jupyterhub widget
notifyservice syncthing
}
syncthing2(){
toggleservice syncthing
}
# -----------
# torrenting status
transmission(){
export PASSWORD_STORE_GPG_OPTS="--pinentry-mode error"
pidof -s transmission-daemon >/dev/null 2>/dev/null || return
pass transmission >/dev/null 2>/dev/null
retval=$?
[ $retval -eq 2 ] && echo && return # transmission active but gpg inactive
if [ $retval -eq 0 ]; then
username=$(pass show transmission | head -2 | tail -1 | sed 's/^[^:]*:[ ]*//g' )
password=$(pass show transmission | head -1)
auth="--auth $username:$password"
fi
if ! transmission-remote "$auth" --list \
| grep -v ID | grep -v Sum:\
| awk '{ print $2;}' \
| sed '/100%/d' | sed 's/%//g' | sed 's|n/a||g' \
| xargs python -c "from sys import argv; print(f' {sum(int(i) for i in argv[1:])/len(argv[1:]):.0f}%')" 2> /dev/null;
then
num=$(transmission-remote "$auth" --list | grep -v ID | grep -vc Sum:)
[ "$num" -gt 0 ] && echo "🌱$num" && return # seeding
echo # active
fi
}
transmission1(){
if pass transmission >/dev/null 2>/dev/null; then
username=$(pass transmission | head -2 | tail -1 | sed 's/^[^:]*:[ ]*//g' )
password=$(pass transmission | head -1)
auth="--auth $username:$password"
fi
num="$(transmission-remote "$auth" --list | grep -v ID | grep -vc Sum:)"
title="$(transmission) Transmission: $(transmission | sed 's//active/g' | sed 's/🌱/seeding/g') [$num]"
msg="\n[ middle click to open transmission-cli ]\n[ right click to stop transmission-daemon ]"
[ "$num" -gt 0 ] && msg="\n$(transmission-remote "$auth" --list)\n$msg"
notify-send "$title" "$msg"
}
transmission2(){
st -e "$HOME/.local/bin/transmission"
}
transmission3(){
kill -SIGTERM "$(pidof transmission-daemon)"
}
# -----------
# volume (managed by pulseaudio)
volume(){ # volume
pct=$(amixer -D pulse get Master | grep "\[on\]" | head -1 | sed "s/^[^\[]*\[\([^%]*\)*%.*/\1/g") || echo 🔇 && return
[ "$pct" -gt 60 ] && echo "🔊$pct%" && return
[ "$pct" -gt 20 ] && echo "🔉$pct%" && return
echo "🔈$pct%"
}
volume1(){ # mouse-button 1 action for volume widget
icon=$(volume | sed 's/^\(.\).*/\1/g')
pct=$(volume | sed 's/^.\(.*\)/\1/g' | sed 's/^[ ]*//g')
notify-send "$icon volume $pct" "\n[ + : volume up ]\n[ + : volume down ]\n[ + + : mute ]"
}
# -----------
# reads from cache! Make sure you have it regularly update somewhere else.
weather(){ # weather
# reads from cache! Make sure you have it regularly update somewhere else.
[ -f "$HOME/.cache/weatherreport/short" ] && sed 's/[ ][ ]*/ /g' "$HOME/.cache/weatherreport/short" || echo ""
}
weather1(){ # mouse-button 1 action for weather widget
# get first 7 lines of weather report and remove all color escape sequences.
report=$(head -7 "$HOME/.cache/weatherreport/full" | sed 's/\x1b\[[0-9;]*m//g' | tail -n 6 | sed 's/\\/\\\\/g' | sed 's/―/-/g')
notify-send "⛅ weather" "$(weather)\n$report\n\n[ middle click for full report ]"
}
weather2(){
st -n float -f mono:12 -g 130x40+1130 -e update_weather --block
}
# -----------
# same info after clicking network icon
wifi(){
nmcli | grep "connected to" | sed 's/.*connected to //g' | head -1
}
wifi1(){
network1
}
# -----------
# Status Command
#--------------------------------------------------------------------------------
setstatus