mhogomchungu / zuluCrypt

zuluCrypt is a front end to cryptsetup and tcplay and it allows easy management of encrypted block devices
https://mhogomchungu.github.io/zuluCrypt
Other
513 stars 60 forks source link

Load zuluCrypt into system tray at startup #175

Closed guttermonk closed 2 years ago

guttermonk commented 2 years ago

Would it be possible to add an option to load zuluCrypt at startup, and have it be minimized in the system tray? Keepass has a feature like that built into the program's settings, and I find it very helpful.

I tried adding zuluCrypt to my Startup Application in Ubuntu with a --minimize but zuluCrypt doesn't appear to have that switch. Also, just adding it to my Startup Applications caused the tray icon to not load. Not sure if it's possible, since it prompts me for my root password when the program starts, but this would be a nice feature.

Thank you!

mhogomchungu commented 2 years ago

The options is -e so the command to add is zuluCrypt-gui -e

guttermonk commented 2 years ago

When I add that command to my Startup Applications, it causes the process to launch in the background but it doesn't show in the tray. This is odd because when I run the same command from terminal, after I've booted, it behaves as expected.

mhogomchungu commented 2 years ago

I do not know how to solve this, if you look at the code here[1], you will see that zuluCrypt first asks if the system tray is available and it shows the tray icon if it is, if it is not available, it then re asks the question 5 times on one second intervals if the system tray is available or not before giving up.

I suspect what is happening here is that at login, zuluCrypt is getting told that the system tray is available when it is not yet and zuluCrypt ends up showing the icon prematurely.

[1] https://github.com/mhogomchungu/zuluCrypt/blob/4edd9bf363ddef44dd4013bc52e6ff2c71de2399/zuluCrypt-gui/utility.cpp#L2024-L2054

guttermonk commented 2 years ago

I was able to use a python script from this Stack answer from fermmm to load the program into the tray at startup: https://askubuntu.com/a/1133211

I added this command to a startup script: python3 ~/Programs/startup_closed.py -hide -c /usr/bin/zuluCrypt-gui

And then added the startup script to my Startup Applications.

Would it be possible to copy the "load at startup" option from KeepassXC and add it to the Zulucrypt options menu? Not sure how KeepassXC goes about loading on startup, but it might be worth a look. Regardless, having a check box in the options menu for that would make it more noob friendly. Love the program BTW.

mhogomchungu commented 2 years ago

Thank you and i will look into how KeepassXC does it.

mhogomchungu commented 2 years ago

I forgot to ask, what desktop environment are you using?

if GNOME, what extension are you using to show the tray icon.

The keepassxc code that shows the tray icon is here[1] and they do the following:-

  1. Show the tray icon
  2. Check if it is visible and if not then wait for 5 seconds and then go to step 1 above if number of attempts to show the tray icon is less than 5.

[1] https://github.com/keepassxreboot/keepassxc/blob/5916a8f8dd93eb6a5de544caedd7a9d8e9a3b1ee/src/gui/MainWindow.cpp#L1438-L1448

mhogomchungu commented 2 years ago

My new code now looks like below and it closely resembes the keepassxc and it does the following:-

  1. It shows the icon and then goes to sleep for 2 seconds.
  2. it wakes up and check if the icon is visible or not and if it is not then it shows it and goes back to sleep for 2 seconds again.
  3. The above process repeats upto 5 times.

Keepassxc does it 5 times on 5 seconds intervals and zuluCrypt does it 5 times on 2 seconds intervals. https://github.com/mhogomchungu/zuluCrypt/blob/48e982e5103acdc5da06632ea0ba4b3df11d4b42/zuluCrypt-gui/utility.cpp#L2018-L2045

mhogomchungu commented 2 years ago

Marking this one as closed but feel free to comment if the issue is still present.

guttermonk commented 2 years ago

Thank you!