Skip to content

Option to focus an existing instance of a web app #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
filips123 opened this issue Feb 7, 2023 Discussed in #287 · 3 comments
Closed

Option to focus an existing instance of a web app #291

filips123 opened this issue Feb 7, 2023 Discussed in #287 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@filips123
Copy link
Owner

Discussed in #287

Originally posted by ThijmenDam February 6, 2023
Hi! I wonder if the current opening behavior of an app on macOS is intended. Right now, if I open a PWA that is already running (i.e. by double clicking the app icon or through Spotlight), a second instance of the app is opened. However, to me it would make more sense if the instance of the app that's already running would be brought to the front instead of opening a new instance. I think this is more in line with the usual behavior of macOS apps.

@filips123 filips123 added the enhancement New feature or request label Feb 7, 2023
@filips123 filips123 added this to the 2.5.0 milestone Feb 7, 2023
@filips123 filips123 moved this to In Progress in PWAsForFirefox Feb 7, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in PWAsForFirefox Feb 8, 2023
@caph1993
Copy link

caph1993 commented Nov 1, 2024

Hello. I'm in Linux and I have exactly this problem. When the app is open and I double click the app launcher a second time, a second window opens.

This is my environment:

~~ firefoxpwa --version                                                                
firefoxpwa 2.12.5

➜  ~ firefox --version                                                                   
Mozilla Firefox 131.0.3

➜  ~ uname -a && lsb_release -a 2>/dev/null | grep 'Description'
Linux lat7310 6.11.5-1-default #1 SMP PREEMPT_DYNAMIC Wed Oct 23 04:27:11 UTC 2024 (b4e3aa9) x86_64 x86_64 x86_64 GNU/Linux
Description:    openSUSE Tumbleweed

As a workaround, install wmctrl, saved the following script as /usr/bin/firefoxwpa-single, give it permission to be executed and replace all the web app launchers in ~/.local/share/applications to point to /usr/bin/firefoxwpa-single instead of /usr/bin/firefoxwpa. A bit awful as a solution, but it does the job.

#!/usr/bin/python
import sys, subprocess

cmd = ["firefoxpwa"] + sys.argv[1:]

if sys.argv[1:3] == ["site", "launch"] and len(sys.argv) >= 4:
    code = sys.argv[3]
    # Check if there is an open window with the app code
    stdout = subprocess.check_output(["wmctrl", "-lx"]).decode("utf-8")
    for line in stdout.split("\n"):
        if code in line:
            cmd = ["wmctrl", "-x", "-a", code]
            break

subprocess.run(cmd)

@filips123
Copy link
Owner Author

You can enable focusing the existing window in the app browser settings.

@caph1993
Copy link

caph1993 commented Nov 1, 2024

You can enable focusing the existing window in the app browser settings.

Oh, yes. I was searching everywhere in the settings of the extension, not in the browser settings inside the PWA.

Thank you, I just realized that this is also mentioned by you here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants