diff options
Diffstat (limited to 'AutoStart.hs')
-rw-r--r-- | AutoStart.hs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/AutoStart.hs b/AutoStart.hs new file mode 100644 index 0000000..dc022df --- /dev/null +++ b/AutoStart.hs @@ -0,0 +1,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 + [] |