#!/usr/bin/env ruby require 'terminal-notifier' event, arg1, arg2, filename = ARGV history = "#{Dir.home}/.mcabber/histo" filename = "#{history}/#{arg2}" log = File.open "#{Dir.home}/.mcabber/eventcmd.log", 'a' log.write "#{event}, #{arg1}, #{arg2}, #{filename}\n" log.write "filename: #{filename}\n" def notify(msg, arg2) # TerminalNotifier.notify(msg, title: "Mcabber", subtitle: "#{arg2}", sound: 'default', activate: 'com.apple.Terminal') # terminal TerminalNotifier.notify(msg, title: "Mcabber", subtitle: "#{arg2}", sound: 'default', activate: 'com.googlecode.iterm2') # iterm2 end case event when "MSG" case arg1 when "IN" if filename and File.exists?(filename) file = File.open(filename).to_a msg = file.last[26..-1] else msg = "file not found" end notify(msg, arg2) when "OUT" end when "STATUS" msg = { "O" => "online", "F" => "chat", "A" => "away", "N" => "xa", "D" => "dnd", "I" => "invisible", "_" => "offline", "?" => "error", "X" => "requested" }[arg1.to_s] notify(msg, arg2) when "UNREAD" end