hook desktop menu file installation into makefile and cabal

This commit is contained in:
Joey Hess 2012-08-01 21:04:25 -04:00
parent ed07546288
commit e78b13c428
3 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,39 @@
{- Generating and installing a desktop menu entry file.
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Build.InstallDesktopFile where
import Utility.Exception
import Utility.FreeDesktop
import Control.Applicative
import System.Environment
import System.Posix.User
{- The command can be either just "git-annex", or the full path to use
- to run it. -}
desktop :: FilePath -> DesktopEntry
desktop command = genDesktopEntry
"Git Annex"
"Track and sync the files in your Git Annex"
False
(command ++ " webapp")
["Network", "FileTransfer"]
writeDesktop :: DesktopEntry -> IO ()
writeDesktop d = do
destdir <- catchDefaultIO (getEnv "DESTDIR") ""
uid <- fromIntegral <$> getRealUserID
dest <- if uid /= 0
then userDesktopMenuFilePath "git-annex"
else return $ systemDesktopMenuFilePath "git-annex"
writeDesktopMenuFile d dest
main = getArgs >>= go
where
go [] = error "specify git-annex command"
go (command:_) = writeDesktop $ desktop command