summaryrefslogtreecommitdiff
path: root/Build/DesktopFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-07-09 19:56:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-07-09 19:56:30 -0400
commitffb8a2d9d6140fb50d9d3553be923b0b8f5cffed (patch)
treeace4e7fa5a5d5f6cb225b6246d87a565b10a58af /Build/DesktopFile.hs
parenta16a6979515886f2496c5204b886dc76748a3c82 (diff)
Install XDG desktop icon files.
The icon files will be installed when running make install or cabal install. Did not try to run update-icon-caches, since I think it's debian specific, and dh_icons will take care of that for the Debian package. Using the favicon as a 16x16 icon. At 24x24 the svg displays pretty well, although the dotted lines are rather faint. The svg is ok at all higher resolutions. The standalone linux build auto-installs the desktop and autostart files when run. I have not made it auto-install the icon file too, because a) that would take more work to include them in the tarball and find them b) it would need to be an install to ~/.icons/, and I don't know if that really works!
Diffstat (limited to 'Build/DesktopFile.hs')
-rw-r--r--Build/DesktopFile.hs21
1 files changed, 18 insertions, 3 deletions
diff --git a/Build/DesktopFile.hs b/Build/DesktopFile.hs
index 3c6816e60..55a22352a 100644
--- a/Build/DesktopFile.hs
+++ b/Build/DesktopFile.hs
@@ -1,4 +1,4 @@
-{- Generating and installing a desktop menu entry file
+{- Generating and installing a desktop menu entry file and icon,
- and a desktop autostart file. (And OSX equivilants.)
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
@@ -28,6 +28,7 @@ import System.Posix.Files
#endif
import System.FilePath
import Data.Maybe
+import System.IO
systemwideInstall :: IO Bool
#ifndef mingw32_HOST_OS
@@ -48,14 +49,28 @@ inDestDir f = do
writeFDODesktop :: FilePath -> IO ()
writeFDODesktop command = do
- datadir <- ifM systemwideInstall ( return systemDataDir, userDataDir )
+ systemwide <- systemwideInstall
+
+ datadir <- if systemwide then return systemDataDir else userDataDir
installMenu command
=<< inDestDir (desktopMenuFilePath "git-annex" datadir)
- configdir <- ifM systemwideInstall ( return systemConfigDir, userConfigDir )
+ installIcon "doc/logo.svg" =<< inDestDir
+ =<< iconFilePath "git-annex.svg" "scalable" systemwide
+ installIcon "doc/favicon.png" =<< inDestDir
+ =<< iconFilePath "git-annex.png" "16x16" systemwide
+
+ 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