Skip to content

Instantly share code, notes, and snippets.

@SymphonySimper
Last active April 21, 2025 08:11
Show Gist options
  • Save SymphonySimper/b38b767b23d36ad64ac5d49c591b5628 to your computer and use it in GitHub Desktop.
Save SymphonySimper/b38b767b23d36ad64ac5d49c591b5628 to your computer and use it in GitHub Desktop.
Slightly modified the generated output from my dotfiles
#!/usr/bin/env bash
time_date_string="$(date '+%H:%M;%d/%m/%Y')"
IFS=";"
read -ra time_date <<<"$time_date_string"
unset IFS
network_status=$(nmcli -p -g type connection show --active | head -n1 | cut -d '-' -f3)
network_title_style="normal"
network="${network_status^}"
case "$network_status" in
ethernet) network_color="#40a02b" ;;
wireless) network_color="#df8e1d" ;;
*)
network="Disconnected"
network_title_style="bold"
network_color="#d20f39"
;;
esac
battery_status=$(</sys/class/power_supply/BAT0/status)
battery_capacity=$(</sys/class/power_supply/BAT0/capacity)
battery_remaining_time=$(acpi -r | cut -d ' ' -f5)
battery_title_style="normal"
case "$battery_status" in
'Charging') battery_status_color="#40a02b" ;;
'Discharging') battery_status_color="#e64553" ;;
esac
if [[ $battery_capacity -gt 80 ]]; then
battery_capacity_color="#e64553"
elif [[ $battery_capacity -gt 50 ]]; then
battery_capacity_color="#40a02b"
elif [[ $battery_capacity -gt 20 ]]; then
battery_capacity_color="#df8e1d"
battery_title_style="bold"
else
battery_capacity_color="#d20f39"
battery_title_style="bold"
fi
power_profile_status=$(powerprofilesctl get)
power_profile_title_style="normal"
if [ "$power_profile_status" == "power-saver" ]; then
power_profile_color="#40a02b"
else
power_profile_color="#d20f39"
power_profile_title_style="bold"
fi
refresh_rate_status=$(hyprctl monitors -j | jq '.[0].refreshRate' | cut -d '.' -f1)
refresh_rate_title_style="normal"
if [[ $refresh_rate_status -eq 48 ]]; then
refresh_rate_color="#40a02b"
else
refresh_rate_color="#d20f39"
refresh_rate_title_style="bold"
fi
brightness_status=$(brightnessctl -m i | cut -d ',' -f4 | tr -d '%')
brightness_title_style="normal"
if [[ $brightness_status -gt 80 ]]; then
brightness_color="#d20f39"
brightness_title_style="bold"
elif [[ $brightness_status -gt 50 ]]; then
brightness_color="#e64553"
brightness_title_style="bold"
elif [[ $brightness_status -gt 20 ]]; then
brightness_color="#df8e1d"
else
brightness_color="#40a02b"
fi
caffeine_inactive=$(systemctl status --user hypridle | grep -q 'inactive' && echo 0 || echo 1)
caffeine_title_style="normal"
if [[ $caffeine_inactive -eq 1 ]]; then
caffeine_status="DISABLED"
caffeine_color="#9ca0b0"
else
caffeine_status="ENABLED"
caffeine_title_style="bold"
caffeine_color="#fe640b"
fi
sink="@DEFAULT_AUDIO_SINK@"
source='@DEFAULT_AUDIO_SOURCE@'
function get_mute() {
wpctl status $source | grep -qi -E "$1.*muted" && echo 0 || echo 1
}
function get_volume() {
volume=$(wpctl get-volume $sink | cut -d ' ' -f2)
echo "$volume * 100 / 1" | bc
}
audio_mute=$(get_mute "stereo")
audio_volume=$(get_volume)
audio_title_style="normal"
if [[ $audio_mute -eq 0 ]]; then
audio="MUTED"
audio_title_style="bold"
audio_color="#d20f39"
else
audio="$audio_volume"
if [[ $audio_volume -gt 80 ]]; then
audio_color="#d20f39"
audio_title_style="bold"
elif [[ $audio_volume -gt 50 ]]; then
audio_color="#e64553"
audio_title_style="bold"
elif [[ $audio_volume -gt 20 ]]; then
audio_color="#df8e1d"
else
audio_color="#40a02b"
fi
fi
mic_mute=$(get_mute "mic")
mic_title_style="normal"
if [[ $mic_mute -eq 0 ]]; then
mic="MUTED"
mic_color="#40a02b"
else
mic="UNMUTED"
mic_title_style="bold"
mic_color="#d20f39"
fi
notify-send -h string:x-dunst-stack-tag:notifybar -u normal "Info" "<span><span foreground='#4c4f69' font_weight='normal'>Date</span>: <span foreground='#4c4f69' font_weight='bold'>${time_date[0]}</span> <span foreground='#4c4f69' font_weight='normal'>${time_date[1]}</span></span>
<span><span foreground='#4c4f69' font_weight='$network_title_style'>Network</span>: <span foreground='$network_color' font_weight='normal'>$network</span></span>
<span><span foreground='#4c4f69' font_weight='$battery_title_style'>Battery</span>: <span foreground='$battery_capacity_color' font_weight='normal'>${battery_capacity}%</span> (<span foreground='$battery_status_color' font_weight='normal'>$battery_remaining_time</span>)</span>
<span><span foreground='#4c4f69' font_weight='$power_profile_title_style'>Power Profile</span>: <span foreground='$power_profile_color' font_weight='normal'>${power_profile_status}</span></span>
<span><span foreground='#4c4f69' font_weight='$refresh_rate_title_style'>Refresh Rate</span>: <span foreground='$refresh_rate_color' font_weight='normal'>${refresh_rate_status}Hz</span></span>
<span><span foreground='#4c4f69' font_weight='$brightness_title_style'>Brightness</span>: <span foreground='$brightness_color' font_weight='normal'>${brightness_status}%</span></span>
<span><span foreground='#4c4f69' font_weight='$caffeine_title_style'>Caffeine</span>: <span foreground='$caffeine_color' font_weight='normal'>$caffeine_status</span></span>
<span><span foreground='#4c4f69' font_weight='$audio_title_style'>Audio</span>: <span foreground='$audio_color' font_weight='normal'>${audio}%</span></span>
<span><span foreground='#4c4f69' font_weight='$mic_title_style'>Mic</span>: <span foreground='$mic_color' font_weight='normal'>$mic</span></span>
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment