pkamb / PowerKey

Remap your Macbook's power key to Forward Delete
MIT License
229 stars 29 forks source link

Option to always run Powerkey in background + not to show preferences dialog #35

Closed olliebaum closed 8 years ago

olliebaum commented 8 years ago

I bought Powerkey from Gumroad about a month ago. I have it set to launch on startup and I would like it to automatically run in the background without the need for clicking the option in the preferences dialog every time. I would also like the preferences dialog not to show once this has been set.

It would therefore be helpful to have three options in the preferences window:

Obviously, users would still need a way to access the preferences should they change their mind. I think the best way to handle this would be to show the preferences whenever the Powerkey application is activated when Powerkey is already running. i.e. if you explicitly activate Powerkey while it is already running (by clicking the application icon in Finder or from Application Launcher) then it would show the preferences dialog. If the user activates Powerkey and it is not already running (e.g. on startup) then Powerkey would follow the user's chosen preference to run in the background and would not show the preferences dialog.

pkamb commented 8 years ago

The app should work like this already:

  1. Preferences shows on first launch.
  2. "Re-launching" the app always shows preferences.
  3. The next full launch will show or not show preferences based on if preferences was still open when PowerKey was last quit.

The code for that is here: https://github.com/pkamb/PowerKey/blob/master/PowerKey/PKAppDelegate.m

Are you not seeing this? Please test it out and let me know if you're seeing a different behavior and exactly what that behavior is.

Thanks!

olliebaum commented 8 years ago

The behaviour I see is different. There is no way to explicitly close the preferences window (it only has a minimise button, not a close button), but the dialog does disappear when I click "Run in background" if that's what you mean by close. However, this does not prevent the dialog from showing the next time I quit and relaunch Powerkey.

I did however manage to manually turn on the option in the preferences .plist file which prevented the dialog showing, but the app still launches in the foreground (with the icon in the dock) and then there is no way to run the application in the background without reopening the preferences dialog, and if I do that then it resets the key I changed in the .plist file.

pkamb commented 8 years ago

However, this does not prevent the dialog from showing the next time I quit and relaunch Powerkey.

How exactly are you "quitting" PowerKey in this case?

olliebaum commented 8 years ago

Ah, okay. That may have been part of the problem. I was using an Alfred workflow to quit PowerKey which used the "kill -9" shell command. If I quit the process from Activity Monitor then Powerkey doesn't show the preference window when I relaunch.

However, the PowerKey icon still shows in the dock despite me having told it to "Run in the background" last time. I would like it to remember to run in the background. Otherwise I'm going to have to open the preference window anyway to tell PowerKey to run in the background, which defeats the object of PowerKey remembering to hide the Pref window.

pkamb commented 8 years ago

Yeah, the kill -9 command would be skipping PowerKey's applicationWillTerminate: code where the flag is set to toggle the window on next run.

And thanks, it looks like there is an issue where the app icon shows in the dock when started at login in the background. I'll fix that in the next release.

olliebaum commented 8 years ago

Excellent, thank you.

rtlkennedy commented 8 years ago

Hi pkamb, looking forward to your next release fix that starts PowerKey at login in the background without an app icon in dock/app in foreground. Regards, Ruairi

pkamb commented 8 years ago

Thanks @olliebaum and @rtlkennedy - this issue has been fixed in version 1.5.1

https://github.com/pkamb/PowerKey/releases/tag/v1.5.1

The new version has been uploaded to GumRoad and should now be available for download: https://gum.co/powerkey