mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2025-06-29 20:20:41 +00:00
Add lemonbar implementation for bspwm
This commit is contained in:
parent
a916b15d11
commit
2ef59a7720
7 changed files with 472 additions and 0 deletions
33
home/.config/lemonbar/applet-battery
Executable file
33
home/.config/lemonbar/applet-battery
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
PANEL_FIFO="$1"
|
||||
PREFIX="$2"
|
||||
DELAY="$3"
|
||||
readarray -td";" ICONS <<< "$4"; declare -p ICONS >/dev/null
|
||||
BATTERY_NAME="${5-BAT0}"
|
||||
|
||||
exec 5>"$PANEL_FIFO"
|
||||
|
||||
main() {
|
||||
local capacity="$(cat /sys/class/power_supply/$BATTERY_NAME/capacity)"
|
||||
local icon=""
|
||||
if [ "$capacity" -lt 20 ]; then
|
||||
icon="${ICONS[0]}"
|
||||
elif [ "$capacity" -lt 40 ]; then
|
||||
icon="${ICONS[1]}"
|
||||
elif [ "$capacity" -lt 60 ]; then
|
||||
icon="${ICONS[2]}"
|
||||
elif [ "$capacity" -lt 80 ]; then
|
||||
icon="${ICONS[3]}"
|
||||
else
|
||||
icon="${ICONS[4]}"
|
||||
fi
|
||||
|
||||
REPLY="$icon $capacity%"
|
||||
}
|
||||
|
||||
while :; do
|
||||
main
|
||||
echo "$PREFIX $REPLY" >&5
|
||||
sleep "$DELAY"
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue