diff options
author | defanor <defanor@uberspace.net> | 2017-12-28 05:03:26 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2017-12-28 06:39:17 +0300 |
commit | b11b05385b5615aaf08bd245af53e8df03a193b3 (patch) | |
tree | 99304984295784f70f8f4c3e3cbc8488bf16e0a6 /Pancake/Unclutter.hs | |
parent | c27c14e866dfb4a3c6c85393ffd0522933c67651 (diff) |
Install and enable a few uncluttering XSLTs by default
Diffstat (limited to 'Pancake/Unclutter.hs')
-rw-r--r-- | Pancake/Unclutter.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Pancake/Unclutter.hs b/Pancake/Unclutter.hs index cf5132e..2169e00 100644 --- a/Pancake/Unclutter.hs +++ b/Pancake/Unclutter.hs @@ -47,12 +47,13 @@ import Data.Text.Encoding (decodeUtf8', decodeLatin1, encodeUtf8) import qualified Data.Text as T import Control.Exception - import Pancake.Common import Pancake.Configuration +import Paths_pancake -- | Tries to unclutter a document by applying an XSLT if it's --- available. +-- available. Looks for a file in a user config directory first, and +-- in the system data directory then. tryUnclutter :: MonadIO m => [(Regex, String)] -- ^ Obtained with 'prepareUnclutter'. @@ -67,8 +68,12 @@ tryUnclutter rs u d = liftIO $ handle err $ do _ -> False case find matches rs of Just (_, fn) -> do - dir <- getXdgDirectory XdgConfig "pancake" - let src = dir </> "unclutter" </> fn <.> "xsl" + src <- do + configDir <- getXdgDirectory XdgConfig "pancake" + let src = configDir </> "unclutter" </> fn <.> "xsl" + exists <- doesFileExist src + dataDir <- getDataDir + pure $ if exists then src else dataDir </> "unclutter" </> fn <.> "xsl" exists <- doesFileExist src if exists then do |