Skip to content

Instantly share code, notes, and snippets.

@julianorchard
Last active February 16, 2023 21:24
Show Gist options
  • Select an option

  • Save julianorchard/9f2d22a64f0fd8f40d1d98e2e347315d to your computer and use it in GitHub Desktop.

Select an option

Save julianorchard/9f2d22a64f0fd8f40d1d98e2e347315d to your computer and use it in GitHub Desktop.
A useful single line battery status command for use with i3blocks
p=$(cat /sys/class/power_supply/BAT0/capacity); ! grep -q "Dischar" /sys/class/power_supply/BAT0/status && echo " ${p}%" && exit 0 || [ $p -gt 80 ] && echo " ${p}%" && exit 0 || [ $p -gt 60 ] && echo " ${p}%" && exit 0 || [ $p -gt 40 ] && echo " ${p}%" && exit 0 || [ $p -gt 20 ] && echo " ${p}%" && exit 0 || echo " ${p}%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment