How to regain the focus back to the launch window?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to regain the focus back to the launch window?
# 1  
Old 11-22-2014
How to regain the focus back to the launch window?

Consider this code snippet below:-
Code:
char=`which afplay`
if [ "$char" != "" ]
then
	xterm -e 'while true; do clear; echo "Press Ctrl-C to Quit..."; afplay /tmp/pulse.wav; done' & > /dev/null 2>&1
fi

This launches a second terminal window that generates a specific waveform for the next calibration of AudioScope.sh.
It works perfectly except for one minor problem.
When Ctrl-C in pressed in this new terminal window it closes down but does NOT return the focus back to the launch, (AudioScope), terminal window.
I have to click inside the window to return the focus back to the AudioScope window.
AudioScope.sh still runs fine when not in focus but when COMMAND mode appears I have to refocus the window before entering text.
Is there any method to refocus it, or is it 'Tough! You will just have to put up with it'?
# 2  
Old 11-22-2014
Don't close the xterm that already has focus.

Write a shell script that traps CTRL-C that kills and restarts afplay without the shell itself quitting. Then use that as the shell xterm starts with.

Of course, then the problem is how to kill the window...
# 3  
Old 11-22-2014
Hi achenle...

Using no xterm at all and launching using eval requires that I kill the process when finished with. The only thing is whether this is a frowend upon method because of 'eval'.

This actually works a real treat and places me straight back into my shell ready for the kill command...
Code:
Last login: Sat Nov 22 16:20:28 on ttys000
AMIGA:barrywalker~> eval 'while true; do afplay /tmp/pulse1.wav; done' &
[1] 19272
AMIGA:barrywalker~> kill 19272
[1]+  Terminated: 15          eval 'while true; do afplay /tmp/pulse1.wav; done'
AMIGA:barrywalker~> _

Thanks for pointing me to a lateral solution...

Bazza...

Last edited by wisecracker; 11-22-2014 at 12:36 PM..
# 4  
Old 11-22-2014
Why do you use the eval construct? What difference does it make without eval?
And, depending on how many background jobs you have, kill %1 (in above case) might be easier to type.
This User Gave Thanks to RudiC For This Post:
# 5  
Old 11-22-2014
Hi RudiC...

Thanks a lot...

Why indeed; 'eval' is not needed after all.

There will only be 1 job at any one time during the main program run...

Many, many thanks...

I will mark as solved when it is inserted and fully working in the main script...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Toggle between xterm window and standard terminal window

Is it possible to toggle back and forth between an xterm invoked from one tty, and a shell invoked from a different tty? I am running Centos 7 with KDE and booting in non-graphic mode. After logging in on the default window (/dev/tty1) , I can then use ALT-F2 to access a new window (/dev/tty2),... (1 Reply)
Discussion started by: rhgscty
1 Replies

2. Shell Programming and Scripting

Script to launch a KDE Konsole window with multiple tabs

Gents, I found this script to to launch a KDE Konsole window with multiple tabs.. #!/bin/bash # # Create my standard konsole windows. if ]; then profile=Shell fi sessions=( sh1 $profile 'clear; bash' sh1 $profile 'clear; bash' su1 $profile 'clear; su'... (1 Reply)
Discussion started by: jiam912
1 Replies

3. UNIX for Dummies Questions & Answers

How do you close and launch X Window in the Bash shell?

What is the Unix command(s) to close the X Window in the Bash shell to get me into text mode. Also need the command to relaunch it from the text mode. Thanks. (1 Reply)
Discussion started by: jacatone
1 Replies

4. Programming

Proximity-card reader: no data when app window out of focus

Hello. I can't get it work :( My application receives data from em-marin reader only being active. Switching to another app makes the port become silent. MarinReader works in another thread. Port reading is going while the app is inactive (tested). Env: Ubuntu 9.04, Gnome, Qt (i've tryed pure... (2 Replies)
Discussion started by: Dp0H
2 Replies

5. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: acclaypool
2 Replies

6. Solaris

Script to launch terminal window?

Hi, I am a newbie here. Trying to find a way of writing a script to launch multiple terminal or console windows on solaris 9. I used to be able to do this using cmdtool on older versions of solaris and it was even possible to configure the size and screen position of the window and the title. ... (5 Replies)
Discussion started by: omerta
5 Replies

7. Windows & DOS: Issues & Discussions

window 2000 professional not pinging my window 98 system.

Hello, We someone help me resolve this problem. I have window 2000 professional, windows 98 and Unixware 7.0.1 on the network. I was able to establish connection with all. However, l was unable to ping window 98 from window 2000 professional. I was able to ping the window 2000 from the window... (10 Replies)
Discussion started by: kayode
10 Replies

8. UNIX for Dummies Questions & Answers

memory regain

When i first restart my computer memory usage is at 24% as the days months and evening pass it gets up to 80% and holds there sometime breaching 98%. Is there an command to regain the memory? Redhat 8 768 mb ram (6 Replies)
Discussion started by: macdonto
6 Replies
Login or Register to Ask a Question