Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling Gnome Volume using DBus

I'm pretty new to the whole DBus stuff so excuse me if this is trivial, but I was wondering whether, using DBus, it is possible to set the audio volume from the command line.

like image 277
cdecker Avatar asked Sep 05 '25 03:09

cdecker


2 Answers

You can also use:

xdotool key XF86AudioRaiseVolume
xdotool key XF86AudioLowerVolume
xdotool key XF86AudioMute
like image 140
César Izurieta Avatar answered Sep 07 '25 23:09

César Izurieta


This seems to work on GNOME 2.30 in Ubuntu 10.04:

$ dbus-send --session --dest=org.ayatana.indicator.sound /org/ayatana/indicator/sound/service org.ayatana.indicator.sound.SetSinkVolume uint32:40

That sets the volume to 40%. Replace 40 with whatever percentage you want the volume to be.

Conversely, to see what the current volume is:

$ dbus-send --session --print-reply --dest=org.ayatana.indicator.sound /org/ayatana/indicator/sound/service org.ayatana.indicator.sound.GetSinkVolume
method return sender=:1.54 -> dest=:1.2228 reply_serial=2
   double 39.9994

(Yes, you set the volume as a uint32, but get it as a double. I don't get it either.)

Given that Ayatana seems to be a Ubuntu project, I don't know how portable this is to other distros.

like image 39
Paul Kuliniewicz Avatar answered Sep 08 '25 00:09

Paul Kuliniewicz