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_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