#!/bin/bash

# Get current battery level
battery_level=$(cat /sys/class/power_supply/BAT0/capacity)

# Get current charging status
charging_status=$(cat /sys/class/power_supply/BAT0/status)
# Get current power supply type
power_supply_type=$(cat /sys/class/power_supply/ADP1/online)

# Create printable output
if [ "$charging_status" = "Charging" ]; then
    status="󰂄"
else
    # Get battery level in percentage
    if [ "$battery_level" -ge 90 ]; then
        status="󰁹"
    elif [ "$battery_level" -ge 70 ]; then
        status="󰂀"
    elif [ "$battery_level" -ge 50 ]; then
        status="󰁾"
    elif [ "$battery_level" -ge 25 ]; then
        status="󰁻"
    else
        status="󰂃"
    fi
fi

# Print the output
if [ "$power_supply_type" -eq 1 ]; then
    echo "$status $battery_level%"
else
    echo "󰂁 $battery_level%"
fi