{- OSX stuff - - Copyright 2012 Joey Hess - - License: BSD-2-clause -} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-tabs #-} module Utility.OSX ( autoStartBase, systemAutoStart, userAutoStart, genOSXAutoStartFile, ) where import Common import Utility.UserInfo autoStartBase :: String -> OsPath autoStartBase label = literalOsPath "Library" literalOsPath "LaunchAgents" toOsPath label <> literalOsPath ".plist" systemAutoStart :: String -> OsPath systemAutoStart label = literalOsPath "/" autoStartBase label userAutoStart :: String -> IO OsPath userAutoStart label = do home <- myHomeDir return $ toOsPath home autoStartBase label {- Generates an OSX autostart plist file with a given label, command, and - params to run at boot or login. -} genOSXAutoStartFile :: String -> String -> [String] -> String genOSXAutoStartFile label command params = unlines [ "" , "" , "" , "" , "Label" , "" ++ label ++ "" , "ProgramArguments" , "" , unlines $ map (\v -> "" ++ v ++ "") (command:params) , "" , "RunAtLoad" , "" , "" , "" ]