Add notifications block

This commit is contained in:
Santiago Lo Coco 2021-10-25 14:12:19 -03:00
parent 126626897b
commit 186cb22b81
4 changed files with 55 additions and 19 deletions

22
blocks.def/notifications.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
ICONmute="🔕"
ICONnotmute="🔔"
checkIfNotificationsArePaused() {
ISPAUSED=$(dunstctl is-paused)
if echo $ISPAUSED | grep -q "true"; then
ICON=$ICONmute
else
ICON=$ICONnotmute
fi
}
checkIfNotificationsArePaused
getIcon() {
printf "$ICON"
}
getIcon

View File

@ -0,0 +1,17 @@
#!/bin/sh
toggleNotifications() {
dunstctl set-paused toggle
}
refreshNotificationsBlock() {
sigdwmblocks 6
}
case "$1" in
#1) toggleNotifications ;;
2) toggleNotifications ;;
#3) pactl set-sink-mute @DEFAULT_SINK@ toggle;;
esac
refreshNotificationsBlock

View File

@ -6,6 +6,8 @@ ICONhigh="🔊"
ICONmute="🔇"
ICONspeakermute="🔕"
ICONspeaker="🔔"
ICONheadphone="🎧"
#ICONspeaker="📢"
#SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1
SINKHDMI=alsa_output.pci-0000_01_00.1.hdmi-stereo
@ -28,29 +30,23 @@ MUTE=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{printf $2}')
checkDefaultSink
getIcon() {
#if [ `pulsemixer --get-mute` -eq 1 ]; then
if [ "$MUTE" = "yes" ]; then
#ICON=$ICONmute
if [ "$SINK" = "$SINKHDMI" ]; then
ICON=$ICONspeakermute
elif [ "$SINK" = "$SINKANALOG" ]; then
ICON=$ICONmute
fi
ICON=$ICONmute
else
if [ "$SINK" = "$SINKHDMI" ]; then
ICON=$ICONspeaker
elif [ "$SINK" = "$SINKANALOG" ]; then
if [ "$VOLUME" -gt "50" ]; then
ICON=$ICONhigh
elif [ "$VOLUME" -gt "20" ]; then
ICON=$ICONmid
else
ICON=$ICONlow
fi
if [ "$VOLUME" -gt "50" ]; then
ICON=$ICONhigh
elif [ "$VOLUME" -gt "20" ]; then
ICON=$ICONmid
else
ICON=$ICONlow
fi
fi
printf "$ICON %s" "$VOLUME%"
if [ "$SINK" = "$SINKHDMI" ]; then
printf "$ICON %s" "$VOLUME%"
elif [ "$SINK" = "$SINKANALOG" ]; then
printf "$ICON %s" "$VOLUME% $ICONheadphone"
fi
}
getIcon

View File

@ -46,6 +46,7 @@ static Block blocks[] = {
/* pathu pathc interval signal */
{ PATH("time.sh"), PATH("time_button.sh"), 1, 1},
//{ PATH("weather.sh"), PATH("weather_button.sh"), 900, 5},
{ PATH("notifications.sh"), PATH("notifications_button.sh"), 0, 6},
{ PATH("volume.sh"), PATH("volume_button.sh"), 0, 2},
{ PATH("mail.sh"), PATH("mail_button.sh"), 0, 3},
{ PATH("cpu_temp.sh"), PATH("cpu_temp_button.sh"), 15, 4},