Skip to content
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

KTailctl can be started multiple times in Flatpak #325

Open
Justinzobel opened this issue Dec 8, 2024 · 5 comments · Fixed by #331
Open

KTailctl can be started multiple times in Flatpak #325

Justinzobel opened this issue Dec 8, 2024 · 5 comments · Fixed by #331
Assignees
Labels
enhancement New feature or request

Comments

@Justinzobel
Copy link

I can open multiple instances of the application.

Not sure if it is Flatpak specific but a quick check to see if the app is already open would be nice to add.

@f-koehler f-koehler changed the title KTailCtl can be started multiple times in Flatpak KTailctl can be started multiple times in Flatpak Dec 9, 2024
@f-koehler
Copy link
Owner

I thought that it behaves like that already (last time I checked on KDE Plasma with the flatpak version). But definitely can be started multiple times on other desktops...

Need to figure out a solution to this. Other KDE apps (e.g. kasts) can only be started once even if installed as a flatpak. One solution would be using QSharedMemory but that would probably required additional flatpak permssions (such as --device=shm). I will have to investigate how other apps achieve this without this shared memory hack.

@f-koehler f-koehler self-assigned this Dec 9, 2024
@f-koehler f-koehler added the enhancement New feature or request label Dec 9, 2024
@Justinzobel
Copy link
Author

I've asked the Kasts dev if they can pop in and provide any insight.

@code8buster
Copy link
Contributor

At the end of main.cpp of the KDE plasma-welcome application, there is a snippet that makes the welcome center single-instance. Perhaps a similar technique can be used to register ktailctl with kdbus
https://github.com/KDE/plasma-welcome/blob/master/src/main.cpp#L115

    // Make it single-instance so it raises e.g. when middle-clicking on taskmanager
    // or accidentally launching it while it's already open
    KDBusService service(KDBusService::Unique);
    QObject::connect(&service, &KDBusService::activateRequested, &engine, [&engine](const QStringList & /*arguments*/, const QString & /*workingDirectory*/) {
        const auto rootObjects = engine.rootObjects();
        for (auto obj : rootObjects) {
            auto view = qobject_cast<QQuickWindow *>(obj);
            if (view) {
                KWindowSystem::updateStartupId(view);
                KWindowSystem::activateWindow(view);
                return;
            }
        }
    });

@f-koehler
Copy link
Owner

@code8buster, thank you for the hint. That could be a potential solution! (Even though not all KDE Apps seem to do it that way). I will test it out, looks like the behavior we want.

@f-koehler
Copy link
Owner

f-koehler commented Jan 3, 2025

Maybe not fully fixed yet:

          This seems to have worked for not starting multiple instances, but in testing the master branch I've noticed that it doesn't open the window when KTail is in-tray or even simply minimized.

Originally posted by @code8buster in #331 (comment)

@f-koehler f-koehler reopened this Jan 3, 2025
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

Successfully merging a pull request may close this issue.

3 participants