Tobias Redmann
Tobias Redmann

Reputation: 174

Make the screen Flash from Mac OS Terminal

I using different build scripts for package my apps. Some of them running a while and it would be great to have a visual notification the script is ready.

I already use the notifications center with an Apple Script but something it is not alarming enough. Is it possible to run and Applescript or a command line command to let the screen flashes. A plus would be to flash in different colors (green for OK and red for build failed).

Upvotes: 4

Views: 2794

Answers (3)

Jake
Jake

Reputation: 2236

This will flash the terminal screen:

tput flash

You can flash your other terminals like this:

tput flash >/dev/ttys002

Upvotes: 1

rekcah1986
rekcah1986

Reputation: 11

Try this:

say finish

or

say there is a problem

Upvotes: 1

Mark Setchell
Mark Setchell

Reputation: 207670

I have a couple of ideas...

Easiest:

Go to Terminal->Preferences->Advanced and change to Visual Bell then do

tput bel

Coolest:

Here is a little scipt I wrote to save the current Desktop background and then set it to green for 3 seconds and then reset it back to what it was. Of course, if you like it you can make it do red for fail pretty simply. All you need to do is save the red.jpg and free,jpg files below in the /Library/Desktop Pictures folders as red.jpg and green.jpg. Then save the script below as notify and make it executable with:

chmod +x notify

and run it with

./notify

Here is the script:

#!/bin/bash

# Function to save current wallpaper
saveWallpaper(){
osascript<<EOF
tell application "Finder"
    set theDesktopPic to desktop picture
    set theName to displayed name of theDesktopPic
    return theName
end tell
EOF
}

# Function to set the wallpaper
setWallpaper(){
echo $1
osascript<<EOF
set desktopImage to POSIX file "/Library/Desktop Pictures/$1"
tell application "Finder"
    set desktop picture to desktopImage
end tell
EOF
}

# Start of actual script

# Save current wallpaper
saved=$(saveWallpaper)
echo Wallpaper is: $saved

# Set wallpaper to green for 3 seconds
setWallpaper "green.jpg"
sleep 3

# Restore wallpaper
setWallpaper "$saved"

Using some sound:

For success:

osascript -e 'beep 1'

For fail:

osascript -e 'beep 3'

Or how about:

afplay /System/Library/Sounds/Ping.aiff -v 2

enter image description here enter image description here

Upvotes: 6

Related Questions