LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 05-03-2011, 10:33 AM   #1
chicone
LQ Newbie
 
Registered: May 2011
Posts: 5

Rep: Reputation: 0
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.
 
Old 05-03-2011, 11:46 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
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
 
Old 05-03-2011, 03:04 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
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
 
Old 05-03-2011, 05:44 PM   #4
chicone
LQ Newbie
 
Registered: May 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks you all. I'll give this a shot when I get home.
 
Old 05-04-2011, 12:06 AM   #5
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
Why don't you set the terminal window to be "On top" ?
 
Old 05-04-2011, 02:01 AM   #6
vdx
Member
 
Registered: Aug 2007
Location: The Greate INDIA
Distribution: CentOS, RHEL, Fedora
Posts: 102

Rep: Reputation: 24
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.
 
  


Reply


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 make an application startup on boot time and instantly minimize? silvyus_06 Linux - Software 6 11-13-2010 02:21 PM
How do i make firefox 3 work after installing firefox 2 on Ubuntu 8.04 avinash.rao Ubuntu 10 09-06-2008 10:34 AM
Can't minimize open windows. They disappear. the firefox 3.0 title bar shows 9 open rangerpresto Linux - Desktop 5 08-10-2008 01:30 PM
Firefox close/minimize buttons merchtemeagle DamnSmallLinux 2 02-05-2006 05:26 AM


All times are GMT -5. The time now is 01:02 PM.

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