MQTT2NotifySend
1.0.0
MQTT和Freedesktop.org之間的橋接通知桌面通知(Ubuntu&其他發行版),以通過MQTT發送通知到您的桌面。
# Dependencies are: libnotify-bin, mosquitto-clients, jq, coreutils
sudo apt install libnotify-bin mosquitto-clients jq coreutils
# Download the script & set as executable (optional)
curl -O https://raw.githubusercontent.com/David-Lor/MQTT2NotifySend/master/mqtt2notifysend.sh
chmod u+x mqtt2notifysend.sh
# Run!
./mqtt2notifysend.sh -h localhost -t notifications
# Send a message to the broker from other terminal window
mosquitto_pub -h localhost -t notifications -m " { " title " : " Custom notification " , " text " : " Hello world " } "mosquitto_sub命令(運行./mqt2notifysend.sh --help Mosquitto_sub命令相同)。title :通知標題(可選)text :通知主體(需要)level :通知緊迫級別(可選; low : normal , critical ;默認值: normal )iconB64 :通知圖像圖像,編碼為base64字符串(可選)可以使用以下環境變量對某些設置進行調整:
RECONNECTION_DELAY :在連接嘗試之間等待的時間(默認: 5 )DEFAULT_TITLE :未經標題發送的通知默認標題(默認: MQTT2NotifySend )DEFAULT_LEVEL :默認通知日期級別,用於未級別發送的通知(默認: normal )LOG_ENABLE :如果是true或1 ,請啟用腳本日誌(默認值: false )ICON_BASE_PATH :下載通知圖標文件的位置,每個通知。這是該文件的絕對/相對路徑,用作前綴(默認值: /tmp/mqtt2notifysend-icon icon )ICON_DELETE_DELAY :在圖標之間等待秒數已被解碼和刪除。不能為零,因為NotifySend命令可能會稍微延遲一點,並且在彈出通知時可以刪除圖標,而不會顯示圖標(默認值: 5 )用法:
LOG_ENABLE=true RECONNECTION_DELAY=1 DEFAULT_TITLE= " Very important notification " DEFAULT_LEVEL=critical
bash mqtt2notifysend.sh -h localhost -t notifications