summaryrefslogtreecommitdiff
path: root/Build/InstallDesktopFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-09-06 12:58:46 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-09-06 12:58:46 -0400
commit5d5cd9f9579e3e6dc5a8c5d92bdd219341a31e8b (patch)
tree5c603911a752ee340749263da34688e18ccc07d7 /Build/InstallDesktopFile.hs
parent835b766301048e010af56d8945da02a9a2ace7d6 (diff)
write a OSX autostart file
Not tested.
Diffstat (limited to 'Build/InstallDesktopFile.hs')
-rw-r--r--Build/InstallDesktopFile.hs38
1 files changed, 36 insertions, 2 deletions
diff --git a/Build/InstallDesktopFile.hs b/Build/InstallDesktopFile.hs
index cde36b738..31771f633 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
+ [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ , "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">"
+ , "<plist version=\"1.0\">"
+ , "<dict>"
+ , "<key>Label</key>"
+ , "<string>" ++ label ++ "</string>"
+ , "<key>ProgramArguments</key>"
+ , "<array>"
+ , "<string>" ++ command ++ "</string>"
+ , "<string>assistant</string>"
+ , "<string>--autostart</string>"
+ , "</array>"
+ , "<key>RunAtLoad</key>"
+ , "</dict>"
+ , "</plist>"
+ ]
+ 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"