4

I'd like to let my bash shell scripts to display gui notifications with two buttons that the user can click and then execute some commands depending on the button pressed.

What options exist?

  • Welcome to Ask Different. What do you have so far to do this? What language is your script? It's best to show your work so that people don't vote to close this as too broad. – bmike Oct 16 '15 at 19:19
  • A simple bash script that performs some tasks and when done shows the notification asking for an action – Matteo Oct 16 '15 at 19:44
3

I'm a big fan of Tkinter since it has far more tutorials that help a new person solve real problems and python/tk ship with all Macs and the versions have been stable for years of OS X releases.

To get started, run this command:

python -c "import Tkinter;Tkinter._test()"

If the free tutorials linked above aren't working for your needs, the professional ones on lynda and python classes like https://www.coursera.org/learn/python are fairly easy to get started with limited time or limited funds.

You could also start from the GUI with Platypus and have it call your desired bash scripts for each button that's pressed. You could then open the "app" with open -a to get things started.

1

I use a small command line "alerter" to display Alerts notifications from terminal.

i code this tool, feel free to contribute : https://github.com/vjeantet/alerter

enter image description here

1

I've had the most success with the widely used terminal-notifier command-line tool.

0

Have a look at AppleScript which can be used from the shell with osascript. It has full gui support, integrates very well with shell scripts and has a rich user base and history with plenty of tutorials to get you started. It's preinstalled on every Mac, including a complete script editor in case you like dedicated apps.

  • Actually i've used AppleScripts widely alongside shell script but it seem it can only show standard notifcations in Notification Center. – Matteo Oct 17 '15 at 11:29
  • So with GUI notifications you don't mean a modal dialog but a Notication Center message with buttons? – John Keates Oct 17 '15 at 18:56
  • Yes, like the app store's notification shown here: stackoverflow.com/questions/21110714/… – Matteo Oct 17 '15 at 19:04
  • In that case, you have to use a helper app like terminal-notifier, or use AppleScriptObjC where you call Objective-C methods from AppleScript like in macscripter.net/viewtopic.php?id=39189 – John Keates Oct 17 '15 at 19:08
  • Ok, mabye it's a bit beyond my current knowledge but i'll check it out. – Matteo Oct 17 '15 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .