Skip to content

Instantly share code, notes, and snippets.

@JamesTheBard
Created June 10, 2013 06:21
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JamesTheBard/5746867 to your computer and use it in GitHub Desktop.
Save JamesTheBard/5746867 to your computer and use it in GitHub Desktop.
mcabber notification script
#!/bin/sh
echo "$1 $2 $3 $4" >> ~/test.mcabber.log
EVENT_TYPE=$1
EVENT_SUBTYPE=$2
JID=$3
FILE=$4
TITLE="Google Hangouts"
SOUND_FILE="$HOME/.mcabber/sounds/alert_47.wav"
ICON="$HOME/.mcabber/images/chat.png"
TIMEOUT=10000
function new_message_in() {
notify-send -i $ICON -t $TIMEOUT "$TITLE" "New message from ${JID}."
aplay -d 2 $SOUND_FILE
}
if [ $EVENT_TYPE == "MSG" ] && [ $EVENT_SUBTYPE == "IN" ]
then
new_message_in
fi
@JamesTheBard
Copy link
Author

The mcabberrc file has the following options set to get this to work:

set events_command = ~/.mcabber/eventcmd
set events_ignore_active_window = 1
set eventcmd_use_nickname = 1

This places the eventcmd script into the $HOME/.mcabber directory. The eventcmd script gets passed information like:

STATUS O Random Person
MSG OUT Random Person
MSG IN Random Person

Just remember to either change $SOUND_FILE and $ICON variables to applicable files, or to change the function new_message_in to not play sounds (aplay) or display an icon.

notify-send -t $TIMEOUT "$TITLE" "New message from ${JID}."
# aplay -d 2 $SOUND_FILE

You can test it out by navigating to the $HOME/.mcabber directory and running:

./eventcmd MSG IN "Test User"

@wuxmedia
Copy link

wuxmedia commented Dec 7, 2013

thank you very much!
this has helped me enormously.

@tobytes
Copy link

tobytes commented Dec 19, 2013

Very nice script. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment