-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A small wrapper around dmenu -- -- hdmenu is a small wrapper around dmenu that can 1. Display commands in -- order of usage and, optionally, apply a frequency decay every time an -- item is selected. 2. Specify extra files to consider, which will be -- opened by a program of your choice (e.g., xdg-open). 3. Open certain -- executables inside of your terminal. @package hdmenu @version 0.3.0 module Core.Util -- | A space-efficient representation of a Word8 vector, supporting -- many efficient operations. -- -- A ByteString contains 8-bit bytes, or by using the operations -- from Data.ByteString.Char8 it can be interpreted as containing -- 8-bit characters. data () => ByteString -- | A Map from keys k to values a. -- -- The Semigroup operation for Map is union, which -- prefers values from the left operand. If m1 maps a key -- k to a value a1, and m2 maps the same key -- to a different value a2, then their union m1 <> -- m2 maps k to a1. data () => Map k a -- | Special directories for storing user-specific application data, -- configuration, and cache files, as specified by the XDG Base -- Directory Specification. -- -- Note: On Windows, XdgData and XdgConfig usually map to -- the same directory. data () => XdgDirectory -- | For configuration files. It uses the XDG_CONFIG_HOME -- environment variable. On non-Windows systems, the default is -- ~/.config. On Windows, the default is %APPDATA% -- (e.g. C:/Users/<user>/AppData/Roaming). Can be -- considered as the user-specific equivalent of /etc. XdgConfig :: XdgDirectory -- | The kind of types with lifted values. For example Int :: -- Type. type Type = TYPE LiftedRep -- | Like 'if', but in a monadic context. ifM :: Monad m => m Bool -> m a -> m a -> m a -- | The operation doesFileExist returns True if the argument -- file exists and is not a directory, and False otherwise. doesFileExist :: FilePath -> IO Bool -- | Construct a CreateProcess record for passing to -- createProcess, representing a raw command with arguments. -- -- See RawCommand for precise semantics of the specified -- FilePath. proc :: FilePath -> [String] -> CreateProcess -- | Obtain the paths to special directories for storing user-specific -- application data, configuration, and cache files, conforming to the -- XDG Base Directory Specification. Compared with -- getAppUserDataDirectory, this function provides a more -- fine-grained hierarchy as well as greater flexibility for the user. -- -- On Windows, XdgData and XdgConfig usually map to the -- same directory unless overridden. -- -- Refer to the docs of XdgDirectory for more details. -- -- The second argument is usually the name of the application. Since it -- will be integrated into the path, it must consist of valid path -- characters. Note: if the second argument is an absolute path, it will -- just return the second argument. -- -- Note: The directory may not actually exist, in which case you would -- need to create it with file mode 700 (i.e. only accessible by -- the owner). -- -- As of 1.3.5.0, the environment variable is ignored if set to a -- relative path, per revised XDG Base Directory Specification. See -- #100. getXdgDirectory :: XdgDirectory -> FilePath -> IO FilePath -- | Creates a new process to run the specified shell command. It does not -- wait for the program to finish, but returns the ProcessHandle. spawnCommand :: String -> IO ProcessHandle -- | createDirectoryIfMissing parents dir creates a new -- directory dir if it doesn't exist. If the first argument is -- True the function will also create all parent directories if -- they are missing. createDirectoryIfMissing :: Bool -> FilePath -> IO () -- | ShowS for ByteString because it is shorter :>. type ShowBS = ByteString -> ByteString -- | Type for helping to decide how to open something. data OpenIn Term :: ShowBS -> OpenIn Open :: ShowBS -> OpenIn -- | Type for an Map that describes all of the executables with their -- ratings. type Items = Map ByteString Double -- | Add a prefix to a string if it does not start with "/". -- -- This will ensure the user can specify absolute paths to files, but -- also conveniently use relative paths (starting from $HOME) if -- that is desired. tryAddPrefix :: ByteString -> ByteString -> ByteString -- | Functorial path-append operation. (<>) :: Functor f => f FilePath -> FilePath -> f FilePath infixr 5 <> -- | Combine two paths into a new path. Adapted from: -- https://hackage.haskell.org/package/filepath () :: FilePath -> FilePath -> FilePath infixr 5 -- | Path to the hdmenu directory. XDG_CONFIG_HOME/hdmenu, so -- probably ~/.config/hdmenu. hdmenuPath :: IO FilePath -- | Path to the history file. ~/.config/hdmenu/histFile histFile :: IO FilePath -- | Spawn a command and forget about it. spawn :: ByteString -> IO () -- | Open something. openWith :: OpenIn -> ByteString -> ByteString module Core.Toml -- | Hdmenu's config file. data Config Config :: [ByteString] -> ShowBS -> FilePath -> ShowBS -> [ByteString] -> Double -> FilePath -> Config [files] :: Config -> [ByteString] [open] :: Config -> ShowBS [dmenuExe] :: Config -> FilePath [term] :: Config -> ShowBS [tty] :: Config -> [ByteString] [decay] :: Config -> Double -- | Command line option, NOT specifiable in the config file. [histPath] :: Config -> FilePath -- | Try to find a user config and, if it exists, parse it. getUserConfig :: IO Config module Core.Parser -- | Read a history file (the file must exist) and parse it into a map. getHist :: FilePath -> IO Items -- | Parse a history file of name-number pairs. pFile :: ByteString -> Items module Core.Select -- | Run dmenu with the given command line options and a list of entries -- from which the user should choose. -- -- Originally select. selectWith :: [String] -> [ByteString] -> String -> IO (Either ProcessError ByteString) -- | Try to read a file that contains a map. Return an empty map if the -- file doesn't exist. tryRead :: FilePath -> IO Items -- | Do the appropriate things with the user selection and update the -- history file. runUpdate :: ByteString -> Config -> Items -> IO () -- | Get all executables from all dirs in $PATH. getExecutables :: IO [ByteString] -- | Apply evalDir to some list of file paths. evalDirs :: [ByteString] -> IO [ByteString] -- | Pretty print our items. showItems :: Items -> ByteString -- | Turn a list into Items and set all starting values to 0. makeNewEntries :: [ByteString] -> Items -- | Sort Items by its values and return the list of keys. This will -- make often used commands bubble up to the top. sortByValues :: Items -> [ByteString]