From 1cace80e4832a5d250ef4b7ccd687996563fb01b Mon Sep 17 00:00:00 2001 From: venomade Date: Thu, 27 Feb 2025 17:06:42 +0000 Subject: Add old dotfiles --- nixos/scripts/get-battery | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 nixos/scripts/get-battery (limited to 'nixos/scripts/get-battery') diff --git a/nixos/scripts/get-battery b/nixos/scripts/get-battery new file mode 100755 index 0000000..fff6d19 --- /dev/null +++ b/nixos/scripts/get-battery @@ -0,0 +1,39 @@ +#!/bin/sh + +BATTERY_PATH="/sys/class/power_supply/BAT0" + +# Check if the battery is present +if [ -d "$BATTERY_PATH" ]; then + # Get battery status (Charging, Discharging, Full, etc.) + status=$(cat "$BATTERY_PATH/status") + + # Get battery percentage + capacity=$(cat "$BATTERY_PATH/capacity") + + # Set default icon and color + icon="" + color="" + + # Determine icon based on battery status + if [ "$status" == "Charging" ]; then + icon="󱟦" # Charging icon + else + icon="󱟤" # Discharging icon + fi + + # Determine color based on battery percentage + if [ "$capacity" -le 20 ]; then + color="" # Red + elif [ "$capacity" -le 50 ]; then + color="" # Orange + elif [ "$capacity" -le 79 ]; then + color="" # Yellow + else + color="" # Green + fi + + # Display battery information with icon and color + echo "$color$icon $capacity%" +else + echo "Battery not found." +fi -- cgit 1.4.1-2-gfad0