added quickshell and updated zsh
This commit is contained in:
16
home/hypr/quickshell/scripts/get_battery.sh
Executable file
16
home/hypr/quickshell/scripts/get_battery.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Read battery state
|
||||
bat_path=$(find /sys/class/power_supply/ -name "BAT*" 2>/dev/null | head -n 1)
|
||||
|
||||
if [ -n "$bat_path" ] && [ -d "$bat_path" ]; then
|
||||
capacity=$(cat "$bat_path/capacity" 2>/dev/null || echo 100)
|
||||
status=$(cat "$bat_path/status" 2>/dev/null || echo "Full")
|
||||
is_charging=false
|
||||
if [ "$status" = "Charging" ] || [ "$status" = "Full" ]; then
|
||||
is_charging=true
|
||||
fi
|
||||
echo "{\"present\": true, \"percent\": $capacity, \"status\": \"$status\", \"charging\": $is_charging}"
|
||||
else
|
||||
# Desktop without battery
|
||||
echo "{\"present\": false, \"percent\": 100, \"status\": \"AC\", \"charging\": true}"
|
||||
fi
|
||||
Reference in New Issue
Block a user