From bd4f5d7e30a5f544235ac7c710c1093ba554a075 Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Thu, 21 Mar 2019 23:36:00 +0200 Subject: [PATCH] Search endpoints --- src/XMonad/Config/MasseR.hs | 11 +++++++---- src/XMonad/Config/MasseR/ExtraConfig.hs | 9 ++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/XMonad/Config/MasseR.hs b/src/XMonad/Config/MasseR.hs index c2e35e4..ba1b62d 100644 --- a/src/XMonad/Config/MasseR.hs +++ b/src/XMonad/Config/MasseR.hs @@ -1,4 +1,5 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} module XMonad.Config.MasseR where @@ -70,15 +71,17 @@ scratchSubmaps conf = submapName . mkNamedKeymap conf $ [ ] -- Search engines inside submaps -searchSubmaps :: XConfig l -> NamedAction -searchSubmaps conf = +searchSubmaps :: ExtraConfig -> XConfig l -> NamedAction +searchSubmaps extraConfig conf = let mkBrowser = promptSearchBrowser def "qutebrowser" _googleP = addName "Search google" $ mkBrowser google ddgP = addName "Search duckduckgo" $ mkBrowser (searchEngine "duckduckgo" "http://duckduckgo.com/?q=") + extras = [(key, addName name $ mkBrowser (searchEngine name url)) | Search{..} <- searchEndpoints extraConfig] in submapName . mkNamedKeymap conf $ [ ("d", ddgP) -- Training to use ddg again , ("g", ddgP) -- training to use ddg again - ] + ] ++ extras + myNav2d :: Navigation2DConfig myNav2d = def { defaultTiledNavigation = lineNavigation } @@ -181,7 +184,7 @@ myKeys extraConfig conf = subKeys "Launchers" [ ("M-S-y", addName "Open youtube" $ spawn "mpv $(clip -o)") , ("M-S-", addName "Open terminal" $ spawn $ XMonad.terminal conf) , ("M-n", scratchSubmaps conf) - , ("M-s", searchSubmaps conf) + , ("M-s", searchSubmaps extraConfig conf) , ("M-p", addName "Retrieve password" $ passPrompt def) , ("M-S-e", addName "Open with app" xdgOpen) , ("M-e", addName "Run app" $ runOrRaisePrompt def)] ^++^ diff --git a/src/XMonad/Config/MasseR/ExtraConfig.hs b/src/XMonad/Config/MasseR/ExtraConfig.hs index aea9d7f..1cf300c 100644 --- a/src/XMonad/Config/MasseR/ExtraConfig.hs +++ b/src/XMonad/Config/MasseR/ExtraConfig.hs @@ -19,7 +19,14 @@ data TopicRule = } deriving (Show, Generic) +data Search = Search { name :: String + , key :: String + , url :: String + } + deriving (Show, Generic) + data ExtraConfig = ExtraConfig { applications :: Applications - , topics :: [ TopicRule ] } + , topics :: [ TopicRule ] + , searchEndpoints :: [Search] } deriving (Show, Generic)