Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

My mute notification for Fluxbox and volumeicon

I use fluxbox, with volumeicon-alsa, and notification-daemon. I could use the bog-standard notifications that volumeicon provides, but the little icons in the notification are really small. So I wrote my own.

In ~/.fluxbox/keys, I react to the volume mute button:

#121 :Exec amixer sset Master,0 toggle
121 :Exec /usr/local/bin/audio-toggle.sh

Instead of just toggling the mute with fluxbox, I call my special script at /usr/local/bin/audio-toggle.sh.

#!/bin/sh
# Startdate: 2022-09-12
# For fluxbox
# handle the audio being muted and send cute notification
tmpfile=/run/user/${UID}/audio-toggle-notify-id
AUDIO="muted"
ICON=/usr/share/icons/Adwaita/64x64/status/audio-volume-muted-symbolic.symbolic.png
amixer sset Master,0 toggle 2>&1 | grep -iqE '\[on\]' 2>/dev/null && {
   AUDIO="unmuted"
   ICON=/usr/share/icons/Adwaita/64x64/status/audio-volume-high-symbolic.symbolic.png
}
nid="$( cat "${tmpfile}" 1>/dev/null 2>&1 )"
notify-send --transient --expire-time 2000 ${nid:+--replace-id=${nid} }--icon "${ICON}" "Audio ${AUDIO}" --print-id | tee "${tmpfile}" 1>/dev/null 2>&1

I wanted the size 64 icons so I could see them! Also, I wanted the black icons because my default theme in notification-daemon is apparently the nice, boring gray that hides white icons.

Comments