Skip to content
Sketch edited this page Oct 12, 2012 · 1 revision
#!/bin/sh
# A very hacky volume script that works in Ubuntu for certain computers.
# 'string "{mute/unmute}"' means the menu icon changed to the {mute/unmute}
# so mute = unmuted, and unmute = muted. Go figure.

dbus-monitor "interface='org.freedesktop.Notifications',path='/org/freedesktop/Notifications'" |
mawk -W interactive '
function printout() {
  if (MUTED == "mute") color="#C03A38"; else color="grey60"
  printf("^fg(%s)%s^i(icons/vol-%s.xbm)^fg()\n", color,
    substr(sprintf("%2s%%",VOL),1,3), MUTED)
}
BEGIN { MUTED="hi" ; VOL="50" ; printout() }
/variant *int32/ {VOL=$3 ; printout() }
/notification-audio-volume-/ {
  if ($2 == "\"notification-audio-volume-muted\"") MUTED="mute"
  else MUTED="hi"
  printout()
}
'
Clone this wiki locally