-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathawesome-widgets.sh
More file actions
executable file
·640 lines (519 loc) · 24.8 KB
/
awesome-widgets.sh
File metadata and controls
executable file
·640 lines (519 loc) · 24.8 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
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
638
639
640
#!/usr/bin/env bash
## By Davoud Arsalani
## https://github.com/davoudarsalani/scripts
## https://github.com/davoudarsalani/scripts/blob/master/awesome-widgets.sh
## https://raw.githubusercontent.com/davoudarsalani/scripts/master/awesome-widgets.sh
## https://davoudarsalani.ir
source ~/main/scripts/utils.sh
declare -i threshhold=70
case "$1" in
wifi )
case "$2" in
turn_on )
nmcli radio wifi on && \
msgn "<span color=\"${gruvbox_orange}\">wifi</span> turned on" || \
msgn "<span color=\"${gruvbox_orange}\">wifi</span> turn on failed" ;;
turn_off )
nmcli radio wifi off && \
msgn "<span color=\"${gruvbox_orange}\">wifi</span> turned off" || \
msgn "<span color=\"${gruvbox_orange}\">wifi</span> turn off failed" ;;
esac ;;
## -------------------------------
clock )
hm="$(date '+%I:%M')"
set_widget 'clock' 'markup' "$hm" ;;
audio )
function update_variables {
source ~/main/scripts/utils-audio.sh
}
update_variables
function mute_vol {
pactl set-sink-mute "$def_sink_index" 1 ## OR pactl set-sink-mute "$def_sink_index" true <--,
} ## |
## |
function unmute_vol { ## |
pactl set-sink-mute "$def_sink_index" 0 ## OR pactl set-sink-mute "$def_sink_index" false <--'-- pactl set-sink-mute "$def_sink_index" toggle
}
function mute_mic {
pactl set-source-mute "$def_source_index" 1
}
function unmute_mic {
pactl set-source-mute "$def_source_index" 0
}
# function mic_0 {
# pactl set-source-volume "$def_source_index" 0%
# }
# function mic_25 {
# pactl set-source-volume "$def_source_index" 25%
# }
function mute_mon {
pactl set-source-mute "$def_source_mon_index" 1
}
function unmute_mon {
pactl set-source-mute "$def_source_mon_index" 0
}
# function mon_0 {
# pactl set-source-volume "$def_source_mon_index" 0%
# }
# function mon_100 {
# pactl set-source-volume "$def_source_mon_index" 100%
# }
case "$2" in
vol_30 )
pactl set-sink-volume "$def_sink_index" 30% ;;
toggle_vol )
if [ "$vol_mute_status" == 'yes' ]; then
unmute_vol
else
mute_vol
fi ;;
vol_up )
pactl set-sink-volume "$def_sink_index" +5% ;;
vol_down )
pactl set-sink-volume "$def_sink_index" -5% ;;
# vol_100 )
# pactl set-sink-volume "$def_sink_index" 100% ;;
# vol_0 )
# pactl set-sink-volume "$def_sink_index" 0% ;;
toggle_mic )
if [ "$mic_mute_status" == 'yes' ]; then
unmute_mic
else
mute_mic
fi ;;
mic_up )
pactl set-source-volume "$def_source_index" +5% ;;
mic_down )
pactl set-source-volume "$def_source_index" -5% ;;
mic_100 )
pactl set-source-volume "$def_source_index" 100% ;;
mic_0 )
pactl set-source-volume "$def_source_index" 0% ;;
toggle_mon )
if [ "$mon_mute_status" == 'yes' ]; then
unmute_mon
else
mute_mon
fi ;;
mon_up )
pactl set-source-volume "$def_source_mon_index" +5% ;;
mon_down )
pactl set-source-volume "$def_source_mon_index" -5% ;;
mon_100 )
pactl set-source-volume "$def_source_mon_index" 100% ;;
mon_0 )
pactl set-source-volume "$def_source_mon_index" 0% ;;
full_info )
text="$(printf '%s\n' \
"<span color=\"${gruvbox_orange}\">Vol</span>
name: ${def_sink_name}
index: ${def_sink_index}
level: ${vol_level}
state: ${vol_state}
mute: ${vol_mute_status}
<span color=\"${gruvbox_orange}\">Mic</span>
name: ${def_source_name}
index: ${def_source_index}
level: ${mic_level}
state: ${mic_state}
mute: ${mic_mute_status}
<span color=\"${gruvbox_orange}\">Mon</span>
name: ${def_source_mon_name}
index: ${def_source_mon_index}
level: ${mon_level}
state: ${mon_state}
mute: ${mon_mute_status}
<span color=\"${gruvbox_orange}\">Active ports</span>
sink: ${active_sink_port}
source: ${active_source_port}")"
msgn "$text" ;;
esac
update_variables
[ "$vol_mute_status" == 'yes' ] && vol_on_off="<span color=\"${gruvbox_red}\">:OF</span>"
(( vol_level > 0 )) || vol_level="<span color=\"${gruvbox_red}\">${vol_level}</span>"
## mic is on
if [ "$mic_mute_status" == 'no' ]; then
mic_info=" MIC:<span color=\"${gruvbox_red}\">${mic_level}:ON</span>"
## mic is off
else
if (( mic_level > 0 )); then
mic_info=" MIC:<span color=\"${gruvbox_red}\">${mic_level}:OF</span>"
else
mic_info=''
fi
fi
## mon is on
if [ "$mon_mute_status" == 'no' ]; then
mon_info=" MON:<span color=\"${gruvbox_red}\">${mon_level}:ON</span>"
## mon is off
else
if (( mon_level > 0 )); then
mon_info=" MON:<span color=\"${gruvbox_red}\">${mon_level}:OF</span>"
else
mon_info=''
fi
fi
# states_initials="${vol_state::1}${mic_state::1}${mon_state::1}" ## RSI
# indeces="${def_sink_index}${def_source_index}${def_source_mon_index}" ## 010
#
# headset_regex='bluez_sink*'
# [[ "$def_sink_name" =~ $headset_regex ]] && headset_connectivity=' HE'
## previously: [ "$(printf '%s\n' "$def_sink_name" | \grep '^bluez_sink')" ] && headset_connectivity=' HE'
#
# xtra_info=" ${states_initials} ${indeces}${headset_connectivity}"
set_widget 'audio' 'markup' "${vol_level}${vol_on_off}${mic_info}${mon_info}${xtra_info}" ;;
memory_cpu )
source ~/main/scripts/utils-calculation.sh
case "$2" in
intensives )
top_memory="$(ps axch -o cmd:15,%mem --sort=-%mem | head -n 10)" ## <--,-- 15 makes it only 15 characters long
top_cpu="$(ps axch -o cmd:15,%cpu --sort=-%cpu | head -n 10)" ## <--'
message_text="$(printf "<span color=\"%s\">Memory</span>\n%s\n\n<span color=\"%s\">CPU</span>\n%s\n" "$gruvbox_orange" "$top_memory" "$gruvbox_orange" "$top_cpu")"
msgn "$message_text" ;;
usage )
## NOTE JUMP_3 memory should be calculated at the end
## becuase IFS=$ in memory section interferes
## with the calculations in cpu and cpu temperature
## ------------
## cpu (https://www.idnt.net/en-US/kb/941772)
## get last cpu
cpu_last="$(redis-cli GET 'awesome_widget__cpu')"
## '--> cpu 0 0 0 0 0 0 0 0 0 0 (is str)
##
if [ "$cpu_last" ]; then
## str -> array
read -a cpu_last <<< "$cpu_last"
else
cpu_last=( cpu 0 0 0 0 0 0 0 0 0 0 )
fi
## get last cpu sum
cpu_sum_last="$(redis-cli GET 'awesome_widget__cpu_sum')" ## 19410508
##
[ "$cpu_sum_last" ] || cpu_sum_last=0
## get new usage
read -a cpu_now < /proc/stat ## get the first line with aggregate of all cpus
cpu_sum="${cpu_now[@]:1}" ## get all columns but skip the first (which is the 'cpu' string)
## ^^ cpu_sum is a str
(( cpu_sum="${cpu_sum// /+}" )) ## replace the column seperator (space) with +
(( cpu_delta="cpu_sum - cpu_sum_last" )) ## get the delta between two reads
(( cpu_idle="cpu_now[4] - cpu_last[4]" )) ## get the idle time delta
(( cpu_used="cpu_delta - cpu_idle" )) ## calc time spent working
cpu_perc="$(float_pad "100*${cpu_used}/${cpu_delta}" 1 1)"
## array -> str
cpu_now__str="$(printf '%s ' "${cpu_now[@]}")"
## save for our next read
redis-cli SET 'awesome_widget__cpu' "$cpu_now__str" || msgn 'ERROR saving cpu_now'
redis-cli SET 'awesome_widget__cpu_sum' "$cpu_sum" || msgn 'ERROR saving cpu_sum'
cpu_geater="$(compare_floats "$cpu_perc" ">" "$threshhold")"
[ "$cpu_geater" == 'true' ] && cpu_perc="<span color=\"${gruvbox_red}\">${cpu_perc}</span>"
## cpu temperature
cpu_temp="$(sensors | \grep 'Package' | cut -d '+' -f 2 | cut -d '.' -f 1)"
cpu_temp_greater="$(compare_floats "$cpu_temp" '>' "$threshhold")"
[ "$cpu_temp_greater" == 'true' ] && cpu_temp="<span color=\"${gruvbox_red}\">${cpu_temp}</span>"
## ------------
## memory
## NOTE JUMP_3 memory should be calculated at the end
## becuase IFS=$ in memory section interferes
## with the calculations in cpu and cpu temperature
IFS=$
mem_info="$(< /proc/meminfo)"
mem_total="$(printf '%s\n' "$mem_info" | \grep '^MemTotal' | awk '{print $2}')"
mem_free="$(printf '%s\n' "$mem_info" | \grep '^MemFree' | awk '{print $2}')"
mem_buffers="$(printf '%s\n' "$mem_info" | \grep '^Buffers' | awk '{print $2}')"
mem_cached="$(printf '%s\n' "$mem_info" | \grep '^Cached' | awk '{print $2}')"
mem_srec="$(printf '%s\n' "$mem_info" | \grep '^SReclaimable' | awk '{print $2}')"
(( mem_used="mem_total - mem_free - mem_buffers - mem_cached - mem_srec" ))
mem_perc="$(float_pad "${mem_used}/${mem_total}*100" 1 1)"
mem_geater="$(compare_floats "$mem_perc" '>' "$threshhold")"
[ "$mem_geater" == 'true' ] && mem_perc="<span color=\"${gruvbox_red}\">${mem_perc}</span>"
set_widget 'memory_cpu' 'markup' "${mem_perc} ${cpu_perc} ${cpu_temp}°${cpu_gov}" ;;
esac ;;
harddisk )
source ~/main/scripts/utils-calculation.sh
case "$2" in
usage )
root_size="$(mounted_drives | \grep '\/$' | awk '{print $3}')"
root_used="$(mounted_drives | \grep '\/$' | awk '{print $4}')"
(( root_used > 0 )) && root_used="$(float_pad "${root_used}*100/${root_size}" 1 1)"
root_geater="$(compare_floats "$root_used" '>' "$threshhold")"
[ "$root_geater" == 'true' ] && root_used="<span color=\"${gruvbox_red}\">${root_used}</span>"
home_size="$(mounted_drives | \grep '\/home$' | awk '{print $3}')"
home_used="$(mounted_drives | \grep '\/home$' | awk '{print $4}')"
(( home_used > 0 )) && home_used="$(float_pad "${home_used}*100/${home_size}" 1 1)"
home_greater="$(compare_floats "$home_used" '>' "$threshhold")"
[ "$home_greater" == 'true' ] && home_used="<span color=\"${gruvbox_red}\">${home_used}</span>"
swap_size="$(swapon --summary | \grep -i 'partition' | awk '{print $3}')"
swap_used="$(swapon --summary | \grep -i 'partition' | awk '{print $4}')"
(( swap_used > 0 )) && swap_used="$(float_pad "${swap_used}*100/${swap_size}" 1 1)"
swap_geater="$(compare_floats "$swap_used" '>' "$threshhold")"
[ "$swap_geater" == 'true' ] && swap_used="<span color=\"${gruvbox_red}\">${swap_used}</span>"
hdd_temp="$(sudo hddtemp /dev/sda --numeric)"
hdd_temp_geater="$(compare_floats "$hdd_temp" '>' "$threshhold")"
[ "$hdd_temp_geater" == 'true' ] && hdd_temp="<span color=\"${gruvbox_red}\">${hdd_temp}</span>"
set_widget 'harddisk' 'markup' "${root_used} ${home_used} ${swap_used} ${hdd_temp}°" ;;
esac ;;
status )
~/main/scripts/status.py ;;
firewall )
function update_variables {
source ~/main/scripts/utils-fir-blu-batt.sh
}
update_variables
case "$2" in
turn_on )
sudo ufw enable ;;
turn_off )
sudo ufw disable ;;
status )
msgn "$(sudo ufw status)" ;;
esac
update_variables
case "$firewall_status" in
active )
set_widget 'firewall' 'markup' 'FI' ;;
* )
set_widget 'firewall' 'markup' 'FI:OF' ;;
esac ;;
bluetooth )
function update_variables {
source ~/main/scripts/utils-fir-blu-batt.sh
}
update_variables
case "$2" in
turn_on )
sudo rfkill unblock bluetooth ;;
turn_off )
sudo rfkill block bluetooth ;;
esac
update_variables
echo $bluetooth_status
case "$bluetooth_status" in
yes )
set_widget 'bluetooth' 'markup' 'BL' ;;
* )
set_widget 'bluetooth' 'markup' 'BL:ON' ;;
esac ;;
ymail )
~/main/scripts/e-mail.py 'ymail' ;;
gmail )
sleep 5 ## only to prevent probable collision with ymail
~/main/scripts/e-mail.py 'gmail' ;;
clipboard )
function check_status {
if_on="$(pgrep 'greenclip')"
}
check_status
case "$2" in
start )
if [ "$if_on" ]; then
msgn "<span color=\"${gruvbox_orange}\">greenclip</span> already on"
else
greenclip daemon &
msgn "<span color=\"${gruvbox_orange}\">greenclip</span> started"
fi ;;
stop )
pkill greenclip
msgn "<span color=\"${gruvbox_orange}\">greenclip</span> stopped" ;;
esac
[ "$if_on" ] && clipboard_text='CL' || clipboard_text="CL:OF"
set_widget 'clipboard' 'markup' "$clipboard_text" ;;
established )
## we can add sudo in this case to get instances other than the user-related ones:
## -i looks for listing ports, -P inhibits the conversion of port numbers to port names for network files, -n does not use DNS name (https://www.cyberciti.biz/faq/how-to-check-open-ports-in-linux-using-the-cli/)
estab="$(sudo lsof -i -P -n | \grep 'ESTABLISHED' | awk '{print $1}' | sort --unique)"
estab_count="$(wc -l < <(printf '%s\n' "${estab:?'NONE'}"))"
## JUMP_1 --,--> expansion structure from https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
## '--> throws non-skippable error when estab nat available
(( estab_count > 0 )) && estab_text="ES:${estab_count}" || estab_text='ES'
set_widget 'established' 'markup' "$estab_text"
case "$2" in
message )
(( estab_count > 0 )) && message_text="$(printf "<span color=\"%s\">Established</span>\n%s\n" "$gruvbox_orange" "$estab")" || message_text='No established connections'
msgn "$message_text" ;;
esac ;;
open_ports )
## https://www.cyberciti.biz/faq/how-to-check-open-ports-in-linux-using-the-cli/
## -i looks for listing ports
## -P inhibits the conversion of port numbers to port names for network files
## -n does not use DNS name
##
open_ports="$(sudo lsof -i -P -n | \grep 'LISTEN')"
## | \grep -v -E '127.0.0.1:8001|mysql|redis|code' (127.0.0.1:8001 is project1 project)
open_ports_count="$(wc -l < <(printf '%s\n' "${open_ports:?'NONE'}"))"
## JUMP_1 --,--> expansion structure from https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
## '--> throws non-skippable error when open_ports nat available
(( open_ports_count > 0 )) && open_ports_text="OP:${open_ports_count}" || open_ports_text='OP'
set_widget 'open_ports' 'markup' "$open_ports_text"
case "$2" in
message )
(( open_ports_count > 0 )) && message_text="$(printf "<span color=\"%s\">Open ports</span>\n%s\n" "$gruvbox_orange" "$open_ports")" || message_text='No open ports'
msgn "$message_text" ;;
esac ;;
tor )
case "$2" in
start )
sudo systemctl start tor && message_suffix='started' || message_suffix='start failed'
msgn "<span color=\"${gruvbox_orange}\">tor</span> ${message_suffix}" ;;
stop )
sudo systemctl stop tor && message_suffix='stopped' || message_suffix='stop failed'
msgn "<span color=\"${gruvbox_orange}\">tor</span> ${message_suffix}" ;;
restart )
sudo systemctl restart tor && message_suffix='restarted' || message_suffix='restart failed'
msgn "<span color=\"${gruvbox_orange}\">tor</span> ${message_suffix}" ;;
is-tor )
~/main/scripts/is-tor.py 'msg' ;;
esac
tor_status="$(pgrep 'tor')"
[ "$tor_status" ] && tor_status_text='TO:ON' || tor_status_text='TO'
set_widget 'tor' 'markup' "$tor_status_text" ;;
git )
source ~/main/scripts/utils-git.sh
set_widget 'git' 'markup' "$refresh_icon"
modified_repos=''
## FIXME
## can't use FZF_DEFAULT_COMMAND and FZF_ALT_C_COMMAND_GIT
## because they are apparently not accessible to this option
## synced with path flags for FZF_DEFAULT_COMMAND in ~/.bashrc
path_flags_1='\
! -path "*.git/*" \
! -path "*.cache/*" \
! -path "*venv*/*" \
! -path "*downloads/*" \
! -path "*kaddy/*" \
! -path "*trash/*" \
! -path "*lost+found/*" \
2>/dev/null'
## synced with path flags for FZF_ALT_C_COMMAND_GIT in ~/.bashrc
path_flags_2='\
! -path "*.config/*" \
! -path "*.vim/*" \
! -path "*go/*" \
! -path "*trash/*" \
! -path "*lost+found/*" \
-iname ".git" | sed "s#/\.git##" | sort'
find_cmd="find ~/main/ -type d $path_flags_1 $path_flags_2"
readarray -t all_repos < <(eval "$find_cmd")
for repo in "${all_repos[@]}"; {
status_count="$(wc -l < <(git_status "$repo"))"
(( status_count > 0 )) && {
base="${repo##*/}"
modified_repos+="${base::2}${status_count},"
}
}
## %,* is to remove the trailing , and everything coming after that (only one % mean non-greedy)
[ "$modified_repos" ] && git_text="GI:${modified_repos%,*}" || git_text='GI'
set_widget 'git' 'markup' "$git_text" ;;
ping )
ping_failed_file=/tmp/ping_failed
declare -i tried=1
if [ -f "$ping_failed_file" ]; then
## exceptionally colored refresh_icon
set_widget 'ping' 'markup' "<span color=\"${gruvbox_red}\">${refresh_icon}</span>"
fi
while (( tried <= 5 )); do
## -W is timeout (time to wait for a response, in seconds)
ping 8.8.8.8 -c 1 -W 2 &>/dev/null
exit_code="$?"
## NOTE used [ "$var" -eq 0 ] instead of (( var == 0 )) because
## (( var == 0 )) is stupid (i.e. it returns true even if var does not exist)
if [ "$exit_code" -eq 0 ]; then
stts=''
if [ -f "$ping_failed_file" ]; then
# text="$(printf 'Connected back at\n%s\n' "$(jdate '+%Y-%m-%d %H:%M:%S')")"
# msgc "$text"
rm "$ping_failed_file"
fi
break
else
stts="<span color=\"${gruvbox_red}\">PI</span>" ## ◖◗
printf '%s\n' "$(get_datetime 'jymdhms')" > "$ping_failed_file"
fi
(( tried++ ))
sleep .1
done
set_widget 'ping' 'markup' "$stts" ;;
audacious )
source ~/main/scripts/utils-calculation.sh
source ~/main/scripts/utils-duration.sh
function update_variables {
source ~/main/scripts/utils-audacious.sh
}
update_variables
if [ "$album" == 'speech' ]; then
audtool --equalizer-set 0 0 0 0 0 0 0 0 0 0 0
else
audtool --equalizer-set -2.10 -10.86 4.00 5.14 2.10 -0.19 -2.10 -2.86 -4.00 -4.00 -4.00
fi
case "$2" in
play_pause )
audtool --playback-playpause ;; ## OR audacious -t
pause )
[ "$play_status" == 'playing' ] && audtool --playback-pause ;;
resume )
[ "$album" == 'speech' ] || exit
## get last value
csols_last="$(redis-cli GET 'awesome_widget__csols')" ## 240
[ "$csols_last" ] || csols_last=0
[ "$csols_last" -gt 0 ] && audtool --playback-seek "$csols_last" ;;
tog_shuff )
audtool --playlist-shuffle-toggle ;;
previous )
audtool --playlist-reverse ;; ## OR audacious -r
next )
audtool --playlist-advance ;; ## OR audacious -f
# forward )
# forward_length=120
# (( remaining_seconds="length_in_seconds - current_position_in_seconds" ))
# if (( remaining_seconds < forward_length )); then
# audtool --playlist-advance
# else
# audtool --playback-seek-relative "+${forward_length}"
# fi ;;
-30 )
audtool --playback-seek-relative -30 ;;
+30 )
audtool --playback-seek-relative +30 ;;
songs )
IFS=$'\n'
readarray -t current_songs < <(audtool --playlist-display)
rofi__title="$1"
rofi__subtitle="$2"
selected_song="$(pipe_to_rofi "${current_songs[@]}")" || exit 37
selected_song_index="$(printf '%s\n' "$selected_song" | awk '{print $1}')"
audtool --playlist-jump "$selected_song_index" ;;
esac
update_variables
if [ "$play_status" == 'stopped' ]; then
text=''
bar_position=0
else
## save csols (currnt song output length seconds) if speech
play_status_regex='^(playing|paused)$'
[ "$album" == 'speech' ] && [[ "$play_status" =~ $play_status_regex ]] && {
## save for our next read
redis-cli SET 'awesome_widget__csols' "$current_position_in_seconds" || msgn 'ERROR saving current_position_in_seconds'
}
[ "$play_status" == 'playing' ] || paused_text='PAUSED '
preamp_is_zero="$(compare_floats "$preamp" '=' 0)"
[ "$preamp_is_zero" == 'false' ] && equalizer='EQ '
[ "$shuffle_status" == 'on' ] && shuffle_text='SH '
order="${position_in_playlist}/${playlist_length}" ## 1/5
[ "$length" ] && timestamp="${current_position}/${length}" || timestamp='0:00/0:00' ## 2:24/18:54
(( bar_position > 99 )) && bar_position=1 || bar_position=0.${bar_position}
left="$(convert_second "$left_in_seconds")" ## 01:05:16
left="$(shorten_duration "$left")" ## 1:05:16
paused_text="<span color=\"${gruvbox_yellow_d}\">${paused_text}</span>"
equalizer="<span color=\"${gruvbox_aqua}\">${equalizer}</span>"
shuffle_text="<span color=\"${gruvbox_purple}\">${shuffle_text}</span>"
##
timestamp="<span color=\"${gruvbox_blue}\">${timestamp}</span>"
title="<span color=\"${gruvbox_blue}\">${title}</span>"
artist="<span color=\"${gruvbox_blue}\">${artist}</span>"
text="${paused_text}${equalizer}${shuffle_text}${order} ${timestamp} -${left} ${title} ${album} ${artist}"
fi
set_widget 'audacious' 'markup' "$text"
## set_widget doesn't work properly for audacious_bar
awesome-client "audacious_bar.value = ${bar_position}"
awesome-client "audacious_bar.color = '${gruvbox_blue_d}'"
;;
esac