summaryrefslogtreecommitdiff
path: root/Assistant/Install/Menu.hs
blob: 41ec855b6978dab575e6604f08d2b6739d52ae5b (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
35
36
37
38
39
40
41
42
43
44
45
46
47
{- Assistant menu installation.
 -
 - Copyright 2013 Joey Hess <joey@kitenet.net>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

{-# LANGUAGE CPP #-}

module Assistant.Install.Menu where

import Common

import Utility.FreeDesktop

installMenu :: FilePath -> FilePath -> FilePath -> FilePath -> IO ()
installMenu command menufile iconsrcdir icondir = do
#ifdef darwin_HOST_OS
	return ()
#else
	writeDesktopMenuFile (fdoDesktopMenu command) menufile
	installIcon (iconsrcdir </> "logo.svg") $
		iconFilePath (iconBaseName ++ ".svg") "scalable" icondir
	installIcon (iconsrcdir </> "favicon.png") $
		iconFilePath (iconBaseName ++ ".png") "16x16" icondir
#endif

{- The command can be either just "git-annex", or the full path to use
 - to run it. -}
fdoDesktopMenu :: FilePath -> DesktopEntry
fdoDesktopMenu command = genDesktopEntry
	"Git Annex"
	"Track and sync the files in your Git Annex"
	False
	(command ++ " webapp")
	(Just iconBaseName)
	["Network", "FileTransfer"]

installIcon :: FilePath -> FilePath -> IO ()
installIcon src dest = do
	createDirectoryIfMissing True (parentDir dest)
	withBinaryFile src ReadMode $ \hin ->
		withBinaryFile dest WriteMode $ \hout ->
			hGetContents hin >>= hPutStr hout

iconBaseName :: String
iconBaseName = "git-annex"