mxrlkn / mouselock

Lock mouse cursor to a centered area of the screen for MacOS.
MIT License
47 stars 6 forks source link

Show icon in menu bar instead of dock #9

Closed kjoedion closed 1 month ago

kjoedion commented 1 year ago

Just wondering if you'd be interested in this feature? I can submit a PR if you'd like.

mxrlkn commented 1 year ago

Yeah that sounds good. I'll take a PR.

Only thing I'm worried about is that you can softlock yourself if you have it on "always" and can't command+tab to mouselock to close/disable it.

Is it possible to make it a toggle option so it can still run as a regular dock app?

If that's possible I could disallow the menu bar option if "always" is on, after you make the PR.

kjoedion commented 1 year ago

I was thinking have checkboxes for "show in dock" and "show in menu bar" which are user-defined.

Also was thinking when League is minimized / hidden / tabbed away from, to automatically also tab away from mouselock. And when league is re-focused, auto refocus mouselock. This would prevent the double-tabbing requirement I noticed and you also mentioned.

Let me know what you think.

Edit: also might be cool to launch the app on login like how mouselock works.

mxrlkn commented 1 year ago

Yeah checkboxes sounds good.

I don't know what you mean by double-tabbing. As a regular dock app, I think it works good currently, because you can tab to it and close it (cmd+q). You can't focus a menubar bar app with cmd+tab, so you can't close it if your mouse is locked, in "always" mode. So I think just creating the checkboxes, so it shows as a menu bar app or dock app is fine. And then disallowing the menu bar option if it's in "always" mode. I hope that makes sense.

Edit: also might be cool to launch the app on login like how mouselock works.

You can just add it as a login item. that should work fine without any additions.

Paw2Pom commented 1 year ago

Yes, please display it on menu bar instead!

ghost commented 2 months ago

@mxrlkn making this a menubar-only app is pretty easy

https://sarunw.com/posts/swiftui-menu-bar-app/

are you still maintaining this at all or should I just fork and do it?

ghost commented 2 months ago

I figured this out in case anyone wants this to be a menubar-only app.

Just go into the main app file and change the App code to this:

@main
struct mouselockApp: App {
    @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    @StateObject var appState = AppState.shared

    var body: some Scene {
//        WindowGroup {
//            ContentView(appState: appState)
//        }

        Settings {
            ContentView(appState: appState)
        }

        MenuBarExtra("mouselock", systemImage: "computermouse") {
            SettingsLink()

            Button("Quit") {
                NSApplication.shared.terminate(nil)
            }
        }
    }
}
mxrlkn commented 1 month ago

Hi, I've been afk for a while so I didn't see your message. I'm still not comfortable to have it be a menubar app as long as it's useful for users in the "always on" mode. Cool you did it yourself instead :) (link for the interested: https://github.com/kejedi/mouselock)