blob: dc022dfef8bb584538d125676d599ed7f24c14fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
{- Copyright 2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module AutoStart where
import Utility.FreeDesktop
import System.Info
import System.Environment
import System.Directory
installAutoStartFile :: IO ()
installAutoStartFile = go =<< autoStartFile
where
go (Just f) = case os of
"linux" -> installFdoAutoStart f
"freebsd" -> installFdoAutoStart f
_ -> return ()
go Nothing = return ()
isAutoStartFileInstalled :: IO Bool
isAutoStartFileInstalled = maybe (pure False) doesFileExist =<< autoStartFile
autoStartFile :: IO (Maybe FilePath)
autoStartFile = case os of
"linux" -> Just . autoStartPath "keysafe" <$> userConfigDir
_ -> return Nothing
installFdoAutoStart :: FilePath -> IO ()
installFdoAutoStart f = do
command <- getExecutablePath
writeDesktopMenuFile (fdoAutostart command) f
fdoAutostart :: FilePath -> DesktopEntry
fdoAutostart command = genDesktopEntry
"Keysafe"
"Autostart"
False
(command ++ " --autostart")
Nothing
[]
|