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?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityI'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?
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.
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
I've had the most success with the widely used terminal-notifier
command-line tool.
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.