web-dev-qa-db-ja.com

音量を返すコマンドラインツールubuntu12.04

Pavucontrolの出力ボリューム設定を返すコマンドラインツールはありますか?他の投稿のpythonスクリプトを使用して、このボリュームをsetできますが、現在の設定を確認する方法がわかりません。

助けてくれてありがとう!

1
Leo Simon

うまくいけば、これで始めることができます(専門的な方法はAPIに接続することに注意してください http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/ ):

#!/usr/bin/python
import subprocess
output = subprocess.check_output("pacmd list-sinks".split())
on_active_sink = False
i_want_as_db = False
for index, line in enumerate(output.splitlines()):
  line = line.split()
  if ['*', 'index:'] == line[:2]:
    on_active_sink = True
    continue
  if on_active_sink and 'volume:' == line[0]:
    if not i_want_as_db:
      print line[2]
      break
    else:
      print output.splitlines()[index + 1].split()[1]
      break
2
Joe