I set up lirc to control my PC with a remote. To switch between different modes I edited .lircrc as follows:
begin vlc
include ~/.lirc/vlc
end vlc
begin gnome
include ~/.lirc/gnome
end gnome
begin firefox
include ~/.lirc/firefox
end firefox
begin me-tv
include ~/.lirc/me-tv
end me-tv
begin
prog = irexec
button = KEY_YELLOW
config = if [ -n $(pgrep -f vlc) ]; then (vlc &); fi
mode = vlc
end
begin
prog = irexec
button = KEY_GREEN
mode = gnome
end
begin
prog = irexec
button = KEY_RED
config = if [ -n $(pgrep -x firefox) ]; then (firefox &); fi
mode = firefox
end
begin
prog = irexec
button = KEY_BLUE
config = if [ -n $(pgrep -x me-tv) ]; then (me-tv &); fi
mode = me-tv
end
Everything works fine with it - except switching to Firefox: When Firefox is running and I press the red button it switches the mode (as it should) and opens a second window/instance of Firefox (as it should not).
The problem appears only with Firefox.
Edit → Preferences → Tabs → Open new windows in a new tab instead is already enabled:

What happens when Firefox is running and I start firefox in a terminal?
firefox- a second window opensfirefox about:startpage- a new tab in Firefox opens with the preconfigured startpage- (!)
firefox about:blank- a new tab in Firefox opens with my personal startpage (Speeddial) firefox chrome://speeddial/content/speeddial.xul(which is the adress of the Speeddial startpage) - nothing happens
What happens when Firefox is not running and I start firefox in a terminal?
firefox- Firefox opens as configured inPreferences(Show my windows and tabs from last time)firefox about:startpage- Firefox opens with an additional new tab with the preconfigured startpage- (!)
firefox about:blank- Firefox opens with an additional new, blank tab firefox chrome://speeddial/content/speeddial.xul- Firefox doesn't open:*** Preventing external load of chrome: URI into browser window.Use -chrome <uri> instead
So, when I modify the command in the script (config = ...) and add an adress like about:blank it solves the problem partly. As problem remains that it doesn't put Firefox in the foreground when it is already running. This only happens sometimes.
Could anyone help me to edit this script to fix this misbehaviour? (Source of the script which I modified.)