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

missionControlFullDesktopBar stops working occasionally #5

Open
skehlet opened this issue Jul 1, 2024 · 4 comments
Open

missionControlFullDesktopBar stops working occasionally #5

skehlet opened this issue Jul 1, 2024 · 4 comments

Comments

@skehlet
Copy link

skehlet commented Jul 1, 2024

Hello, long time user of missionControlFullDesktopBar here, thank you!

Problem: Occasionally (several times per work day) missionControlFullDesktopBar just stops working. I have to kill it and restart it and then everything is fine (for a while).

Some details:

  • I use missionControlFullDesktopBar instead of forceFullDesktopBar because I cannot turn off SPI on my work laptop.
  • I built missionControlFullDesktopBar myself for arm64 and Sonoma 14.5 using Xcode.
  • I use Hammerspoon to intercept the "F3"/Mission Control key press to launch missionControlFullDesktopBar.
  • I don't use -i because it's slow sometimes.
  • Note: -i works fine from the Terminal, similar to the behavior you described here
  • If it's useful, my hammerspoon code to call missionControlFullDesktopBar is here.
  • I have a key combo there to quickly kill and restart it
  • I don't see any logs for missionControlFullDesktopBar in /var/log/*

Thank you for years of using this tool. FYI I did try some other techniques, Hammerspoon-native stuff to wiggle the mouse, and also BTT, but missionControlFullDesktopBar is just better. If you have time to look into this, or suggestions for me to try, I'd appreciate it.

@briankendall
Copy link
Owner

I admit it's been quite a while since I've revisited this project. (I just keep SIP disabled.) Which version of macOS are you running? I ask because I can't get it to work in Ventura, which is what I'm currently running.

One possible workaround for this: can you just not run the app in daemon mode? It might be a bit slower, but hopefully still an acceptable speed.

@skehlet
Copy link
Author

skehlet commented Jul 1, 2024

Hi! Thanks for responding.

Which version of macOS are you running?

macOS 14.5 (23F79)

One possible workaround for this: can you just not run the app in daemon mode? It might be a bit slower, but hopefully still an acceptable speed.

I gave that a shot and am having a little trouble. Running missionControlFullDesktopBar with no args launches Mission Control fine. But then the second run (with -r) doesn't exit—it just hangs there, and also doesn't close Mission Control. I thought I'd poke around the code a little, so I added cleanUpAndFinish(); to app.m line 90. That makes it exit okay, but it still doesn't close Mission Control. It seems like the logic at line 84 checks how long MC has been open, but when run not as a daemon, I think it doesn't have this info (lastMissionControlInvocationTime is 0). I could be wrong!

Okay I ended up with the following, it could be wrong but seems to work:

void releaseMissionControl()
{
    double timeSince = lastMissionControlInvocationTime ? -[lastMissionControlInvocationTime timeIntervalSinceNow] : 0;
    printf("timeSince: %f\n", timeSince);
    bool alreadyInMissionControl = false;
    determineIfInMissionControl(&alreadyInMissionControl);
    printf("alreadyInMissionControl: %d\n", alreadyInMissionControl);

    if (timeSince > 0.5 && alreadyInMissionControl) {
        printf("Released mission control trigger when in mission control after adequate time!\n");
        invokeMissionControl();
        cleanUpAndFinish();
    } else if (!daemonized) {
        printf("Released mission control trigger when not daemonized!\n");
        invokeMissionControl();
        cleanUpAndFinish();
    } else {
        printf("Release: not in Mission Control or too soon after initial trigger, so not doing anything\n");
        cleanUpAndFinish();
    }
}

Now the issue is a quick press of Mission Control opens then immediately closes it. I think I could use some logic I have lying around in Hammerspoon to handle this.

@skehlet
Copy link
Author

skehlet commented Jul 1, 2024

I think you really have to run in daemon mode, otherwise there's no way to know if you should ignore release requests for quick presses. But good news, it's working better with the following. And strangely -i is working. I'll give it a try for a few days and submit a PR if it seems good:

void releaseMissionControl()
{
    double timeSince = lastMissionControlInvocationTime ? -[lastMissionControlInvocationTime timeIntervalSinceNow] : 0;
    printf("timeSince: %f\n", timeSince);
    bool alreadyInMissionControl = false;
    determineIfInMissionControl(&alreadyInMissionControl);
    printf("alreadyInMissionControl: %d\n", alreadyInMissionControl);

    if (!alreadyInMissionControl) {
        printf("Release: not in Mission Control, so not doing anything\n");
    } else {
        if (!daemonized) {
            // when not daemonized, we have no idea what timeSince is, so just do as instructed
            printf("Released mission control trigger when not daemonized!\n");
            invokeMissionControl();
        } else {
            if (timeSince > 0.5) {
                printf("Released mission control trigger when in mission control after adequate time!\n");
                invokeMissionControl();
            } else {
                printf("Release: too soon after initial trigger, so not doing anything\n");
            }
        }
    }

    cleanUpAndFinish();
}

@briankendall
Copy link
Owner

Sounds good. I don't see anything wrong with that change. It at least means that the -r flag will do something even when not daemonized. You're correct that previously it just did nothing when not running as a daemon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants