Created
January 3, 2021 23:29
-
-
Save cypres/d356c1bfe393f3f97b9b695bf7e82e11 to your computer and use it in GitHub Desktop.
baraction.sh script for spectrwm status bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# baraction.sh script for spectrwm status bar | |
print_backlight() { | |
if [ -e /sys/class/backlight/intel_backlight/brightness ]; then | |
BL=$(oled-backlight current) | |
echo -n " BL:$BL%" | |
else | |
echo -n " BL:Unknown" | |
fi | |
} | |
print_volume() { | |
VOL=$(pamixer --get-volume-human) | |
MUTED=$(pamixer --get-mute) | |
if [[ "$MUTED" == "true" ]]; then | |
echo -n " V:Muted" | |
else | |
echo -n " V:$VOL" | |
fi | |
} | |
print_battery() { | |
batt=$(cat /sys/class/power_supply/BAT0/capacity) | |
batt_state=$(cat /sys/class/power_supply/BAT0/status | cut -c-1) | |
echo -n " BAT:$batt_state$batt%" | |
} | |
SLEEP_SEC=5 # set bar_delay = 5 in /etc/spectrwm.conf | |
#loops forever outputting a line every SLEEP_SEC secs | |
while :; do | |
print_backlight | |
print_volume | |
print_battery | |
echo "" | |
sleep $SLEEP_SEC | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment