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

macOS - option to hide dock icon #1334

Closed
woj-tek opened this issue Dec 28, 2017 · 45 comments · Fixed by #4782
Closed

macOS - option to hide dock icon #1334

woj-tek opened this issue Dec 28, 2017 · 45 comments · Fixed by #4782
Assignees

Comments

@woj-tek
Copy link

woj-tek commented Dec 28, 2017

Currently it's possible to show tray icon (the one next to clock) but dock icon still remains. It would be great to be able to hide dock icon and let KeePassXC run "in the background" (only with tray icon)

Expected Behavior

Select "Show system tray icon", add another option "Hide dock icon" to the group of this options

Current Behavior

We have two icons now if we enabled mentioned option. The dock icon could be shown when the window is visible though.

Context

This could limit the clutter in the dock. Long running application are better situated in the tray instead of dock/taskbar.

Debug Info

KeePassXC - Version 2.2.4
Revision: 4723f66

Libraries:

  • Qt 5.9.1
  • libgcrypt 1.8.1

Operating system: macOS High Sierra (10.13)
CPU architecture: x86_64
Kernel: darwin 17.3.0

Enabled extensions:

  • KeePassHTTP
  • Auto-Type
  • YubiKey
@woj-tek
Copy link
Author

woj-tek commented Dec 30, 2017

I'm not sure about macOS - in windows you can have similar behaviour - only show application in tray without taskbar item. I'm fairly sure that in Linux this works in similar fashion.

@bannmann
Copy link

One example of a widely-used app that does this is Google Drive.

@woj-tek
Copy link
Author

woj-tek commented Jan 23, 2018

Quite a lot of apps do this - yet another example would be DrobBox.

@beck
Copy link

beck commented May 11, 2018

This ticket is especially important for keeping browser integration without adding noise to alt-tab.

@MZLAKg2aGGFs8yi
Copy link

Another Example is Onedrive. This is important for someone who want to keep their dock clean, like me.

@droidmonkey
Copy link
Member

droidmonkey commented Aug 30, 2018

First off, the examples given are NOT applications, they are services. The little popup you see when you click the icon is just a modal window, not an app window. That is why its not visible in the task bar.

Second, you can minimize KeePassXC to tray and keep it there while still using AutoType and Browser integration. I do not think it is even possible to hide from the taskbar from our application. That is typically an OS or window manager concern.

Im not a Mac user so I dont know what the limitations are with their icons.

@woj-tek
Copy link
Author

woj-tek commented Aug 30, 2018

First of - if you use KeePassXC mostly (only) as a service to keep passwords for browsers then... it's a service (I kinda stopped using KeePassXC because was annoyed by the dock icon and quite frequent, unintentional switching to it when changing apps)

Secondly - you may be able to minimize to try under different OSs, but as you stated - you are not a macOS user and the whole point of this ticket is that - it's not possible to minimise app to try currently (there is a workaround with PlistInfo modification, but it's very brittle and doesn't work well).

I tried tinkering with it myself, but unfortunately it went over my head.

@droidmonkey
Copy link
Member

droidmonkey commented Aug 30, 2018

Would this work for you: http://ghosttile.kernelpanic.im

This code snippet might help implement the desired behavior. When the app is supposed to be minimized to tray (like in windows), we should hide the dock icon.

https://gist.github.com/TomLiu/7837127

Technically Qt should be doing this for us.

You can also try setting the environment variable QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM to 1 which should prevent the app from ever creating a dock icon. See https://bugreports.qt.io/browse/QTBUG-29197

And yes, there is a huge difference between background (ie service) applications and foreground applications. The definition doesn't change depending on how you use it, this is an OS distinction.

@phoerious
Copy link
Member

We should implement normal macOS behaviour which is to only close the window, but keep the app running when the window close button is pressed. We kind of have that already, but it requires explicit configuration.

@woj-tek
Copy link
Author

woj-tek commented Aug 30, 2018

@droidmonkey - I'll try those patches

@phoerious - currently close window button closes the window (and it works correctly) - macOS has little bit different notion of application/windows: you can have running application without any window (not minimised - window widget/document completely destroyed), AFAIR it contradicts windows/linux where if you run the app you have the document and (in majority of the times) if you close last document you close the application altogether.

@phoerious
Copy link
Member

You can enable the tray icon and then the option to hide the window instead of closing everything.

@praveendhawan
Copy link

Are there any updates on this?

@droidmonkey
Copy link
Member

Not this in particular, but we did fix interaction with the app during browser extension use. The window will properly re-hide itself and stay out of alt+tab.

@woj-tek
Copy link
Author

woj-tek commented Feb 11, 2019

@praveendhawan I played a bit with it without much luck (lack of c/qt experience I guess).

@droidmonkey I appreciate all the work to improve compatibility with macos, unfortunately this is unrelated to this particular issue :-)

@peacetype
Copy link

I'm interested in the inverse of this behavior... I'd like to see the system tray icon gone but the dock icon remain. Do you think others might be interested in this as a separate feature request?

@droidmonkey
Copy link
Member

You can just disable the tray icon in settings.

@peacetype
Copy link

@droidmonkey Unfortunately, disabling that option also disables the 3 sub-options that are dependant on it.

I like how you can close the KeePassXC window to hide it and the app keeps running and can be made visible again by clicking the dock icon. I just wish that feature did not require adding another icon to my already-cluttered system tray. I know other apps like iTunes and Photoshop have this behavior without adding an icon to the system tray.

@droidmonkey
Copy link
Member

I'll play around with this on our test Mac to see if there is an easy solution. Those three sub options are mainly for windows and Linux envs.

@peacetype
Copy link

@droidmonkey Sweet! If I knew more about C++ and Mac development I might even try messing with it myself but its way over my head. I'm just getting started with self-teaching programming and learning iOS development.

This app is amazing btw. I've missed Keepass ever since I switched over from Windows. Never could find a good Mac version. This cross-platform approach is terrific!

@TCB13
Copy link

TCB13 commented Mar 10, 2019

I was reading the comments above and usually in macOS to hide a running App from the Dock you need to add the following to Info.plist:

<key>LSUIElement</key>
<string>1</string>

Can't it be done programmatically in Qt? I tried this in my installed App and it works.

@woj-tek
Copy link
Author

woj-tek commented Mar 12, 2019

@TCB13 - I played with it a bit and while it hides icon from the dock it messes up the interaction with KeePass - in the end I had to force-close it because I wasn't able to restore the window. Maybe recent changes to improve compatibility would help with the situation.

However, adding it to Info.plist would make it non-optional, which may be a problem for some.

@TCB13
Copy link

TCB13 commented Mar 12, 2019

@woj-tek you just need to add it to the menu on top (next to the clock), and you can always get it back.

@TCB13
Copy link

TCB13 commented Mar 12, 2019

image

Works just fine for me.

@woj-tek
Copy link
Author

woj-tek commented Mar 12, 2019

Have you tried it? Because as I said - I was playing with it a bit and while at the beginning it was working ok I had to revert it because it broke later on...

@TCB13
Copy link

TCB13 commented Mar 12, 2019

@woj-tek I've been using it for a week or so, no trouble at all. :)

@TCB13
Copy link

TCB13 commented Mar 12, 2019

@woj-tek have a look at my current settings:

image

@TCB13
Copy link

TCB13 commented Mar 12, 2019

@woj-tek ,

However, adding it to Info.plist would make it non-optional, which may be a problem for some.

I wasn't asking for it to be permanent. We could have a default like:

<key>LSUIElement</key>
<string>0</string>

Then, if user turns on "hide window to system tray when minimized" it could change it to:

<key>LSUIElement</key>
<string>1</string>

This way it would be optional and consistent with the current Windows experience.

@woj-tek
Copy link
Author

woj-tek commented Mar 12, 2019

OK, I know what was my issue - I also store some passwords for other applications that don't provide interaction with KeePassXC and with LSUIElement the application in "shown state" doesn't show up in alt-tab so if you want to get some secret to other app ypu have to toggle KeePassXC, copy it and then if you want to go back to KeePassXC you have to click twice on toggle in the menu.

@TCB13
Copy link

TCB13 commented Mar 12, 2019

@woj-tek interesting, I don't have that use case indeed. Anyway, what do you think about toggling LSUIElement on Hide window to system tray when minimized?

@woj-tek
Copy link
Author

woj-tek commented Mar 12, 2019

I'm not sure that this option should be toggled altogether. IMHO there should be a better way to handle it via Qt.

@TCB13
Copy link

TCB13 commented Mar 12, 2019

Hmm... but toggling LSUIElement is something native to the Apple platform that works reliably and is used by many apps. A Qt solution would fall more into a slight hack.

Some examples:

  • Dropbox:
    image

  • Viscosity VPN:
    image

  • Dropzone 3:
    image

Anyway, thank you for you feedback. Keep up the great work!

@woj-tek
Copy link
Author

woj-tek commented Mar 13, 2019

In that case that may be a viable option - hopefully developers would consider it :-)

@2young-2simple-sometimes-naive

LSUIElement also remove it from command+tab selection. A perfect behavior should be like onedrive. You can open Onedrive settings and still see it in command+tab, while it is indeed minimized to system tray.

@TCB13
Copy link

TCB13 commented Mar 13, 2019

@xvrxq52Dm6Pu and... that kind of “perfect behaviors” is exactly why Microsoft’s apps for Mac are all full of UI glitches, crashes and others problems - instead of going with native solutions for common problems (that work reliable and in an expected way) they hack stuff around.

@marothe
Copy link

marothe commented May 29, 2019

I tried the workaround - and it worked: there is no dock-symbol but only a tray icon. But, now I cannot use auto-type any longer, only if I delete the two lines of code from the Info.plist.
Is there really no real workaround? And why are the developers not implementing this easy feature?

@konrad-a
Copy link

I have the same usability issue - is there a way to hide the dock icon and have the auto-type working?

@TCB13
Copy link

TCB13 commented Jun 19, 2019

@marothe @konrad-a I don't use auto-type so I can't comment on it.

@marothe
Copy link

marothe commented Jun 19, 2019

@konrad-a I got used to the symbol in the dock...hope I can get rid of it in the future.

@semihcanturk
Copy link

What I've tried is toggling the LSUIElement from Terminal (essentially the same operation with altering Info.plist manually), and then re-signing the application to avoid crashing on startup:

defaults write /Applications/KeePassXC.app/Contents/Info LSUIElement 1
sudo codesign -f -s - /Applications/KeePassXC.app

Works for me for the time being.

@janprzy
Copy link

janprzy commented Feb 2, 2020

What I've tried is toggling the LSUIElement from Terminal (essentially the same operation with altering Info.plist manually), and then re-signing the application to avoid crashing on startup:

defaults write /Applications/KeePassXC.app/Contents/Info LSUIElement 1
sudo codesign -f -s - /Applications/KeePassXC.app

Works for me for the time being.

I can confirm that this works for me too. Maybe making it the default should be considered.

I see no point in having a dock icon when accessing passwords through a browser extension. Especially when the menu bar icon is enabled, the dock icon just provides pointless redundancy. Maybe only hide it when the menu bar icon is enabled?

@konrad-a
Copy link

I reinstalled by MacOs and ended up googling this issue again.
Yes, the workaround works, but could it be included in one of future releases?
defaults write /Applications/KeePassXC.app/Contents/Info LSUIElement 1 sudo codesign -f -s - /Applications/KeePassXC.app

@droidmonkey
Copy link
Member

@phoerious is this something we can add to 2.6?

@phoerious
Copy link
Member

I thought that's already possible when the tray is enabled?

@phoerious
Copy link
Member

I stand corrected. The dock icon is still showing, even when pressing the close button. Lemme see if I can fix that.

phoerious added a commit that referenced this issue May 26, 2020
Transforms application into a UIElement agent app when
minimize to tray is enabled and the window is hidden.
This hides the dock icon and removes the application
from the Cmd+Tab listing. The changes work well together
with macOS's inbuilt hide feature.

Also fixes the buggy tray icon context menu trigger behaviour.
macOS triggers the tray context menu also on normal left
click, which causes the window to toggle at the same time
as the menu. To fix this, window toggling has been disabled
altogether on macOS and users will be shown only the context
menu from now on.

Fixes #1334
@phoerious
Copy link
Member

Changing the plist file is not something you want or can do at runtime, especially not with a signed app. There are other system APIs to achieve the same effect. I proposed a fix, which should resolve this issue and overall improve the tray icon experience.

phoerious added a commit that referenced this issue May 26, 2020
Transforms application into a UIElement agent app when
minimize to tray is enabled and the window is hidden.
This hides the dock icon and removes the application
from the Cmd+Tab listing. The changes work well together
with macOS's inbuilt hide feature.

Also fixes the buggy tray icon context menu trigger behaviour.
macOS triggers the tray context menu also on normal left
click, which causes the window to toggle at the same time
as the menu. To fix this, window toggling has been disabled
altogether on macOS and users will be shown only the context
menu from now on.

Fixes #1334
phoerious added a commit that referenced this issue May 27, 2020
Transforms application into a UIElement agent app when
minimize to tray is enabled and the window is hidden.
This hides the dock icon and removes the application
from the Cmd+Tab listing. The changes work well together
with macOS's inbuilt hide feature.

Also fixes the buggy tray icon context menu trigger behaviour.
macOS triggers the tray context menu also on normal left
click, which causes the window to toggle at the same time
as the menu. To fix this, window toggling has been disabled
altogether on macOS and users will be shown only the context
menu from now on.

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

Successfully merging a pull request may close this issue.