diff options
-rw-r--r-- | Assistant/Install.hs | 5 | ||||
-rw-r--r-- | Assistant/Install/Menu.hs | 24 | ||||
-rw-r--r-- | Build/DesktopFile.hs | 18 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | Utility/FreeDesktop.hs | 13 |
5 files changed, 36 insertions, 25 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs index 3c7d09698..dee1b5be3 100644 --- a/Assistant/Install.hs +++ b/Assistant/Install.hs @@ -49,8 +49,9 @@ ensureInstalled = go =<< standaloneAppBase #ifdef darwin_HOST_OS autostartfile <- userAutoStart osxAutoStartLabel #else - installMenu program - =<< desktopMenuFilePath "git-annex" <$> userDataDir + menufile <- desktopMenuFilePath "git-annex" <$> userDataDir + icondir <- iconDir <$> userDataDir + installMenu program menufile base icondir autostartfile <- autoStartPath "git-annex" <$> userConfigDir #endif installAutoStart program autostartfile diff --git a/Assistant/Install/Menu.hs b/Assistant/Install/Menu.hs index 940a2b32c..41ec855b6 100644 --- a/Assistant/Install/Menu.hs +++ b/Assistant/Install/Menu.hs @@ -9,14 +9,20 @@ module Assistant.Install.Menu where +import Common + import Utility.FreeDesktop -installMenu :: FilePath -> FilePath -> IO () -installMenu command file = +installMenu :: FilePath -> FilePath -> FilePath -> FilePath -> IO () +installMenu command menufile iconsrcdir icondir = do #ifdef darwin_HOST_OS return () #else - writeDesktopMenuFile (fdoDesktopMenu command) file + 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 @@ -27,5 +33,15 @@ fdoDesktopMenu command = genDesktopEntry "Track and sync the files in your Git Annex" False (command ++ " webapp") - (Just "git-annex") -- icon base name + (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" diff --git a/Build/DesktopFile.hs b/Build/DesktopFile.hs index f3293d128..9f4ba5992 100644 --- a/Build/DesktopFile.hs +++ b/Build/DesktopFile.hs @@ -28,7 +28,6 @@ import System.Posix.Files #endif import System.FilePath import Data.Maybe -import System.IO systemwideInstall :: IO Bool #ifndef mingw32_HOST_OS @@ -52,25 +51,14 @@ writeFDODesktop command = do systemwide <- systemwideInstall datadir <- if systemwide then return systemDataDir else userDataDir - installMenu command - =<< inDestDir (desktopMenuFilePath "git-annex" datadir) - - installIcon "doc/logo.svg" - =<< inDestDir (iconFilePath "git-annex.svg" "scalable" datadir) - installIcon "doc/favicon.png" - =<< inDestDir (iconFilePath "git-annex.png" "16x16" datadir) + menufile <- inDestDir (desktopMenuFilePath "git-annex" datadir) + icondir <- inDestDir (iconDir datadir) + installMenu command menufile "doc" icondir configdir <- if systemwide then return systemConfigDir else userConfigDir installAutoStart command =<< inDestDir (autoStartPath "git-annex" configdir) -installIcon :: FilePath -> FilePath -> IO () -installIcon src dest = do - createDirectoryIfMissing True (parentDir dest) - withBinaryFile src ReadMode $ \hin -> - withBinaryFile dest WriteMode $ \hout -> - hGetContents hin >>= hPutStr hout - writeOSXDesktop :: FilePath -> IO () writeOSXDesktop command = do installAutoStart command =<< inDestDir =<< ifM systemwideInstall @@ -107,6 +107,7 @@ linuxstandalone: Build/Standalone strip "$(LINUXSTANDALONE_DEST)/bin/git-annex" ln -sf git-annex "$(LINUXSTANDALONE_DEST)/bin/git-annex-shell" zcat standalone/licences.gz > $(LINUXSTANDALONE_DEST)/LICENSE + cp doc/favicon.png doc/logo.svg $(LINUXSTANDALONE_DEST) ./Build/Standalone "$(LINUXSTANDALONE_DEST)" diff --git a/Utility/FreeDesktop.hs b/Utility/FreeDesktop.hs index 9ed92a77b..da9d7b618 100644 --- a/Utility/FreeDesktop.hs +++ b/Utility/FreeDesktop.hs @@ -17,6 +17,7 @@ module Utility.FreeDesktop ( writeDesktopMenuFile, desktopMenuFilePath, autoStartPath, + iconDir, iconFilePath, systemDataDir, systemConfigDir, @@ -93,13 +94,17 @@ autoStartPath :: String -> FilePath -> FilePath autoStartPath basename configdir = configdir </> "autostart" </> desktopfile basename -{- Path to use for an icon file, in either the systemDataDir - - or the userDatadir. +{- Base directory to install an icon file, in either the systemDataDir + - or the userDatadir. -} +iconDir :: FilePath -> FilePath +iconDir datadir = datadir </> "icons" </> "hicolor" + +{- Filename of an icon, given the iconDir to use. - - The resolution is something like "48x48" or "scalable". -} iconFilePath :: FilePath -> String -> FilePath -> FilePath -iconFilePath file resolution datadir = datadir </> "icons" </> - "hicolor" </> resolution </> "apps" </> file +iconFilePath file resolution icondir = + icondir </> resolution </> "apps" </> file desktopfile :: FilePath -> FilePath desktopfile f = f ++ ".desktop" |