blob: 7781e57f4bbf4a91b32d93f7809a155f8545f308 (
plain) (
blame)
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
|
#!/usr/bin/env bash
volume_component() { amixer get Master | awk -F'[][]' '/Left:/ {print $C}' C="$1"; }
mic_component() { amixer get Capture | awk -F'[][]' '/dB/ {print $C}' C="$1" | head -n 1; }
playerctl_icon() {
local playstate="$(~/scripts/music/player.sh get_play_state)";
case "$playstate" in
Paused) echo "" ;;
Playing) echo "" ;;
Stopped) echo "" ;;
*) ;;
esac
}
network_state() {
local status=$((nmcli dev show wlp0s20f3 || echo "") | grep '^GENERAL.STATE:' | sed 's/^GENERAL.STATE:\s*//g');
echo " ${status:0:16}";
}
volume_icon() { volume_component 4 | sed 's/on//; s/off/🔇/'; }
mic_icon() { mic_component 4 | sed 's/on//; s/off/✖/'; }
icon() {
case "$1" in
date) echo "" ;;
battery) echo "" ;;
music) playerctl_icon ;;
volume) volume_icon ;;
brightness) echo "" ;;
network) network_state ;; # | sed 's/\(connected\)//; s/\(connecting.*\)//; s/\(disconnected\)/❌/' ;;
*) ;;
esac
}
date_module() {
echo "$(icon date) $(date +"%A, %e %b - %I:%M %p")";
}
battery_module() {
local capacity=$(cat "/sys/class/power_supply/BAT0/capacity");
echo "$(icon battery) $capacity%";
}
music_module() {
local label=$(~/scripts/music/player.sh get_label);
echo "$(icon music) $label";
}
brightness_module() {
echo "$(icon brightness) $(printf "%.0f%s" "$(xbacklight -get)" "%")"
}
volume_module() {
echo "$(icon volume) $(volume_component 2)";
}
keymode_module() {
echo "$(~/scripts/shotkey.sh mode)";
}
network_module() {
echo "$(icon network)";
}
get_module() {
case "$1" in
date) date_module ;;
battery) battery_module ;;
volume) volume_module ;;
music) music_module ;;
brightness) brightness_module ;;
keymode) keymode_module ;;
network) network_module ;;
esac;
}
padding=" ";
echo "$padding$(get_module $1 || echo "-")$padding";
exit 0;
|