Custom script instead of battery widget.
This commit is contained in:
parent
99e8ee4eb7
commit
7e575ee9f5
2 changed files with 21 additions and 6 deletions
18
_desktop/_scripts/sb-battery
Executable file
18
_desktop/_scripts/sb-battery
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
icon='\uf241 '
|
||||||
|
for battery in /sys/class/power_supply/BAT?*; do
|
||||||
|
# If non-first battery, print a space separator.
|
||||||
|
[ -n "${capacity+x}" ] && printf " "
|
||||||
|
# Sets up the status and capacity
|
||||||
|
case "$(cat "$battery/status")" in
|
||||||
|
"Full") status="\uf102" ;;
|
||||||
|
"Discharging") status="\uf078" ;;
|
||||||
|
"Charging") status="\uf077" ;;
|
||||||
|
"Not charging") status="\uf444" ;;
|
||||||
|
"Unknown") status="\uf128" ;;
|
||||||
|
esac
|
||||||
|
capacity=$(cat "$battery/capacity")
|
||||||
|
# Will make a warn variable if discharging and low
|
||||||
|
[ "$capacity" -le 20 ] && printf "$icon <span foreground='#ffffff' background='#770000'>${status} ${capacity}%%</span>" || printf "$icon ${status} ${capacity}%%"
|
||||||
|
done && exit 0
|
|
@ -136,12 +136,9 @@ screens = [
|
||||||
update_interval=0.2,
|
update_interval=0.2,
|
||||||
func=lambda: subprocess.check_output("sb-network").decode(),
|
func=lambda: subprocess.check_output("sb-network").decode(),
|
||||||
),
|
),
|
||||||
widget.Battery(
|
widget.GenPollText(
|
||||||
format='\uf241 {char} {percent:2.0%}',
|
update_interval=0.2,
|
||||||
charge_char="\uf077",
|
func=lambda: subprocess.check_output("sb-battery").decode(),
|
||||||
discharge_char="\uf078",
|
|
||||||
full_char="\uf102",
|
|
||||||
unknown_char="\uf444",
|
|
||||||
),
|
),
|
||||||
widget.Clock(
|
widget.Clock(
|
||||||
format='\uf073 [%d] %I:%M:%S %p'
|
format='\uf073 [%d] %I:%M:%S %p'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue