Send highlights and private message to a unix socket
Place the script at ~/.weechat/ruby/socket_notify.rb
and symlink into
~/.weechat/ruby/autoload
if you want it to load on startup.
Then load it in weechat by running:
/script load socket_notify.rb
On my macbook I turn these notifications into OS X Notification Center messages by using the terminal-notifier app that I installed (with homebrew) by running:
brew install terminal-notifier
Then I read and react to these notifications with the follow bash functions:
function irc-notification {
TYPE=$1
MSG=$2
terminal-notifier \
-title IRC \
-subtitle "$TYPE" \
-message "$MSG" \
-appIcon ~/share/weechat.png \
-contentImage ~/share/weechat.png \
-execute "/usr/local/bin/tmux select-window -t 0:IRC" \
-activate com.apple.Terminal \
-sound default \
-group IRC
}
function get-irc-notifications {
ssh remote.host.net 'nc -k -l -U /tmp/weechat.notify.sock' | \
while read type message; do
irc-notification "$(echo -n $type | base64 -D -)" "$(echo -n $message | base64 -D -)"
done
}
Whenever weechat gets a private message or a highlight this script will write a
short description and the message to the /tmp/weechat.notify.socket
unix
socket if it exists. If the socket doesn't exist or isn't currently listening
then this script does nothing.
The message written is in the form:
<Base64 Description> <Base64 Message>
I chose to do this since it made reading the message with bash scripts really easy. You can read one line at a time from the socket and split on space to get both items. Please let me know if there are any other good uses for this that you come up with!