代码之家  ›  专栏  ›  技术社区  ›  Debugger

如何使用notify send向其他用户发送通知?猛击

  •  3
  • Debugger  · 技术社区  · 16 年前

    通知发送显示一个通知框,其中包含要在自己的计算机上显示的消息。

    是否有方法使用notify send向其他用户发送通知消息并在其计算机上显示该消息?

    1 回复  |  直到 11 年前
        1
  •  7
  •   Jürgen Hötzel    16 年前

    Bash可以写入网络套接字,但不能侦听/读取。你可以用 GNU Netcat 为了这个功能。

    侦听端口10000的网络通知读取器(无安全性):

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

    对应的客户:

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

    所以你可以用

    notify-sender.sh  your-host message
    
    推荐文章