summaryrefslogtreecommitdiff
path: root/Build/Desktop.hs
blob: b35b0c01049e4c0ce5c9b4d640b18d8eb9dec4f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{- 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.Desktop 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