Page 1 of 1

Doing computer notifications from Mudlet

Posted: Thu Jun 04, 2009 11:29 pm
by Vadi
This function will spawn a computer notification from Mudlet - useful if you're not looking at it but want to be notified of something imporant happening.

It's for Ubuntu 9.04 only right now though - if you know the OS command for the standard linux one / mac / windows, lemme know and I'll add it in.

Code: Select all

function notify (...)
	os.execute([[notify-send "Mudlet" "]] .. ... .. [["]])
end
Example:

Code: Select all

notify("It works!")

Re: Doing computer notifications from Mudlet

Posted: Fri Jun 05, 2009 5:14 am
by derekperrault
Vadi, there's nothing native for Mac OSX, but the most popular third-party app for providing notifications is Growl.

I'm not sure if a Lua binding actually exists at the moment.
http://growl.info/documentation/developer/

Re: Doing computer notifications from Mudlet

Posted: Fri Jun 05, 2009 1:27 pm
by Vadi
Yeah, the notify-osd thing doesn't have lua bindings yet. I'm just using a system command they provide "for everything else" right now.

Does perl come standard with Mac OS? We can use Lua's os.execute command then to execute a perl script which does the notification.

edit: ah crap, it says perl needs manual installation. can applescript be executed via terminal?

Re: Doing computer notifications from Mudlet

Posted: Fri Jun 05, 2009 7:11 pm
by derekperrault
Actually, Perl (currently v5.8.8) does come pre-installed with Mac OS X.

And, yes, AppleScript (ugh) can be executed from the terminal using the osascript command.

Re: Doing computer notifications from Mudlet

Posted: Fri Jun 05, 2009 8:55 pm
by Vadi
Yes but Growl says Growl Perl support needs installation whereas AppleScript doesn't.

I don't have a mac to test this, want to poke about this yourself with http://growl.info/documentation/applescript-support.php ?

you can use os.execute(command) to execute binary that is in the systems path, so calling osascript with it should go.

Re: Doing computer notifications from Mudlet

Posted: Thu Jun 25, 2009 3:03 am
by Thylacine
KDE3 users can do something like:

Code: Select all

os.execute("dcop knotify default notify eventname appname 'Hello world' '' '' 2 0")
KDE4, though, will need to use DBus or Kdialog..

Code: Select all

kdialog --title "This is a passive popup" --passivepopup "It will disappear in about 10 seconds" 2
Which doesn't work here.

I'm also not familiar with dbus, but there you go :?

Re: Doing computer notifications from Mudlet

Posted: Tue Mar 18, 2014 9:07 am
by uti
For OS X, you can install terminal-notifier

The function code then becomes:

Code: Select all

function notify (...)
   os.execute([[terminal-notifier -title "Mudlet" -message "]] .. ... .. [["]])
end
NOTE: Did not work for me with manual install. I had to install it via gem (sudo gem install terminal-notifier). See under "Download" in the readme here: https://github.com/alloy/terminal-notifier

Re: Doing computer notifications from Mudlet

Posted: Tue May 13, 2014 12:28 am
by SlySven
Trawling through the old posts found this but found that although I had the DBUS infrastructure in place on my Debian 7.3 (Wheezy) I did not have the notify-send command - turned out it was in libnotify-bin package - if that helps anyone else and at version 0.7.5 there are at least the following options that can be used...

Code: Select all

os.execute([[notify-send --app-name="Mudlet" --icon="./icons/mudlet_main_48px.png --expire-time=10000 ]] .. summary .. message .. [["]])
You will need to quote or double-quote both the "short?" summary line and the main message text taking care with any character that can invoke extra shell actions (e.g. '!' which bash shells used for history expansion needs to be escaped with a '\' to prevent that if in a double-quoted text).