u0xpsec

get_battery.sh

Dec 1st, 2018
389
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/zsh
  2. #
  3. # Author: u0xpsec 2018
  4. #
  5. if [ `upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "state" | cut -d" " -f20 ` = "fully-charged" ];then
  6. echo "──────────────────- < battery charged >"
  7. elif [ `upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "state" | cut -d" " -f20 ` = "discharging" ];then
  8. echo "────────────────- < discharging:" `upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "percentage" | cut -d" " -f15-` ">"
  9. elif [ `upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "state" | cut -d" " -f20 ` = "charging" ];then
  10. echo "────────────────────- < charging:" `upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "percentage" | cut -d" " -f15-` ">"
  11. else
  12. echo "< Unknown State >"
  13. fi
RAW Paste Data