2

In GNOME 3 the audio change notification looks like this:

Can I get a caps lock or num lock icon like it?

Tim
  • 33,500

1 Answers1

3

To display a notification like the volume one in Gnome 3 you can use gdbus (dbus-send won't work because it can't pass function parameters of type a{sv} (array of dict{string:variant}))

With gdbus the volume notification looks like this:

gdbus call --session --dest 'org.gnome.Shell' --object-path '/org/gnome/Shell' --method 'org.gnome.Shell.ShowOSD' "{'icon': <'audio-volume-high-symbolic'>, 'label': <'Line-Out'>, 'level': <90>}"

So for something like Numlock on notification you'd use:

gdbus call --session --dest 'org.gnome.Shell' --object-path '/org/gnome/Shell' --method 'org.gnome.Shell.ShowOSD' "{'icon': <'input-dialpad-symbolic'>, 'label': <'Numlock On'>}"

Icon names are the names of the icon files from the icon theme in use without the extension. Icons themes are located in /usr/share/icons/ or ~/.icons/. So for the /usr/share/icons/Adwaita/scalable/devices/input-dialpad-symbolic.svg you'd use 'input-dialpad-symbolic'. You can also specify icon by it's full path like '/home/user/.icons/Icon-Theme-Name/devices/symbolic/input-dialpad-symbolic.svg' if it's not in the icon theme in use.

The way I discovered this is by looking at dbus calls by using dbus-monitor. When I lowered the volume it printed this:

method call time=1563905341.664155 sender=:1.34 -> destination=:1.8 serial=149 path=/org/gnome/Shell; interface=org.gnome.Shell; member=ShowOSD
array [
  dict entry(
     string "icon"
     variant             string "audio-volume-high-symbolic"
  )
  dict entry(
     string "label"
     variant             string "Line Out"
  )
  dict entry(
     string "level"
     variant             int32 94
  )
]

destination=:1.8 seems to be the same as org.gnome.Shell so both --dest ':1.8' and --dest 'org.gnome.Shell' work.