Skip to content

Instantly share code, notes, and snippets.

@marmakoide
Last active January 1, 2021 17:27
Show Gist options
  • Save marmakoide/3dbabfb2b796fd2179ea592d12d78295 to your computer and use it in GitHub Desktop.
Save marmakoide/3dbabfb2b796fd2179ea592d12d78295 to your computer and use it in GitHub Desktop.
Shell script that generates a string describing power supply status, to use with dwmblocks and Font Awesome
#!/bin/sh
is_ac_powered=$(cat /sys/class/power_supply/AC0/online)
batt_capacity=$(cat /sys/class/power_supply/BAT0/capacity)
if [ "$is_ac_powered" -eq 1 ]; then
icon="" #uF1E6
else
if [ "$batt_capacity" -gt 80 ]; then
icon="" #uF240
elif [ "$batt_capacity" -le 80 -a "$batt_capacity" -gt 60 ]; then
icon="" #uF241
elif [ "$batt_capacity" -le 60 -a "$batt_capacity" -gt 40 ]; then
icon="" #uF242
elif [ "$batt_capacity" -le 40 -a "$batt_capacity" -gt 20 ]; then
icon="" #uF243
else
icon="" #uF244
fi
fi
echo $icon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment