Doing computer notifications from Mudlet

Post Reply
User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Doing computer notifications from Mudlet

Post 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!")

derekperrault
Posts: 14
Joined: Sun May 31, 2009 7:40 am

Re: Doing computer notifications from Mudlet

Post 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/

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Doing computer notifications from Mudlet

Post 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?

derekperrault
Posts: 14
Joined: Sun May 31, 2009 7:40 am

Re: Doing computer notifications from Mudlet

Post 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.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Doing computer notifications from Mudlet

Post 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.

Thylacine
Posts: 28
Joined: Sun May 10, 2009 5:04 am

Re: Doing computer notifications from Mudlet

Post 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 :?

uti
Posts: 10
Joined: Thu Feb 03, 2011 6:16 pm

Re: Doing computer notifications from Mudlet

Post 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

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Doing computer notifications from Mudlet

Post 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).

Post Reply