使用DBus控制Gnome卷

cde*_*ker 3 command-line gnome dbus command-line-interface

我对整个DBus的东西都很陌生,所以请原谅我,如果这是微不足道的,但我想知道,使用DBus,是否可以从命令行设置音量.

Pau*_*icz 5

这似乎适用于Ubuntu 10.04中的GNOME 2.30:

$ dbus-send --session --dest=org.ayatana.indicator.sound /org/ayatana/indicator/sound/service org.ayatana.indicator.sound.SetSinkVolume uint32:40
Run Code Online (Sandbox Code Playgroud)

这将音量设置为40%.将40替换为您想要的音量百分比.

相反,要查看当前的数量是多少:

$ 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
Run Code Online (Sandbox Code Playgroud)

(是的,你将音量设置为uint32,但是将其设置为double.我也不会得到它.)

鉴于Ayatana似乎是一个Ubuntu项目,我不知道这对其他发行版有多便携.