aboutsummaryrefslogtreecommitdiff
path: root/Build/InstallDesktopFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-01 21:04:25 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-01 21:05:27 -0400
commite78b13c42807f598d9dd7e449a5980c26f731f72 (patch)
treeb832bea706a7ffaa1f98214797c17dcce1f0825e /Build/InstallDesktopFile.hs
parented07546288733a13129a866ce70ea2f94d6259cb (diff)
hook desktop menu file installation into makefile and cabal
Diffstat (limited to 'Build/InstallDesktopFile.hs')
-rw-r--r--Build/InstallDesktopFile.hs39
1 files changed, 39 insertions, 0 deletions
diff --git a/Build/InstallDesktopFile.hs b/Build/InstallDesktopFile.hs
new file mode 100644
index 000000000..b4a56a2cb
--- /dev/null
+++ b/Build/InstallDesktopFile.hs
@@ -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