1
我想要一個從systemd服務啓動的python腳本來輸出音頻。systemd服務音頻輸出
我有一個從模板啓動systemd服務的udev規則。模板然後開始一個python腳本有兩個參數(--device和設備路徑)
multiupload @。服務文件:
[Unit]
Description=Mutiupload start service routine
[Service]
Type=oneshot
ExecStart=/path/to/script.py --device %I
[Install]
WantedBy=multi-user.target
在Python腳本我叫任CVLC,mpg123的或ffplay與音頻文件輸出音頻:
# cvlc does not like to be run as root
#audio_args = ["cvlc", "--play-and-exit", "/dir/to/audio/file"]
#mpg123 shits its pants when doing this
#audio_args = ["mpg123", "/dir/to/audio/file"]
#ffplay blacks out my screen? also no output
#audio_args = ["ffplay", "-autoexit", "/dir/to/audio/file"]
subprocess.call(audio_args)
與登錄會話,但是當通過systemd服務,稱爲不輸出音頻從終端中執行時,所有這些工作的很好。
我可以從我的python腳本輸出任何方式,由systemd服務調用?或者這是不可能的(系統服務不應該以這種方式與用戶會話交互?)?
也許Mopidy會的工作,但我想用盡可能少的部件儘可能...
感謝所有的想法!