From 5d5cd9f9579e3e6dc5a8c5d92bdd219341a31e8b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 Sep 2012 12:58:46 -0400 Subject: [PATCH] write a OSX autostart file Not tested. --- Build/InstallDesktopFile.hs | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Build/InstallDesktopFile.hs b/Build/InstallDesktopFile.hs index cde36b7384..31771f6337 100644 --- a/Build/InstallDesktopFile.hs +++ b/Build/InstallDesktopFile.hs @@ -6,6 +6,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Build.InstallDesktopFile where import Utility.Exception @@ -49,8 +51,8 @@ inDestDir f = do destdir <- catchDefaultIO (getEnv "DESTDIR") "" return $ destdir f -writeDesktop :: FilePath -> IO () -writeDesktop command = do +writeFDODesktop :: FilePath -> IO () +writeFDODesktop command = do datadir <- ifM isRoot ( return systemDataDir, userDataDir ) writeDesktopMenuFile (desktop command) =<< inDestDir (desktopMenuFilePath "git-annex" datadir) @@ -67,6 +69,38 @@ writeDesktop command = do writeFile programfile command ) +writeOSXDesktop :: FilePath -> IO () +writeOSXDesktop command = do + home <- myHomeDir + let base = "Library" "LaunchAgents" label ++ ".plist" + autostart <- ifM isRoot ( return $ "/" base , return $ home base) + writeFile autostart $ unlines + [ "" + , "" + , "" + , "" + , "Label" + , "" ++ label ++ "" + , "ProgramArguments" + , "" + , "" ++ command ++ "" + , "assistant" + , "--autostart" + , "" + , "RunAtLoad" + , "" + , "" + ] + where + label = "com.branchable.git-annex.assistant" + +writeDesktop :: FilePath -> IO () +#ifdef darwin_HOST_OS +writeDesktop = writeOSXDesktop +#else +writeDesktop = writeFDODesktop +#endif + main = getArgs >>= go where go [] = error "specify git-annex command"