How to send a notification to another user with notify-send ? Bash

匿名 (未验证) 提交于 2019-12-03 08:57:35

问题:

notify-send display a notification box with the message that you want to display on your own machine.

Is there a way to use notify-send to send a notification message to another user and display the message on his machine?

回答1:

Bash can write to network sockets but can't listen/read. You could use GNU Netcat for this functionality.

A network notify-reader listening on port 10000 (no security):

#!/bin/bash  # no multiple connections: needs to improve while true; do     line="$(netcat -l -p 10000)"     notify-send -- "Received Message" "$line" done 

An a corresponding client:

#!/bin/bash  host="$1" echo "$@" >/dev/tcp/$host/10000 

So you can send messages using

notify-sender.sh  your-host message 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!