Bash: Exiting while true loop when terminal is not the focus window | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Bash: Exiting while true loop when terminal is not the focus window

Shell Programming and Scripting


Tags
linux, ubuntu

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-12-2008
acclaypool acclaypool is offline
Registered User
 
Join Date: Feb 2008
Last Activity: 25 February 2008, 5:02 PM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Power Bash: Exiting while true loop when terminal is not the focus window

I am running an Ubuntu Gutsy laptop with Advanced Compiz fusion options enabled. I am using xdotool to simulate keyboard input in order to rotate through multiple desktops.

I am looking for a way to kill a while true loop when the Enter key (or Control+C if it is easier) is pushed when the terminal window is not the focus window. The following script works like a charm if the terminal is the focus but I'm don't want a terminal window in the rotation.

Any ideas?

Here is the code.

#!/bin/bash



while true;
do
read -t 12 && break
./xdotool key "super+e"
read -t 2 && break
./xdotool key "Right"
read -t 2 && break
./xdotool key "super+e"
read -t 12 && break
./xdotool key "super+e"
read -t 2 && break
./xdotool key "Down"
read -t 2 && break
./xdotool key "super+e"
read -t 12 && break
./xdotool key "super+e"
read -t 2 && break
./xdotool key "Left"
read -t 2 && break
./xdotool key "super+e"
read -t 12 && break
./xdotool key "super+e"
read -t 2 && break
./xdotool key "Up"
read -t 2 && break
./xdotool key "super+e"

done
Sponsored Links
    #2  
Old 02-13-2008
acclaypool acclaypool is offline
Registered User
 
Join Date: Feb 2008
Last Activity: 25 February 2008, 5:02 PM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
"but I'm don't want"

I just read over my post, my "but I'm don't want" made me giggle internally.
Sponsored Links
    #3  
Old 02-25-2008
acclaypool acclaypool is offline
Registered User
 
Join Date: Feb 2008
Last Activity: 25 February 2008, 5:02 PM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
I am assuming that this is much more trouble than it is worth.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using arrays in bash using strings to bash built-in true kristinu Shell Programming and Scripting 41 03-30-2012 08:07 PM
loop until true antointoronto Shell Programming and Scripting 3 04-19-2010 12:43 PM
Proximity-card reader: no data when app window out of focus Dp0H Programming 2 08-18-2009 07:39 AM
how to exit a while true loop Noob e Shell Programming and Scripting 5 08-26-2007 02:44 PM
Exiting eXceed window kills my process shantaputi UNIX for Dummies Questions & Answers 2 05-31-2007 11:27 AM



All times are GMT -4. The time now is 03:01 AM.