如何使用Triggerhappy守護程式覆蓋文件

如何使用Triggerhappy守護程式覆蓋文件

我安裝了 Rpi4 和 Volumio 2.729。當按下鍵盤按鈕時,我使用 Triggerhappy 運行 node.js 腳本 - 該腳本將播放相應的互聯網廣播電台:

module.paths.push('/lib/node_modules');
var io=require('socket.io-client');
var socket= io.connect('http://127.0.0.1:3000');

socket.on('connect',function(){
        socket.emit('replaceAndPlay', {"service":"webradio","uri":"http://185.85.28.148:8000"});
});

此外,當同時按下按鈕和“M”鍵時,Triggerhappy 將運行.js 腳本,將當前播放的電台綁定到該按鈕- 它的工作原理是獲取volumio 的狀態並替換.js 腳本中的URI(來自上面的範例)綁定到該按鈕fs.writeFile().

我的問題是,Triggerhappy 無法覆蓋 .js 檔案。當我從終端手動運行此腳本時,它運行良好。

我設法以 root 身份運行 Triggerhappy,但沒有幫助。我怎麼能讓Triggerhappy覆蓋文件,或者有更優雅的解決方案?

編輯:這是輸出sudo systemctl狀態triggerhappy.service -l

● triggerhappy.service - LSB: triggerhappy hotkey daemon
   Loaded: loaded (/etc/init.d/triggerhappy)
   Active: active (running) since Thu 2020-04-16 19:58:25 CEST; 4min 44s ago
  Process: 640 ExecStart=/etc/init.d/triggerhappy start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/triggerhappy.service
           ├─ 698 /usr/sbin/thd --daemon --triggers /etc/triggerhappy/triggers.d/ --socket /var/run/thd.socket --pidfile /var/run/thd.pid --user volumio /dev/input/event*
           ├─2415 /usr/sbin/thd --daemon --triggers /etc/triggerhappy/triggers.d/ --socket /var/run/thd.socket --pidfile /var/run/thd.pid --user volumio /dev/input/event*
           ├─2416 sh -c node /home/volumio/node-stream/play_uri_1-node.js
           ├─2417 node /home/volumio/node-stream/play_uri_1-node.js
           ├─2636 /usr/sbin/thd --daemon --triggers /etc/triggerhappy/triggers.d/ --socket /var/run/thd.socket --pidfile /var/run/thd.pid --user volumio /dev/input/event*
           ├─2637 sh -c node /home/volumio/node-stream/play_uri_2-node.js
           └─2638 node /home/volumio/node-stream/play_uri_2-node.js

沒有關於 memory.js 的條目,該腳本是在 play_uri_x-node.js 中寫入的腳本

答案1

預設情況下triggerhappy應該運行為nobody.一種解決方法是nobody透過編輯 sudo 檔案授予調用特定命令的權限。但不必使用 root,如果您的普通用戶可以運行該腳本就足夠了。

在您的triggerhappy 設定中,驗證您是否具有腳本的完全限定路徑。

最後但並非最不重要的一點是,檢查您的日誌檔案(syslog,可能還有 中的其他檔案/var/log)。

相關內容