added waybar config for laptop
This commit is contained in:
19
.config/waybar/scripts/airplane_mode.sh
Executable file
19
.config/waybar/scripts/airplane_mode.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
is_blocked_all() { rfkill list | awk '/Soft blocked:/{c++;/yes/&&y++} END{exit !(c>0 && c==y)}'; }
|
||||
print() {
|
||||
if is_blocked_all; then
|
||||
echo '{"text":"✈","class":"on","tooltip":"Airplane mode: ON (click to disable)"}'
|
||||
else
|
||||
echo '{"text":"✈","class":"off","tooltip":"Airplane mode: OFF (click to enable)"}'
|
||||
fi
|
||||
}
|
||||
case "${1:---print}" in
|
||||
--toggle)
|
||||
if is_blocked_all; then rfkill unblock all; else rfkill block all; fi
|
||||
;;
|
||||
--print) : ;;
|
||||
*) echo "Usage: $0 [--toggle|--print]"; exit 1 ;;
|
||||
esac
|
||||
print
|
||||
|
29
.config/waybar/scripts/battery_health.sh
Executable file
29
.config/waybar/scripts/battery_health.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
bat="$(upower -e | grep -m1 BAT || true)"
|
||||
if [ -z "$bat" ]; then
|
||||
echo '{"text":" --","class":"no-battery","tooltip":"No battery found"}'
|
||||
exit 0
|
||||
fi
|
||||
info="$(upower -i "$bat")"
|
||||
full=$(echo "$info" | awk -F: '/energy-full:/{gsub(/[^0-9.]/,"",$2); print $2; exit}')
|
||||
design=$(echo "$info" | awk -F: '/energy-full-design:/{gsub(/[^0-9.]/,"",$2); print $2; exit}')
|
||||
if [ -z "$full" ] || [ -z "$design" ] || [ "$design" = "0" ]; then
|
||||
# Try charge-full fallback
|
||||
full=$(echo "$info" | awk -F: '/charge-full:/{gsub(/[^0-9.]/,"",$2); print $2; exit}')
|
||||
design=$(echo "$info" | awk -F: '/charge-full-design:/{gsub(/[^0-9.]/,"",$2); print $2; exit}')
|
||||
fi
|
||||
wear="--"
|
||||
if [ -n "$full" ] && [ -n "$design" ] && [ "$design" != "0" ]; then
|
||||
health=$(awk -v f="$full" -v d="$design" 'BEGIN{printf "%.0f", (f/d)*100}')
|
||||
wear=$(( 100 - health ))
|
||||
text="❤ ${health}%"
|
||||
else
|
||||
text="❤ --"
|
||||
fi
|
||||
cycles=$(echo "$info" | awk -F: '/cycle count:/{gsub(/[^0-9]/,"",$2); print $2; exit}')
|
||||
vendor=$(echo "$info" | awk -F: '/vendor:/{gsub(/^ +/,"",$2); print $2; exit}')
|
||||
model=$(echo "$info" | awk -F: '/model:/{gsub(/^ +/,"",$2); print $2; exit}')
|
||||
tt="Battery health info\nWear: ${wear}%\nCycles: ${cycles:---}\nVendor: ${vendor:---}\nModel: ${model:---}"
|
||||
printf '{"text":"%s","class":"battery-health","tooltip":"%s"}\n' "$text" "$(echo "$tt" | sed ':a;N;$!ba;s/\n/\\n/g')"
|
||||
|
18
.config/waybar/scripts/bt_toggle.sh
Executable file
18
.config/waybar/scripts/bt_toggle.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
status() { bluetoothctl show 2>/dev/null | awk '/Powered:/ {print tolower($2); exit}'; } # yes/no
|
||||
print() {
|
||||
s="$(status)"; s="${s:-no}"
|
||||
if [ "$s" = "yes" ]; then
|
||||
echo '{"text":"","class":"on","tooltip":"Bluetooth: on (click to toggle)"}'
|
||||
else
|
||||
echo '{"text":"","class":"off","tooltip":"Bluetooth: off (click to toggle)"}'
|
||||
fi
|
||||
}
|
||||
case "${1:---print}" in
|
||||
--toggle) [ "$(status)" = "yes" ] && bluetoothctl power off || bluetoothctl power on ;;
|
||||
--print) : ;;
|
||||
*) echo "Usage: $0 [--toggle|--print]"; exit 1 ;;
|
||||
esac
|
||||
print
|
||||
|
29
.config/waybar/scripts/kbdlight.sh
Executable file
29
.config/waybar/scripts/kbdlight.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
dev() { brightnessctl --list 2>/dev/null | awk '/kbd_backlight/ {print $2; exit}'; }
|
||||
get_vals() {
|
||||
d="$(dev)"; [ -z "$d" ] && return 1
|
||||
cur="$(brightnessctl -d "$d" get)"; max="$(brightnessctl -d "$d" max)"
|
||||
echo "$d;$cur;$max"
|
||||
}
|
||||
print() {
|
||||
if vals="$(get_vals)"; then
|
||||
IFS=';' read -r d cur max <<<"$vals"
|
||||
[ "$max" -gt 0 ] || max=1
|
||||
pct=$(( cur * 100 / max ))
|
||||
# show in steps if small range
|
||||
steps=$(( max>10 ? 10 : max ))
|
||||
step=$(( cur * steps / max ))
|
||||
echo "{\"text\":\"⌨ ${pct}%\",\"class\":\"kbd $step/$steps\",\"tooltip\":\"Keyboard backlight: ${cur}/${max} (${pct}%)\\nScroll to adjust\"}"
|
||||
else
|
||||
echo '{"text":"⌨","class":"kbd none","tooltip":"No keyboard backlight device found"}'
|
||||
fi
|
||||
}
|
||||
case "${1:---print}" in
|
||||
--inc) if vals="$(get_vals)"; then IFS=';' read -r d cur max <<<"$vals"; brightnessctl -d "$d" set +1 >/dev/null; fi ;;
|
||||
--dec) if vals="$(get_vals)"; then IFS=';' read -r d cur max <<<"$vals"; brightnessctl -d "$d" set 1- >/dev/null; fi ;;
|
||||
--print) : ;;
|
||||
*) echo "Usage: $0 [--inc|--dec|--print]"; exit 1 ;;
|
||||
esac
|
||||
print
|
||||
|
18
.config/waybar/scripts/wifi_toggle.sh
Executable file
18
.config/waybar/scripts/wifi_toggle.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
status() { nmcli -t -f WIFI g | awk -F: '{print $1}'; } # enabled/disabled
|
||||
print() {
|
||||
s="$(status)"
|
||||
if [ "$s" = "enabled" ]; then
|
||||
echo '{"text":"","class":"on","tooltip":"Wi-Fi: enabled (click to toggle)"}'
|
||||
else
|
||||
echo '{"text":"","class":"off","tooltip":"Wi-Fi: disabled (click to toggle)"}'
|
||||
fi
|
||||
}
|
||||
case "${1:---print}" in
|
||||
--toggle) [ "$(status)" = "enabled" ] && nmcli radio wifi off || nmcli radio wifi on ;;
|
||||
--print) : ;;
|
||||
*) echo "Usage: $0 [--toggle|--print]"; exit 1 ;;
|
||||
esac
|
||||
print
|
||||
|
Reference in New Issue
Block a user