3

I am using multiple workspaces. Whenever I click the Firefox icon in the Unity toolbar it takes me to the workspace with Firefox currently open which is a useful feature. However, every time I click the Firefox icon I'd like a new window in Firefox to open. I know it's possible to right click the icon and click "Open a New Window" but I'd like "Open a New Window" to be the default.

Here is a terrible hack that I implemented this morning but I'd like to learn a more elegant solution.

First I created a script called openfirefox and placed it in my home directory /home/user

#!/bin/bash

firefox &

I made the file executable and then used the gnome-desktop-item-edit command to create a .desktop file and placed it on the desktop

$ sudo gnome-desktop-item-edit /home/user/Desktop --create-new

I entered the fields as follows

Name: MyFox
Command: /home/user/openfirefox

This created a .desktop file on my desktop. Now whenever I double click the MyFox.desktop file, a new Firefox window opens everytime.

So, is there a more elegant way to do what I want? Perhaps if I edit /usr/share/applications/firefox.desktop I can change the defaults? Maybe there is a Unity setting I can change?

Note: I am also aware you can simply press the shift key to open a new window but I'm just wondering if there is a way to make it a default. If this is an unrealistic request I'll just make do with shift and MyFox.desktop

3
  • 2
    I think that you can put the .desktop - that you created on your Desktop - in the Launcher. If not, place it in ~/.local/share/applications/ , on the next login it should show up in Unity and then you can put it in the Launcher.
    – dadexix86
    Nov 23, 2015 at 17:15
  • This worked. I don't know why I didn't think of this before. Thanks. Nov 25, 2015 at 2:11
  • @CMRELAB You're right. My answer opens a new window whenever the launcher runs the default "Exec" action, but this does not happen when clicking on the icon while it's already running on a different workspace. I deleted my answer.
    – Byte Commander
    Nov 26, 2015 at 14:18

2 Answers 2

2

I think that you can put the .desktop file - that you created on your Desktop - in the Launcher.

If not, place it in ~/.local/share/applications/, on the next login it should show up in Unity and then you can put it in the Launcher.

2

We will make a copy of the Firefox launcher for your user account and modify the default action by adding the -new-window argument to the firefox command.

First, we copy the original firefox.desktop to the right folder in your home directory:

cp /usr/share/applications/firefox.desktop ~/.local/share/applications/

Second, we can simply modify the correct line with the command below:

sed -i 's/%u/-new-window %u/' ~/.local/share/applications/firefox.desktop

This searches for occurrences of %u in the file and replaces them with -new-window %u. That works because the %u argument place-holder only appears once in the Exec line of the default action. The modified line is:

  • from: Exec=firefox %u
  • to: Exec=firefox -new-window %u

IMPORTANT: You need to restart Unity afterwards by logging out and back in!
Otherwise Unity doesn't recognize that there's a new file in your home directory that should override the system-wide one and you won't see any change.

3
  • Hmmm. This seemed simple enough but it didn't work for me. There is definitely a new firefox.desktop file in ~/.local and the file has -new-window in the default Exec line but when I click the icon in the Unity toolbar it still only opens 1 window. I actually tried this from dadexix86 "I think that you can put the .desktop - that you created on your Desktop - in the Launcher. If not, place it in ~/.local/share/applications/ , on the next login it should show up in Unity and then you can put it in the Launcher." and that worked pretty well. Nov 25, 2015 at 2:46
  • 1
    @CMRELAB you probabloy didn't log out/in afterwards. This is simply the way to do it. Nov 25, 2015 at 8:40
  • I did log out and back in. I even removed the original firefox.desktop file from /usr/ and still no luck. When I click Firefox in Unity it opens an instance of Firefox. Then when I switch to a new workspace and click the Firefox icon in Unity it simply switches me to the original instance that was already open rather than opening a new one. I did a search for other firefox.desktop files on my computer (found nothing) and even tried this on my laptop but it's not working for me. Perhaps my Ubuntu just has a weird setting that yours doesn't. I should probably add that I'm using 14.04 Nov 26, 2015 at 14:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .