mirror of
https://github.com/Foltik/dotfiles
synced 2024-12-11 05:52:21 -05:00
38 lines
1.1 KiB
Bash
Executable File
38 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
BATTERY=$(echo "${BLOCK_INSTANCE}" | awk -F ';' '{print $1}')
|
|
OPT=$(echo "${BLOCK_INSTANCE}" | awk -F ';' '{print $2}')
|
|
BATTERY_INFO=$(acpi -b | grep "Battery ${BATTERY}")
|
|
BATTERY_STATE=$(echo "${BATTERY_INFO}" | grep -wo "Full\|Charging\|Discharging")
|
|
BATTERY_POWER=$(echo "${BATTERY_INFO}" | grep -o '[0-9]\+%' | tr -d '%')
|
|
BATTERY_REMAINING=$(acpi -b | grep remaining | awk '{print $5}')
|
|
|
|
URGENT_VALUE=10
|
|
if [[ "${BATTERY_STATE}" = "Charging" ]]; then
|
|
if [[ "${OPT}" = "rem" ]]; then
|
|
echo "${BATTERY_POWER}%+ ${BATTERY_REMAINING}"
|
|
echo "${BATTERY_POWER}%+ ${BATTERY_REMAINING}"
|
|
else
|
|
echo "${BATTERY_POWER}%+"
|
|
echo "${BATTERY_POWER}%+"
|
|
fi
|
|
echo ""
|
|
elif [[ "${BATTERY_STATE}" = "Discharging" ]]; then
|
|
if [[ "${OPT}" = "rem" ]]; then
|
|
echo "${BATTERY_POWER}%- ${BATTERY_REMAINING}"
|
|
echo "${BATTERY_POWER}%- ${BATTERY_REMAINING}"
|
|
else
|
|
echo "${BATTERY_POWER}%-"
|
|
echo "${BATTERY_POWER}%-"
|
|
fi
|
|
echo ""
|
|
else
|
|
echo "${BATTERY_POWER}%"
|
|
echo "${BATTERY_POWER}%"
|
|
echo ""
|
|
fi
|
|
|
|
if [[ "${BATTERY_POWER}" -le "${URGENT_VALUE}" ]]; then
|
|
exit 33
|
|
fi
|