MQTT2NotifySend
1.0.0
? สะพานระหว่าง MQTT และ freedesktop.org แจ้งเตือนการแจ้งเตือนเดสก์ท็อป (Ubuntu & distros อื่น ๆ )? เพื่อส่งการแจ้งเตือนไปยังเดสก์ท็อปของคุณผ่าน 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 (run ./mqt2notifysend.sh --help เพื่อทราบข้อมูลเพิ่มเติม)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