bash pactl暂停特定应用程序

时间:2015-07-17 01:10:53

标签: linux bash audio sh suspend

我编写了以下代码来暂停特定应用程序的音频

spotify > '/home/user/Desktop/temp_spotify.txt' 2>&1 & # store terminal output to text file
while :
do # tail grabs recently updated last line in text file | awk searches for specific word in text and then signals exit to tail
  tail -fn0 --pid=$(pidof awk) '/home/user/Desktop/temp_spotify.txt' | awk '/spotify:ad/ { exit }'
  sleep 5
  pactl suspend-sink 2 1 # supend all audio applications grouped under sink 2
  sleep 25
  pactl suspend-sink 2 0 # resume all audio applications grouped under sink 2
done

但是我无法为pactl指定一个唯一标识符来暂停spotify应用程序。相反,我指定了sink 2,它包含许多应用程序。

如何为特定应用程序暂停音频?

应用程序文本文件中的初始参数

01:06:27.735 I [breakpad.cpp:110                ] Registered Breakpad for product: spotify

01:06:27.738 I [translate.cpp:152               ] Reloading language file
01:06:27.749 I [translate.cpp:152               ] Reloading language file
01:06:27.750 I [breakpad.cpp:269                ] Searching for crashdumps: /home/user/.cache/spotify/*.dmp

Got bus address:  "unix:abstract=/tmp/dbus-6gUEyklNpI,guid=ad6f12cdc093618710fd017755a787fd" 
Connected to accessibility bus at:  "unix:abstract=/tmp/dbus-6gUEyklNpI,guid=ad6f12cdc093618710fd017755a787fd" 
Registered DEC:  true 
01:06:27.937 E [offline_key_store.cpp:77        ] Offline: failed to load key stores, error 7007, path /home/user/.cache/spotify/Users/user-user/offline2
01:06:27.940 E [offline_key_store.cpp:77        ] Offline: failed to load key stores, error 7007, path /home/user/.cache/spotify/Users/user-user/cached

0 个答案:

没有答案