xdg-desktop-entry-0.1.1.2: Parse files conforming to the xdg desktop entry spec

Copyright | 2019 Ivan Malison
License | BSD3-style (see LICENSE)
Maintainer | Ivan Malison
Stability | unstable
Portability | unportable
Safe Haskell | Safe-Inferred
Language | Haskell2010

System.Environment.XDG.DesktopEntry

Description

Implementation of version 1.2 of the freedesktop "Desktop Entry specification", see https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.2.html.

Synopsis

- data DesktopEntry = DesktopEntry {
  - deType :: DesktopEntryType
  - deFilename :: FilePath
  - deAttributes :: [(String, String)]
  }
- deCommand :: DesktopEntry -> Maybe String
- deComment :: [String] -> DesktopEntry -> Maybe String
- deHasCategory :: DesktopEntry -> String -> Bool
- deIcon :: DesktopEntry -> Maybe String
- deName :: [String] -> DesktopEntry -> String
- deNoDisplay :: DesktopEntry -> Bool
- deNotShowIn :: DesktopEntry -> [String]
- deOnlyShowIn :: DesktopEntry -> [String]
- getClassNames :: DesktopEntry -> [String]
- getDirectoryEntriesDefault :: IO [DesktopEntry]
- getDirectoryEntry :: [FilePath] -> String -> IO (Maybe DesktopEntry)
- getDirectoryEntryDefault :: String -> IO (Maybe DesktopEntry)
- getXDGDataDirs :: IO [FilePath]
- indexDesktopEntriesBy :: Foldable t => (DesktopEntry -> [String]) -> t DesktopEntry -> MultiMap String DesktopEntry
- indexDesktopEntriesByClassName :: Foldable t => t DesktopEntry -> MultiMap String DesktopEntry
- listDesktopEntries :: String -> FilePath -> IO [DesktopEntry]
- readDesktopEntry :: FilePath -> IO (Either String DesktopEntry)

# Documentation

data DesktopEntry Source #

Desktop Entry. All attributes (key-value-pairs) are stored in an association list.

Constructors

DesktopEntry |

Fields

- deType :: DesktopEntryType
- deFilename :: FilePath

  unqualified filename, e.g. "firefox.desktop"

- deAttributes :: [(String, String)]

  Key-value pairs

#### Instances

Instances details

Read DesktopEntry Source # |
Instance details Defined in System.Environment.XDG.DesktopEntry Methods readsPrec :: Int -> ReadS DesktopEntry Source # readList :: ReadS [DesktopEntry] Source # readPrec :: ReadPrec DesktopEntry Source # readListPrec :: ReadPrec [DesktopEntry] Source #
Show DesktopEntry Source # |
Instance details Defined in System.Environment.XDG.DesktopEntry Methods showsPrec :: Int -> DesktopEntry -> ShowS Source # show :: DesktopEntry -> String Source # showList :: [DesktopEntry] -> ShowS Source #
Eq DesktopEntry Source # |
Instance details Defined in System.Environment.XDG.DesktopEntry Methods (==) :: DesktopEntry -> DesktopEntry -> Bool Source # (/=) :: DesktopEntry -> DesktopEntry -> Bool Source #

deCommand :: DesktopEntry -> Maybe String Source #

Return the command that should be executed when running this desktop entry.

deComment Source #

Arguments

:: [String] | Preferred languages
-> DesktopEntry |
-> Maybe String |

Return the proper comment of the desktop entry, depending on the list of preferred languages.

deHasCategory :: DesktopEntry -> String -> Bool Source #

Determine whether the Category attribute of a desktop entry contains a given value.

deIcon :: DesktopEntry -> Maybe String Source #

Return the Icon attribute

deName Source #

Arguments

:: [String] | Preferred languages
-> DesktopEntry |
-> String |

Return the proper name of the desktop entry, depending on the list of preferred languages.

deNoDisplay :: DesktopEntry -> Bool Source #

Return True if the entry must not be displayed

deNotShowIn :: DesktopEntry -> [String] Source #

Return the categories in which the entry shall not be shown

deOnlyShowIn :: DesktopEntry -> [String] Source #

Return the categories in which the entry shall be shown

getClassNames :: DesktopEntry -> [String] Source #

Get all the text elements that could be interpreted as class names from a `DesktopEntry`.

getDirectoryEntriesDefault :: IO [DesktopEntry] Source #

Get all instances of `DesktopEntry` for all desktop entry files that can be found by looking in the directories specified by the XDG specification.

getDirectoryEntry :: [FilePath] -> String -> IO (Maybe DesktopEntry) Source #

Retrieve a desktop entry with a specific name.

getDirectoryEntryDefault :: String -> IO (Maybe DesktopEntry) Source #

Get a desktop entry with a specific name from the default directory entry locations.

getXDGDataDirs :: IO [FilePath] Source #

Get all of the XDG data directories (both global and user).

indexDesktopEntriesBy :: Foldable t => (DesktopEntry -> [String]) -> t DesktopEntry -> MultiMap String DesktopEntry Source #

Construct a `Multimap` where each `DesktopEntry` in the provided foldable is indexed by the keys returned from the provided indexing function.

indexDesktopEntriesByClassName :: Foldable t => t DesktopEntry -> MultiMap String DesktopEntry Source #

Construct a multimap where desktop entries are indexed by their class names.

listDesktopEntries Source #

Arguments

:: String | The extension to use in the search
-> FilePath | The filepath at which to search
-> IO [DesktopEntry] |

Return a list of all desktop entries in the given directory.

readDesktopEntry :: FilePath -> IO (Either String DesktopEntry) Source #

Read a desktop entry from a file.