write a OSX autostart file
Not tested.
This commit is contained in:
parent
835b766301
commit
5d5cd9f957
1 changed files with 36 additions and 2 deletions
|
@ -6,6 +6,8 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Build.InstallDesktopFile where
|
module Build.InstallDesktopFile where
|
||||||
|
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
|
@ -49,8 +51,8 @@ inDestDir f = do
|
||||||
destdir <- catchDefaultIO (getEnv "DESTDIR") ""
|
destdir <- catchDefaultIO (getEnv "DESTDIR") ""
|
||||||
return $ destdir </> f
|
return $ destdir </> f
|
||||||
|
|
||||||
writeDesktop :: FilePath -> IO ()
|
writeFDODesktop :: FilePath -> IO ()
|
||||||
writeDesktop command = do
|
writeFDODesktop command = do
|
||||||
datadir <- ifM isRoot ( return systemDataDir, userDataDir )
|
datadir <- ifM isRoot ( return systemDataDir, userDataDir )
|
||||||
writeDesktopMenuFile (desktop command)
|
writeDesktopMenuFile (desktop command)
|
||||||
=<< inDestDir (desktopMenuFilePath "git-annex" datadir)
|
=<< inDestDir (desktopMenuFilePath "git-annex" datadir)
|
||||||
|
@ -67,6 +69,38 @@ writeDesktop command = do
|
||||||
writeFile programfile command
|
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
|
main = getArgs >>= go
|
||||||
where
|
where
|
||||||
go [] = error "specify git-annex command"
|
go [] = error "specify git-annex command"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue