dotfiles/.local/bin/print-status

112 lines
3.1 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#! /usr/bin/sh
recordings=$(pgrep wf-recorder | wc -l)
if [ "${recordings}" = "0" ]; then
recs=""
else
recs="📽${recordings}"
fi
if [ "$(cat /sys/class/leds/input0::capslock/brightness)" = "1" ]; then
capslock="𝗔"
else
capslock="𝗮"
fi
if [ "$(cat /sys/class/leds/input0::numlock/brightness)" = "1" ]; then
numlock="🔢"
else
numlock="⮔"
fi
touchpad=$(swaymsg -t get_inputs | jq -r '[.[] | select(.type == "touchpad")][0] | .libinput.send_events')
if [ "${touchpad}" = "enabled" ]; then
touchpad_active="✅"
else
touchpad_active="❎"
fi
today=$(date +'%Y-%m-%d')
now=$(date +'%H:%M:%S')
hour=$(echo "${now}" | cut -d: -f1 -)
minute=$(echo "${now}" | cut -d: -f2 -)
if [ "${minute}" -lt 30 ]; then
case "${hour}" in
"00"|"12") clock_face="🕛";;
"01"|"13") clock_face="🕐";;
"02"|"14") clock_face="🕑";;
"03"|"15") clock_face="🕒";;
"04"|"16") clock_face="🕓";;
"05"|"17") clock_face="🕔";;
"06"|"18") clock_face="🕕";;
"07"|"19") clock_face="🕖";;
"08"|"20") clock_face="🕗";;
"09"|"21") clock_face="🕘";;
"10"|"22") clock_face="🕙";;
"11"|"23") clock_face="🕚";;
esac
else
case "${hour}" in
"00"|"12") clock_face="🕧";;
"01"|"13") clock_face="🕜";;
"02"|"14") clock_face="🕝";;
"03"|"15") clock_face="🕞";;
"04"|"16") clock_face="🕟";;
"05"|"17") clock_face="🕠";;
"06"|"18") clock_face="🕡";;
"07"|"19") clock_face="🕢";;
"08"|"20") clock_face="🕣";;
"09"|"21") clock_face="🕤";;
"10"|"22") clock_face="🕥";;
"11"|"23") clock_face="🕦";;
esac
fi
audio_mute=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
audio_volume=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n 1 | tr -d %)
audio_symbol="❔"
if [ "${audio_mute}" = "yes" ]; then
audio_symbol="🔇"
elif [ "${audio_mute}" = "no" ]; then
if [ "${audio_volume}" = "0" ]; then
audio_symbol="🔈"
elif [ "${audio_volume}" -lt 50 ]; then
audio_symbol="🔉"
else
audio_symbol="🔊"
fi
else
audio_symbol="❔"
fi
mike_mute=$(pactl get-source-mute @DEFAULT_SOURCE@ | awk '{print $2}')
mike_volume=$(pactl get-source-volume @DEFAULT_SOURCE@ | grep -o '[0-9]\+%' | head -n 1 | tr -d %)
mike_symbol="❔"
if [ "${mike_mute}" = "yes" ]; then
mike_symbol="🍌"
elif [ "${mike_mute}" = "no" ]; then
mike_symbol="🎤"
else
mike_symbol="❔"
fi
battery=$(cat /sys/class/power_supply/BAT0/capacity)
battery_state=$(cat /sys/class/power_supply/BAT0/status)
case "${battery_state}" in
"Charging"|"Full"|"Not charging")
battery_symbol="🔌"
;;
"Discharging")
if [ "${battery}" -lt 20 ]; then
battery_symbol="🪫"
else
battery_symbol="🔋"
fi
;;
*)
battery_symbol="❔"
;;
esac
echo "${numlock}${capslock} ${recs} 🕹️${touchpad_active} 📆${today} ${clock_face}${now} ${mike_symbol}${mike_volume}% ${audio_symbol}${audio_volume}% ${battery_symbol}${battery}%"