Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-30-2009, 05:19 PM   #1
Registered: Mar 2005
Posts: 284

Rep: Reputation: 33
[SOLVED] Focus Problem with Dual Monitors when Launching Program with Bash script

Hello programming forum,

My computer has two monitors and each monitor operates from its own separate X server.

I want to launch a program on the second monitor from the first monitor using a simple bash script (DISPLAY=":0.1" /usr/bin/mythfrontend &).

This approach works but once I lose focus on the application in the second monitor, I can not get focus back again unless I close the application and open it back again.

The only remedy is to launch the program from the second monitor instead of the first monitor.

Is there a way I can fix this problem such as adding code to the bash script so that I can launch the program from the first monitor and be able to regain focus in the second monitor (with a mouse click) if it is lost?

Thank much in advance,

Last edited by rrrssssss; 12-01-2009 at 06:43 AM.
Old 12-01-2009, 06:42 AM   #2
Registered: Mar 2005
Posts: 284

Original Poster
Rep: Reputation: 33

I figured out a simple way to start mythfrontend from the first monitor and the focus problem be resolved. I used the following script below:

DISPLAY=":0.1" /usr/bin/icewm &
sleep 1
DISPLAY=":0.1" /usr/bin/mythfrontend &

If both commands (icewm and mythfrontend) are combined into one script instead of using two separate scripts, the focus problem is resolved. I had been using separate scripts, one script for icewm and another script for mythfrontend. That will not work. Both commands must be in the same script. Now I can start mythfrontend from my first monitor and have no focus problem.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set the focus to the window my bash program is running in? jlinkels Programming 1 09-18-2008 06:26 AM
Compiz - with Dual Monitors - screen focus NoStop Linux - Desktop 0 01-16-2008 10:47 AM
Independant monitors: launching an app to a monitor from CLI / script piete Slackware 0 12-12-2006 10:41 AM
launching programs from a bash script Ian D Linux - Software 2 10-25-2005 05:31 PM
Dual Monitors Problem Schmoe Linux - Software 2 07-01-2002 12:09 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:12 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration