Skip to content

Instantly share code, notes, and snippets.

@cypres
Created January 3, 2021 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cypres/d356c1bfe393f3f97b9b695bf7e82e11 to your computer and use it in GitHub Desktop.
Save cypres/d356c1bfe393f3f97b9b695bf7e82e11 to your computer and use it in GitHub Desktop.
baraction.sh script for spectrwm status bar
#!/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