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. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-03-2011, 10:33 AM
|
#1
|
|
LQ Newbie
Registered: May 2011
Posts: 5
Rep:
|
bash question: how to make firefox open, but minimize
I am relatively new to scripting, but I was wanting to open a firefox window from a bash script, but have it open, then minimize.
In the script, I have a single instance of:
firefox &
but is there a way to minimize it, versus have it displayed on the screen? I was wanting the command terminal to remain visible and it can't since the firefox window is open in front of it.
I looked all over the place, including the man pages, but to no avail. I can make the height and width changes, but no minimize.
Either that, or to be able to bring the terminal window back to the front automatically.
Thanks.
|
|
|
|
05-03-2011, 11:46 AM
|
#2
|
|
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,591
|
This will work. Install xdotool if you don't already have it from your distribution repositories.
Code:
xdotool search --class firefox windowactivate
xdotool key alt+F9
|
|
|
|
05-03-2011, 03:04 PM
|
#3
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,577
|
Other than initial size and position, window control like this is usually handled by the window manager, not the program or the shell that launches it. KDE, for example, has application-specific settings ability, accessible through the window menu or system settings.
There are ways for the shell to talk to the WM, however, such as through dbus.
xdotool is stand-alone program that sends simulated input events from the shell to the X windowing system. Unfortunately, it can't directly handle window raising or lowering, but you can simulate a press of a hotkey combination, which is what macemoneta's example above does.
However, his example may affect all open windows of the program. To be certain you're affecting only the one you're just launching, create a wrapper script like this:
Code:
#!/bin/bash
#launch the program in the background, with all command-line options passed to it.
firefox "$@" &
#grab its process id.
pidno=$!
#wait for a second so that the window has time to fully register.
sleep 1
#use xdotool to make sure that window is raised to the top.
#this is necessary because it won't directly accept xdotool keypresses otherwise.
#matches both the pid and the class, to ensure we have the right window.
xdotool search --all --pid $pidno --class firefox windowactivate
#use xdotool again to simulate your hotkey combo. Adjust as necessary.
xdotool key alt+F9
exit 0
|
|
|
|
05-03-2011, 05:44 PM
|
#4
|
|
LQ Newbie
Registered: May 2011
Posts: 5
Original Poster
Rep:
|
Thanks you all. I'll give this a shot when I get home.
|
|
|
|
05-04-2011, 12:06 AM
|
#5
|
|
Senior Member
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279
|
Why don't you set the terminal window to be "On top" ?
|
|
|
|
05-04-2011, 02:01 AM
|
#6
|
|
Member
Registered: Aug 2007
Location: The Greate INDIA
Distribution: CentOS, RHEL, Fedora
Posts: 102
Rep:
|
One more question addition to this....
Can we do this(minimizing firefox) using "gconf-editor" ?
Wt it stands for ?
Is it like windows registry editor ?
[Kindly mark this thread as SOLVED, If you(@chicone) got solution]
Last edited by vdx; 05-04-2011 at 02:36 AM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:12 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|