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

Option to start Cryptomator in background (system tray etc) incl. auto start on startup #418

Closed
overheadhunter opened this issue Dec 19, 2016 · 33 comments
Labels
state:has-workaround There is a known workaround for the described problem type:feature-request New feature or request
Milestone

Comments

@overheadhunter
Copy link
Member

overheadhunter commented Dec 19, 2016

Once issue #40 is resolved, it would be nice to have an option to start Cryptomator in "hidden" mode.

User story:

After booting my computer I don't want to interact with Cryptomator (not even closing the window), but I want it to mount the drives that I have marked for auto unlock.

Workaround
As pointed out in this comment, it is currently already possible to configure Cryptomator like this manually.

@tobihagemann
Copy link
Member

Just wanted to add that this issue doesn't only include the option to start in hidden mode but also that Cryptomator can be automatically started on startup.

@tobihagemann tobihagemann changed the title Option to start Cryptomator in background (system tray etc) Option to start Cryptomator in background (system tray etc) incl. auto start on startup Aug 6, 2017
@daylightbrightledlight
Copy link

daylightbrightledlight commented Aug 31, 2017

I would like to see this feature on macOS.
The app doesn't enter backgrounding mode when there are no unlocked vaults (see #346). The app should not automatically quit when closing the main window.

@lhagan
Copy link

lhagan commented Sep 3, 2017

On Windows, closing the Cryptomator window exits the application and unmounts any vaults without asking for confirmation. At a minimum, I think a dialog box would be nice to prevent this from happening by accident, but of course it would be even better Cryptomator minimized to the tray and continued running in the background.

@markuskreusch
Copy link
Contributor

@lhagan

Cryptomator should actually minimize to the tray when the window is closed and any vaults are unlocked. Just checked this and currently it really unmounts all vaults and exists when closing. @overheadhunter did we change this behaviour for some reason or is this a bug?

@0x4a
Copy link

0x4a commented Oct 11, 2017

I see some inconsistent behavior on Win7 here: I'm like 100% sure that the first time I tried it, closing the window quit cryptomator and unmounted the vault. After starting it again, it now minimizes to tray, without unmounting the vault. Can't reproduce.

@what2345
Copy link

what2345 commented Nov 2, 2017

I love Cryptomator, but I needed to be able to start it silently in the tray before I can use it for my everyday purposes.
In the meantime, I made a workaround for Windows using AutoIt3 if anyone is interested:

#NoTrayIcon

; Runs Cryptomator hidden.
#include <File.au3>
#include <MsgBoxConstants.au3>


Func Basename($Path)
   Local $Drive, $Dir, $FName, $Ext
   _PathSplit($Path, $Drive, $Dir, $FName, $Ext)
   Return $FName & $Ext
EndFunc


; Settings
$CRYPTOMATOR_PATH = "C:\Program Files\Cryptomator\Cryptomator.exe"
$CRYPTOMATOR_WINDOW = "[Title:Cryptomator]"
$MAX_RETRIES = 10
$RETRY_WAIT = 3000 ; milliseconds


If ProcessExists(Basename($CRYPTOMATOR_PATH)) Then
	; MsgBox($MB_SYSTEMMODAL, "", "Cryptomator is already running.")
	ConsoleWrite("Cryptomator is already running." & @CRLF)
	Exit
EndIf

ConsoleWrite("Starting Cryptomator." & @CRLF)
For $I = 0 To ($MAX_RETRIES - 1) Step 1
	ConsoleWrite("Attempt " & ($I + 1) & " of " & $MAX_RETRIES & @CRLF)
	$Pid = Run($CRYPTOMATOR_PATH, "", @SW_HIDE)

	If $Pid <> 0 Then
		ConsoleWrite("PID: " & $Pid & @CRLF)

		WinWait($CRYPTOMATOR_WINDOW, "", 20)
		WinClose($CRYPTOMATOR_WINDOW)

		WinWaitClose($CRYPTOMATOR_WINDOW, "", 20)
		WinSetState($CRYPTOMATOR_WINDOW, "", @SW_SHOW)

		; On window exit, Cryptomator will occasionally exit completely instead of minimizing to tray.
		; This is a test for that bug.
		If Not WinExists($CRYPTOMATOR_WINDOW) And ProcessExists($Pid) Then
			; MsgBox($MB_SYSTEMMODAL, "", "Cryptomator started.")
			ConsoleWrite("Cryptomator successfully started." & @CRLF)
			ExitLoop
		EndIf
	EndIf

	ConsoleWrite("Attempt failed." & @CRLF)
	Sleep($RETRY_WAIT)
Next

After installing Autoit, you can compile the script and add it to your "Startup" folder in your start menu. Then Cryptomator will auto-start on boot, in the tray, without interaction.


I also got the "exit instead of closing to tray" bug when I was testing this script (Win 10 x64). I don't see any pattern to its occurrence and I can't consistently reproduce the issue. My script just loops 10 times and retries if Cryptomator auto-exited instead of minimizing to tray.

@0x4a
Copy link

0x4a commented Nov 2, 2017

Thats a nice workaround, will port this to Autohotkey!

@h-town
Copy link

h-town commented Nov 6, 2017

@0x4a please do, and please post it! 💯

@0x4a
Copy link

0x4a commented Nov 7, 2017

Here we go:

#SingleInstance, Force
#NoEnv
#NoTrayIcon

CRYPTOMATOR_PATH := "C:\Program Files\Cryptomator\Cryptomator.exe"
MAX_RETRIES := 10
RETRY_WAIT := 3000 ; milliseconds

SplitPath, CRYPTOMATOR_PATH, CRYPTOMATOR_EXE
Process, Exist, %CRYPTOMATOR_EXE%

If ErrorLevel > 0
{
;  Msgbox, Cryptomator already running
  Exit
}
Else
{
  counter := 0
  Loop, %MAX_RETRIES%
  {
    counter := counter + 1
    Run, %CRYPTOMATOR_PATH%, , , PID
    WinWait, ahk_pid %PID%
    WinClose, ahk_pid %PID%
    WinWaitClose, ahk_pid %PID%
    Sleep, %RETRY_WAIT%
    Process, Exist, %PID%
    If ErrorLevel > 0
    {
;      Msgbox,started + minimized
      Exit
    }
    Else
    {
;      Msgbox,Retry: %counter%
      Sleep, %RETRY_WAIT%
    }
  }
}

This is more or less a direct copy of @what2345's work, should do exactly the same, works for me.

Please report back!

@h-town
Copy link

h-town commented Nov 7, 2017

@0x4a dude...already?! copy or not, what are the chances of me scouring the tubes looking for such a thing only to stumble across your comment on github left 4 days prior to my arrival, and subsequently see you put something together before the clock strikes midnight same day?! you can't make this stuff up! YOU DA REAL HERO! thanks!

@0x4a
Copy link

0x4a commented Nov 7, 2017

@h-town you're welcome mate! You just had real good timing ;)

So does it work for you? I can not reproduce the "closing does not minimize to tray"-bug at the moment, so the part where execution is retried is completely untested...

@what2345 is the MVP here, he came up with the idea & execution. I just ported it...

What we now need is a REAL HERO, who can fix the problem in the application itself, instead of MacGuyvering a way around :D

@h-town
Copy link

h-town commented Nov 7, 2017

@0x4a it's loaded up but i haven't had a chance (read: time) to reboot just yet. if it doesn't work i'll report back and try to do some hacking on it myself.

oh the things we spend so much time on to avoid the 1 second inconvenience of minimizing a window! ;)

@0x4a
Copy link

0x4a commented Nov 8, 2017

Didn't try it with a real reboot neither. Did not work after rebooting, made some small changes to the script above, maybe this time? Did reboot one more time and it worked. Can't be bothered to reboot more ;)

@h-town
Copy link

h-town commented Dec 18, 2017

@0x4a i couldn't get the AHK version to work :(

by chance have you had any success?

@0x4a
Copy link

0x4a commented Dec 18, 2017

@h-town where/how is it failing?
Works fine for me, have you made sure you're using the updated version (above)?

@h-town
Copy link

h-town commented Dec 18, 2017

@0x4a it's just not kicking off at all (updated version was used). cryptomator will execute on startup but the window remains on top. what i haven't tried:

  1. moving script closer to top of script file (i've seen this help with others)
  2. uncommenting the script execution comment boxes at certain stages (probably next step)
  3. allowing script to execute cryptomator rather than windows startup (and subsequent discovery by AHK)
  4. crack cocaine (i heard that's some nasty stuff yo)

@0x4a
Copy link

0x4a commented Dec 18, 2017

@h-town:

  1. seems like you are running the script from another script, or what do you want to move where? try running it standalone? I just put it into the autostart-folder.
  2. always a good idea!
  3. that's the way intended: run cryptomator from the script, put the script in startup.
  4. yep, keep that and heroin on your list of things to stay away from!

@hector
Copy link

hector commented Mar 19, 2018

I found an easy solution for Mac OSX for now.

  1. Set Cryptomator to auto-start
  2. Set cryptomator to auto-mount a valut at login. (This might not be necessary)
  3. Add cryptomator to your user login items (in preferences) as a hidden item. Detailed instructions

That's it! @

@markuskreusch markuskreusch added the state:has-workaround There is a known workaround for the described problem label Mar 19, 2018
@overheadhunter overheadhunter modified the milestones: 1.4.0, 1.5.0 Mar 23, 2018
@hector
Copy link

hector commented Apr 4, 2018

I don't know if Cryptomator updated or something (I have version 1.3.2 1046) but my solution stopped working in a few days.

@overheadhunter
Copy link
Member Author

As you can see this issue is scheduled for 1.5.0, which will be a release solely focused on UI and desktop integration issues. Before we start development, we will have at least one more 1.4.x release, though.

@overheadhunter overheadhunter mentioned this issue Jan 21, 2019
6 tasks
@achimismaili
Copy link

achimismaili commented Feb 2, 2019

Looking forward for the next cryptomator version. :)
The current windows workaround is a bit too complicated for me and I don't have AutoIt3 installed, therefore here an alternative.

I solved it for me until 1.5.0 comes out by doing the following:

  1. Create a new text file with this content
    Get-Process cryptomator | Foreach-Object { $_.CloseMainWindow() | Out-Null }
  2. Save file with PowerShell script extension ".ps1", e.g. under C:\Users\Public\Documents\Close-Cryptomator.ps1 (If you worked in Notepad, make sure, that no ".txt" is added to the file name)
  3. Create a new basic windows scheduled task
  4. Call it "Close Cryptomator after windows start"
  5. Select trigger: "when the computer starts"
  6. Action "start a program"
  7. As Program, select "PowerShell.exe"
  8. Unter 'Add Arguments', put in '-File "[path to the saved ps1 file]"', e.g. '-File "C:\Users\Public\Documents\Close-Cryptomator.ps1"'
  9. Before clicking finish, select to open the property dialog (or open the task again, after it is finished)
  10. In properties, select tab "Triggers", select the only trigger "at startup" and click on "Edit"
  11. Check the option "Delay task for" and put in a wait time, for me, 10 seconds works fine. The time should be at least, how long it takes for your cryptomator to mount one drive.

That's it. On the next windows start, the window should disappear after the delay entered by you and all unlocked drives should be mounted.

Some additional tipps:

  • You can play with this time, if it is e.g. too short, then start perhaps with a minute. A lot of programs show up temporarily, when windows is started, as soon as they disappear after a few seconds, it is fine for me, so even a minute in there wouldn't bother me too much.
  • Before creating a file and a scheduled task, you can also first just try the command out by running it in a PowerShell console

@wwtex
Copy link

wwtex commented Mar 4, 2019

I'm on macOS and couldn't stand the extra icon in my dock, so I wrote a hidden startup solution for macOS without the extra Cryptomator icon lingering in the dock.

To use:

  1. Have Cryptomator installed in /Applications/Cryptomator.app
  2. Add the following applescript to an Automator project and export it to an *.app bundle
  3. Add the exported app bundle to startup items in System Preferences
  4. Add the exported app bundle to the whitelist in System Preferences -> Security and Privacy -> Accessibility (if the app bundle is ever modified in any way, it will need to be re-whitelisted. It's a bug of the System Preferences panel that it still displays the entry as valid even after its been invalidated by post-adding modification)
on run {input, parameters}
	if application "Cryptomator" is running then
		return null
	end if
	
	repeat 20 times
		# Runs Cryptomator hidden albeit with dock icon still displayed.
		log "Attempting to run Cryptomator."
		# run application "/Applications/Cryptomator.app"
		do shell script "open -j \"/Applications/Cryptomator.app\""
		set window_found to false
		
		tell application "System Events"
			# set visible of application process "Cryptomator" to false
			
			# Wait up to thirty seconds for Cryptomator window to appear.
			repeat 60 times
				if exists window "Cryptomator" of application process "Cryptomator" then
					log "Cryptomator window found."
					set window_found to true
					exit repeat
				end if
				
				delay 0.5
			end repeat
			
			if window_found then
				log "Closing open Cryptomator window."
				click (first button of every window of application process "Cryptomator" whose role description is "close button")
				exit repeat
			end if
		end tell
		
		# display dialog "Wait is over."
	end repeat
	
	return input
end run

@CollinChaffin
Copy link

Caution @achimismaili Powershell solution does NOT work (at least on latest builds) and will forcibly close your vaults and pop up this message:

Cryptomator_me0IbpR1AM

All this call does is the same as clicking "close" on the window - which we already know does NOT currently leave it properly minimized to the tray.

@ldrocket
Copy link

Just wanted to add that this issue needs a process that unmounts/locks the vaults when shutting down the machine. Because the application runs in background, there's no simple possibility for the user to unmount/lock a vault manually, so the application needs to do that.

Or is there already a process present that unmounts/locks all vaults when shutting down the machine without unmounting/locking them manually?

@ldrocket
Copy link

ldrocket commented Sep 11, 2019

@overheadhunter Can someone please answer to my post above? Thank you.

@overheadhunter
Copy link
Member Author

@ldrocket Taken care of in cb50b20. For remarks, please see issue #838. This issue is about starting the application.

@overheadhunter
Copy link
Member Author

Launching in background is now merged on develop in 230436b.

Still missing: Option to register Cryptomator to start after booting.

@hippotastic

This comment has been minimized.

@overheadhunter

This comment has been minimized.

@overheadhunter
Copy link
Member Author

For those of you working with Windows or macOS, please check out the 1.5.0 beta 2, which will now give your two options to

  1. open cryptomator on system start and
  2. keep the window hidden (only add a tray icon)

Bildschirmfoto 2020-01-10 um 10 25 25

Please note, that auto unlock of vaults isn't yet available in the beta, though.

@aweedman
Copy link

aweedman commented Feb 5, 2023

Do these checkboxes actually work? I'm a new user of Cryptomator. I have "Hide window" checked but the app is still opening to the taskbar when booting up. Also, if I then try to close it wants to exit out vs. minimizing to the tray.

@overheadhunter
Copy link
Member Author

I have "Hide window" checked but the app is still opening to the taskbar when booting up.

It should still work. If you encounter any issues, this might be a bug. Please open a bug report with more details on your setup.

@aweedman
Copy link

I have "Hide window" checked but the app is still opening to the taskbar when booting up.

It should still work. If you encounter any issues, this might be a bug. Please open a bug report with more details on your setup.

Thanks. I figured it out. If you also uncheck "Show Tray Icon" then it just closes the app instead of minimizing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:has-workaround There is a known workaround for the described problem type:feature-request New feature or request
Projects
None yet
Development

No branches or pull requests