vially / volumectl

Small utility to control the volume from the command line
MIT License
8 stars 3 forks source link

Volume change notification Icon name hardcoded, doesn't work with Adwaita Icon theme #3

Open cvicentiu opened 1 year ago

cvicentiu commented 1 year ago

Problem statement

Currently running Archlinux with Sway. With the Adwaita Icon theme configured for GTK, the sound change notifications don't have the volume icon correctly set. Instead I get the placeholder "missing icon".

More details following my investigation:

The issue is that the notification icon is hardcoded to notification-audio-volume-xxx, see https://github.com/vially/volumectl/blob/29cb6a1a97a76f87c3c48695cb59a00c80dc63a2/notify.go#L50

Unfortunately, Adwaita icon theme (which is probably the most popular amongs default installs with users switching from Gnome) does not have it.

Here is the list of icons that work for Papirus:

$ pwd && find . | grep Papirus.*notification.*audio-volume-
/usr/share/icons
./Papirus/48x48/status/notification-audio-volume-high.svg
./Papirus/48x48/status/notification-audio-volume-low.svg
./Papirus/48x48/status/notification-audio-volume-medium.svg
./Papirus/48x48/status/notification-audio-volume-muted.svg
./Papirus/48x48/status/notification-audio-volume-off.svg

And here is the list of icons for Adwaita:

pwd && find . | grep Adwaita.*notification.*audio-volume-
/usr/share/icons

Here is what Adwaita does have:

$ pwd && find . | grep Adwaita.*audio-volume-
/usr/share/icons
./Adwaita/16x16/status/audio-volume-high-rtl-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-high-symbolic-rtl.symbolic.png
./Adwaita/16x16/status/audio-volume-high-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-low-rtl-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-low-symbolic-rtl.symbolic.png
./Adwaita/16x16/status/audio-volume-low-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-medium-rtl-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-medium-symbolic-rtl.symbolic.png
./Adwaita/16x16/status/audio-volume-medium-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-muted-rtl-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-muted-symbolic-rtl.symbolic.png
./Adwaita/16x16/status/audio-volume-muted-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-overamplified-rtl-symbolic.symbolic.png
./Adwaita/16x16/status/audio-volume-overamplified-symbolic-rtl.symbolic.png
./Adwaita/16x16/status/audio-volume-overamplified-symbolic.symbolic.png
.... # Contents skipped for brevity. There are also scalable SVG versions too.

Workaround

It took me quite some time to track down what the problem was. Switching to Papirus icon theme fixed my issue, but I think volumectl should be made such that it works with Adwaita (and possibly other popular icon themes as well)

Suggestions:

  1. Identify the GTK icon theme before issuing the notification. Then do a best-effort searchf or audio-volume icons.
  2. Allow the user to manually specify the icon to be used within the notification via a volumectl command line argument / environment variable.
  3. Config file where user can specify where the icons can be fetched from.
  4. Expand README to account for this issue.
  5. Allow volumectl to be started with a higher verbosity level, explaining what it does so that users might be able to debug what's happening.

For instance: volumectl up --debug Could output:

LOG: Setting volume up from x -> y`
LOG: Sending notification with following contents: Icon, Message, etc.
cvicentiu commented 1 year ago

Also discovered one can debug notifications via:

$ dbus-monitor --session interface='org.freedesktop.Notifications'

vially commented 1 year ago

This is a great investigation and write-up. Thank you!

I think your suggestions make a lot of sense. I do plan to look closer into it and try to come up with a good solution but unfortunately I don't think I'll be able to do that very soon.