Se si necessita di un programma che regoli il volume di Pluseaudio da riga di comando, è possibile usare il seguente script:
#!/usr/bin/ruby
def current
c = IO::popen("pacmd \"list-sinks\" | grep volume | head -1").readlines[0]
return c.split(" ").last.sub("%", "").strip.to_i
end
def max
c = IO::popen("pacmd \"list-sinks\" | grep \"volume steps\" | head -1").readlines[0]
return c.split(" ").last.strip.to_i - 1
end
def index
c = IO::popen("pacmd \"list-sinks\" | grep index | head -1").readlines[0]
return c.split(" ").last.strip.to_i
end
def set(v)
IO::popen("pacmd \"set-sink-volume #{index} #{v}\"").readlines
end
def muted
c = IO::popen("pacmd \"list-sinks\" | grep muted | head -1").readlines[0]
return c.split(" ").last.strip == "yes"
end
def toggle
t = 1
if ( muted )
t = 0
end
IO::popen("pacmd \"set-sink-mute #{index} #{t}\"").readlines
end
interval = 5
if ( ARGV.size == 0 )
puts current
elsif (ARGV[0] == "?" )
puts muted
elsif ( ARGV[0] == "+" )
set([current + interval, 100].min * (max / 100.0).round)
elsif ( ARGV[0] == "-" )
set([current - interval, 0].max * (max / 100.0).round)
elsif ( ARGV[0] == "!" )
toggle
end
Con i poteri di root, incollarlo dentro un file /usr/bin/pavol e renderlo eseguibile con:
sudo chmod +x /usr/bin/pavol
I requisiti di questo script sono l’installazione di ruby:
sudo aptitude install ruby
mentre per l’utilizzo si rispecchia la seguente sintassi:
pavol +
aumenta il volume
pavol -
diminuisce il volume
pavol !
muta
Fonte: [lm]azy