2013-04-20 23:27:36 +00:00
|
|
|
{- Assistant menu installation.
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2013 Joey Hess <id@joeyh.name>
|
2013-04-20 23:27:36 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2013-04-20 23:27:36 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
{-# LANGUAGE CPP #-}
|
2015-05-10 20:38:49 +00:00
|
|
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
2013-04-20 23:27:36 +00:00
|
|
|
|
|
|
|
module Assistant.Install.Menu where
|
|
|
|
|
|
|
|
import Utility.FreeDesktop
|
2020-10-29 16:02:46 +00:00
|
|
|
import Utility.FileSystemEncoding
|
|
|
|
import Utility.Path
|
|
|
|
|
|
|
|
import System.IO
|
|
|
|
import Utility.SystemDirectory
|
|
|
|
import System.FilePath
|
2013-04-20 23:27:36 +00:00
|
|
|
|
2013-07-10 00:50:41 +00:00
|
|
|
installMenu :: FilePath -> FilePath -> FilePath -> FilePath -> IO ()
|
2013-04-22 15:24:48 +00:00
|
|
|
#ifdef darwin_HOST_OS
|
2013-12-15 21:10:24 +00:00
|
|
|
installMenu _command _menufile _iconsrcdir _icondir = return ()
|
2013-04-22 15:24:48 +00:00
|
|
|
#else
|
2013-12-15 21:10:24 +00:00
|
|
|
installMenu command menufile iconsrcdir icondir = do
|
2013-07-10 00:50:41 +00:00
|
|
|
writeDesktopMenuFile (fdoDesktopMenu command) menufile
|
|
|
|
installIcon (iconsrcdir </> "logo.svg") $
|
|
|
|
iconFilePath (iconBaseName ++ ".svg") "scalable" icondir
|
2014-03-16 19:50:53 +00:00
|
|
|
installIcon (iconsrcdir </> "logo_16x16.png") $
|
2013-07-10 00:50:41 +00:00
|
|
|
iconFilePath (iconBaseName ++ ".png") "16x16" icondir
|
2013-04-20 23:27:36 +00:00
|
|
|
#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")
|
2013-07-10 00:50:41 +00:00
|
|
|
(Just iconBaseName)
|
2013-04-20 23:27:36 +00:00
|
|
|
["Network", "FileTransfer"]
|
2013-07-10 00:50:41 +00:00
|
|
|
|
|
|
|
installIcon :: FilePath -> FilePath -> IO ()
|
|
|
|
installIcon src dest = do
|
2020-10-28 18:53:25 +00:00
|
|
|
createDirectoryIfMissing True (fromRawFilePath (parentDir (toRawFilePath dest)))
|
2013-07-10 00:50:41 +00:00
|
|
|
withBinaryFile src ReadMode $ \hin ->
|
|
|
|
withBinaryFile dest WriteMode $ \hout ->
|
|
|
|
hGetContents hin >>= hPutStr hout
|
|
|
|
|
|
|
|
iconBaseName :: String
|
|
|
|
iconBaseName = "git-annex"
|