38 lines
876 B
Bash
Executable File
38 lines
876 B
Bash
Executable File
#!/bin/sh
|
|
|
|
get_date() {
|
|
date '+%H:%M %a %d/%m/%y'
|
|
}
|
|
|
|
get_battery() {
|
|
BATTERY_PATH="/sys/class/power_supply/BAT0"
|
|
|
|
if [ -f "$BATTERY_PATH/capacity" ]; then
|
|
BAT_PERCENT=$(cat "$BATTERY_PATH/capacity")
|
|
BAT_STATUS=$(cat "$BATTERY_PATH/status")
|
|
|
|
printf "%s%%" "$BAT_PERCENT"
|
|
|
|
if [ "$BAT_STATUS" = "Charging" ] || [ "$BAT_STATUS" = "Unknown" ]; then
|
|
printf "^"
|
|
fi
|
|
else
|
|
printf "NoBat"
|
|
fi
|
|
}
|
|
|
|
get_volume() {
|
|
SINK=$(pactl info | awk -F': ' '/Default Sink/ {print $2}')
|
|
VOLUME=$(pactl get-sink-volume "$SINK" | awk '{print $5}' | head -n 1)
|
|
MUTE_STATUS=$(pactl get-sink-mute "$SINK" | awk '{print $2}')
|
|
|
|
printf "%s" "$VOLUME"
|
|
[ "$MUTE_STATUS" = "yes" ] && printf " (m)"
|
|
}
|
|
|
|
while true; do
|
|
printf "V: %s | %s | B: %s\n" "$(get_volume)" "$(get_date)" "$(get_battery)"
|
|
sleep 1
|
|
done
|
|
|