Flash And Fade DEMO For Mac OSX 10.7.5, (And Linux?).


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Flash And Fade DEMO For Mac OSX 10.7.5, (And Linux?).
# 1  
Old 02-24-2013
Flash And Fade DEMO For Mac OSX 10.7.5, (And Linux?).

This is an AT A GLANCE shell DEMO that does:-

1) 10 centred greyscale fades without warning beeps.

2) 5 centred yellow "WARNING!" flashes with beeps every ON state.

3) 5 FULL widowed red "DANGER!!!" flashes with beeps in the ON and OFF states.

It assumes that the warning bell is enabled inside the terminal.

It is primarily for OSX 10.7.5 and above but it could just as easily work in Linux or other UNIX like systems. It is issued as Public Domain and you my do with it as you please...

READ THE CODE FOR MORE INFO...

(Watch for wordwrapping, etc...)

Bazza, G0LCU...

Code:
#!/bin/bash
#
# Flash and fade for a Macbook Pro OSX 2.7.5 Terminal...
# A DEMO to show how to give an AT A GLANCE, and, audible warning of impending doom in a shell script.
# It is for something like an analogue Data Logger input say from an Arduino analogue source.
#
# It may well work on other Linux and Unix like machines but is untested and uses the "tput" command
# to hide and unhide the terminal cursor. The command "setterm" is commented out and could be used
# in place of the above depending on the *NIX flavour...
#
# Written in such a way that anyone can understand how it works.
#
# It starts with 10 cycles of grey/gray scale fading on a black background without any beeps then next
# 5 yellow warning flashes with a beep every full flash and finally 5 FULL screen red flashes with beeps
# on every ON and OFF state.
#
# Clear a screen to white on black...
printf "\033[0;37;40m"
clear
printf "\n           Flash and fade for a default Macbook Pro OSX 2.7.5 Terminal.\n"
# Turn the cursor off...
#setterm -cursor off
tput civis
# Fade on and off 10 times, grey/gray scales on black.
for fade in $(seq 1 10)
do
	printf "\033[12;23f\033[1;30;40mFading using four _shades_ of grey...\033[0m"
	sleep 0.1
	printf "\033[12;23f\033[1;90;40mFading using four _shades_ of grey...\033[0m"
	sleep 0.1
	printf "\033[12;23f\033[1;37;40mFading using four _shades_ of grey...\033[0m"
	sleep 0.1
	printf "\033[12;23f\033[1;97;40mFading using four _shades_ of grey...\033[0m"
	sleep 0.1
	printf "\033[12;23f\033[1;37;40mFading using four _shades_ of grey...\033[0m"
	sleep 0.1
	printf "\033[12;23f\033[1;90;40mFading using four _shades_ of grey...\033[0m"
	sleep 0.1
done
# Over-write the above with the same line again but with black foreground and background colo(u)rs.
printf "\033[12;23f\033[1;30;40mFading using four _shades_ of grey...\033[0m"
# Now flash a YELLOW warning line with beeps for 5 times.
for flash in $(seq 1 5)
do
	printf "\033[12;37f\033[0;93;40mWARNING!\033[0m\a"
	sleep 0.5
	printf "\033[12;37f\033[0;30;103mWARNING!\033[0m"
	sleep 0.5
done
# Finally a full window flash with _continuous_ beeps.
for fullflash in $(seq 1 5)
do
	printf "\033[1;91;40m"
	clear
	printf "\033[12;36f\033[1;91;40mDANGER!!!\a"
	sleep 0.5
	printf "\033[0;30;101m"
	clear
	printf "\033[12;36f\033[1;30;101mDANGER!!!\a"
	sleep 0.5
done
# Reset the cursor back on...
#setterm -cursor on
tput cnorm
# Reset the terminal colo(u)rs back to the defaults...
printf "\033[0m"
clear
printf "\n         \$VER: Fade.sh_Version_0.00.10_Public_Domain_2012_B.Walker_G0LCU.\n\n"
# Fade.sh DEMO end...
# Enjoy finding simple solutions to often very difficult problems...

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

UML on MAC OSX

Hey guyz, Is it possible to build user-mode linux kernel on MAC OSX? Please I need a reply asap as I have an assignment that I need to do. Thanks! Adel (1 Reply)
Discussion started by: aje02
1 Replies

2. OS X (Apple)

Does MAC OSX follow POSIX?

i mean if i coded an application for Linux using System Calls and no libs, and compiled it on MAC, will it work? thanks (6 Replies)
Discussion started by: JonhyM
6 Replies

3. OS X (Apple)

Cron on Mac OSX

Hello, I was wondering about my Cron Script: HELL=/bin/tcsh PATH=/sbin:/bin:/usr/sbin:/usr/bin HOME=/var/log MAILTO=jwillis 25 1 * * * root /Users/jwillis/Fbcmd\Scripts/DailyBirthday.scrmy returned message is: Subject: Cron <jwillis@Macintosh-66> root ... (1 Reply)
Discussion started by: jwillis0720
1 Replies

4. OS X (Apple)

Mac OSX kernel

is there anyway of looking at, and if possible, modifying it? (2 Replies)
Discussion started by: cleansing_flame
2 Replies

5. Windows & DOS: Issues & Discussions

win-xp/mac-osx

I'm currently looking for an emulation program that would allow me to open and run osx app.s and programs on a windows xp based system. if not is there a unix/linux/lindows program that may do the same? (3 Replies)
Discussion started by: area51nstk
3 Replies

6. UNIX Desktop Questions & Answers

Mac Osx.2

I finally broke down and decided to buy a new piece of hardware. I think I made the right decision when I chose an Apple iBook - OSX is incredible! I haven't used a Mac since System7.5, and 10.2 is just blowing me away! Best of all, it's easy to use for people who are not used to Mac, but if I... (5 Replies)
Discussion started by: LivinFree
5 Replies

7. Cybersecurity

ssh and Mac OSX

Please help if you are familiar with Mac OSX. I downloaded OpenSSH for a newer version of SSH than what comes with OS 10.1. What a mistake! Now every time I try to make a connection to my remote server I get an message that ssh was built against version such and such and I have version such and... (2 Replies)
Discussion started by: glfisfn
2 Replies

8. UNIX for Dummies Questions & Answers

XWindows on Mac OSX

Hello, I'm like most people who post here, I'm new in UNIX. Yesterday I installed Xwindows on my OSX box just to learn as much about UNIX as I can. I been messing around with my terminal and conf files that have to do with Apache and sendmail and didn't mess anything up so I thought I was ready to... (2 Replies)
Discussion started by: Alpha_Harblo
2 Replies

9. UNIX for Dummies Questions & Answers

Mac OSX question

Hi. Is it possible to execute a Cocoa (or Carbon or eaven a classic) program for mac OSX in the terminal window? OSX finder can sometimes be so busy that it wont respond for several minutes, ie if you are uploading a very big file/files to a afp server. Then it would have been nice to start... (7 Replies)
Discussion started by: nicke30
7 Replies

10. UNIX for Dummies Questions & Answers

Mac OSX vs. UNIX

To anyone that has the answer: What does UNIX have that Mac OSX doesn't. I am a programmer, and I am wondering if I could just get Mac OSX for my programming needs instead of UNIX. But my major question is what does UNIX have that Mac OSX doesn't. Thank you if you have the answer, and are willing... (2 Replies)
Discussion started by: REM
2 Replies
Login or Register to Ask a Question