mirror of
https://github.com/dzaczek/Uconsole-i3.git
synced 2025-12-07 20:39:39 +00:00
initial commit
This commit is contained in:
commit
81b9fd515f
7 changed files with 789 additions and 0 deletions
28
scripts/rpibat.sh
Executable file
28
scripts/rpibat.sh
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Define the path to the uevent file
|
||||
UEVENT_FILE="/sys/class/power_supply/axp20x-battery/uevent"
|
||||
|
||||
# Check if the uevent file exists
|
||||
if [ ! -f "$UEVENT_FILE" ]; then
|
||||
echo "Battery info not available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract battery status and capacity from the uevent file
|
||||
BATTERY_STATUS=$(grep -E "POWER_SUPPLY_STATUS" "$UEVENT_FILE" | cut -d'=' -f2)
|
||||
BATTERY_CAPACITY=$(grep -E "POWER_SUPPLY_CAPACITY" "$UEVENT_FILE" | cut -d'=' -f2)
|
||||
|
||||
# Define font-awesome icons
|
||||
ICON_CHARGING="\uf1e6" # plug icon
|
||||
ICON_DISCHARGING="\uf242" # battery icon
|
||||
|
||||
# Check the battery status and output the appropriate icon and capacity
|
||||
if [ "$BATTERY_STATUS" == "Charging" ]; then
|
||||
echo -e "$ICON_CHARGING $BATTERY_CAPACITY%"
|
||||
elif [ "$BATTERY_STATUS" == "Discharging" ]; then
|
||||
echo -e "$ICON_DISCHARGING $BATTERY_CAPACITY%"
|
||||
else
|
||||
echo "Battery: $BATTERY_CAPACITY% | $BATTERY_STATUS"
|
||||
fi
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue