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!
This commit is contained in:
parent
ea6fdc745f
commit
19b8bcbe30
7 changed files with 45 additions and 7 deletions
|
@ -3,6 +3,7 @@
|
|||
- http://standards.freedesktop.org/basedir-spec/latest/
|
||||
- http://standards.freedesktop.org/desktop-entry-spec/latest/
|
||||
- http://standards.freedesktop.org/menu-spec/latest/
|
||||
- http://standards.freedesktop.org/icon-theme-spec/latest/
|
||||
-
|
||||
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
|
@ -16,6 +17,7 @@ module Utility.FreeDesktop (
|
|||
writeDesktopMenuFile,
|
||||
desktopMenuFilePath,
|
||||
autoStartPath,
|
||||
iconFilePath,
|
||||
systemDataDir,
|
||||
systemConfigDir,
|
||||
userDataDir,
|
||||
|
@ -34,6 +36,7 @@ import System.Directory
|
|||
import System.FilePath
|
||||
import Data.List
|
||||
import Data.String.Utils
|
||||
import Data.Maybe
|
||||
import Control.Applicative
|
||||
|
||||
type DesktopEntry = [(Key, Value)]
|
||||
|
@ -54,18 +57,19 @@ toString (ListV l)
|
|||
where
|
||||
escapesemi = join "\\;" . split ";"
|
||||
|
||||
genDesktopEntry :: String -> String -> Bool -> FilePath -> [String] -> DesktopEntry
|
||||
genDesktopEntry name comment terminal program categories =
|
||||
genDesktopEntry :: String -> String -> Bool -> FilePath -> Maybe String -> [String] -> DesktopEntry
|
||||
genDesktopEntry name comment terminal program icon categories = catMaybes
|
||||
[ item "Type" StringV "Application"
|
||||
, item "Version" NumericV 1.0
|
||||
, item "Name" StringV name
|
||||
, item "Comment" StringV comment
|
||||
, item "Terminal" BoolV terminal
|
||||
, item "Exec" StringV program
|
||||
, maybe Nothing (item "Icon" StringV) icon
|
||||
, item "Categories" ListV (map StringV categories)
|
||||
]
|
||||
where
|
||||
item x c y = (x, c y)
|
||||
item x c y = Just (x, c y)
|
||||
|
||||
buildDesktopMenuFile :: DesktopEntry -> String
|
||||
buildDesktopMenuFile d = unlines ("[Desktop Entry]" : map keyvalue d) ++ "\n"
|
||||
|
@ -89,6 +93,17 @@ autoStartPath :: String -> FilePath -> FilePath
|
|||
autoStartPath basename configdir =
|
||||
configdir </> "autostart" </> desktopfile basename
|
||||
|
||||
{- Path to use for an icon file.
|
||||
- The resolution is something like "48x48" or "scalable". -}
|
||||
iconFilePath :: FilePath -> String -> Bool -> IO FilePath
|
||||
iconFilePath file resolution systemwide
|
||||
| systemwide = return $ systemDataDir </> "icons" </> subpath
|
||||
| otherwise = do
|
||||
home <- myHomeDir
|
||||
return $ home </> ".icons" </> subpath
|
||||
where
|
||||
subpath = "hicolor" </> resolution </> "apps" </> file
|
||||
|
||||
desktopfile :: FilePath -> FilePath
|
||||
desktopfile f = f ++ ".desktop"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue