Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notification when Terminal is ready/finished - Applescript

is there a way to get notified when terminal finished a command?

-> I run another script(not mine!) which downloads data when this script finished I want to quit terminal and do other stuff with this data.

EDIT:
I may didnt ask correctly...

Example:


tell application "Terminal"
   keystroke "php downloadscript.php"
   keystroke return
end tell

if (downloadFinished) -- do stuff else -- wait till finished

Edit 2: Awesome! Thank you! Working like that:


tell application "Terminal"
    set frontWindow to window 1
    repeat until busy of frontWindow is false
        delay 1
    end repeat
    #display dialog "finished"
end tell
greetings hatschii
like image 966
Timm Avatar asked Apr 29 '13 06:04

Timm


People also ask

What is terminal notifier Mac?

terminal-notifier is a command-line tool to send macOS User Notifications, which are available on macOS 10.10 and higher.

How do I check notifications on Mac?

in the upper-right corner of your screen, or swipe left with two fingers from the right edge of your trackpad. To view notifications that you missed, such as calendar alerts or FaceTime calls, click Notifications at the top of Notification Center. To open a notification in the app that sent it, click the notification.

Why am I not getting notifications on my Mac?

Give Notification Permission Step 2: Open System Preferences menu. Step 3: Go to the Notifications & Focus menu. Step 4: Select an app that's giving you trouble with notifications. Enable Allow Notifications toggle and close the menu.

How do I launch terminal and inform terminal?

Open Command Prompt in WindowsClick Start and search for "Command Prompt." Alternatively, you can also access the command prompt by pressing Ctrl + r on your keyboard, type "cmd" and then click OK.


1 Answers

Terminal's Dock icon starts bouncing when a tab prints \a and the tab is not focused or Terminal is not frontmost:

sleep 5; printf '\a'

You could also run something like afplay /System/Library/Sounds/Blow.aiff. Or use terminal-notifier:

sudo gem install terminal-notifier
terminal-notifier -message ''

You can wait until a program finishes running by checking the busy property of a tab:

tell application "Terminal"
    set w to do script "sleep 5"
    repeat
        delay 1
        if not busy of w then exit repeat
    end repeat
end tell
like image 154
Lri Avatar answered Nov 15 '22 17:11

Lri