nix-config/modules/home-manager/desktop-xmonad/xmonad/lib/Prompts.hs

93 lines
2.7 KiB
Haskell
Raw Normal View History

2022-01-18 09:32:55 +01:00
module Prompts ( promptKeybinds ) where
import Text.Printf (printf)
import qualified Data.Map as M ( Map , fromList )
import Graphics.X11.Types
( KeySym , ButtonMask
, xK_Tab
, xK_a , xK_b , xK_c , xK_p , xK_r , xK_s , xK_u , xK_t
)
import Graphics.X11.ExtraTypes.XF86 ( xF86XK_Launch1 )
import XMonad.Core ( X , modMask , XConfig(XConfig) , Layout )
import XMonad.Util.Run ( safeSpawn )
import qualified XMonad.Prompt as P
( XPConfig
, def
, font
, bgColor
, fgColor
, bgHLight
, fgHLight
, bgColor
, borderColor
, promptBorderWidth
, alwaysHighlight
, defaultPrompter
)
import HostConfig
( ColorConfig
, FontConfig
, fontConfig
, colorConfig
, fontName
, fontSize
, bgColor
, fgColor
, selColor
, selFgColor
)
import Utils ( mkSubmap )
promptKeybinds :: XConfig Layout -> M.Map (ButtonMask, KeySym) (X ())
promptKeybinds XConfig {modMask = modm} = M.fromList
[ ((0, xF86XK_Launch1), run)
, ((modm, xK_r), run)
, ((modm, xK_a) , subMapMaker
[ ( xK_r , drun )
, ( xK_p , pass )
, ( xK_Tab , window )
, ( xK_t , todo )
, ( xK_c , clipmenu )
, ( xK_b , buku )
, ( xK_s , ssh )
])
]
where
run = safeSpawn "rofi" ["-show", "run"]
drun = safeSpawn "rofi" ["-show", "drun"]
pass = safeSpawn "rofi-pass" []
buku = safeSpawn "rofi-buku" []
ssh = safeSpawn "rofi" ["-show", "ssh"]
window = safeSpawn "rofi" ["-show", "window"]
clipmenu = safeSpawn "clipmenu" dmenuArgs
todo = safeSpawn "todo-rofi" []
subMapMaker = mkSubmap modm . map (\(key,action) -> ((0,key),action))
dmenuArgs :: [String]
dmenuArgs =
[ "-b" -- bottom
, "-fn", printf "%s:size=%d" (fontName fontConfig) (fontSize fontConfig)
, "-nb", bgColor colorConfig -- normal background
, "-nf", fgColor colorConfig -- normal foreground
, "-sb", selColor colorConfig -- selected background
, "-sf", selFgColor colorConfig -- selected foreground
]
theme :: P.XPConfig
theme = P.def
{ P.font = printf "xft:%s:size=%d" (fontName fontConfig) (fontSize fontConfig)
, P.bgColor = bgColor colorConfig
, P.fgColor = fgColor colorConfig
, P.bgHLight = selColor colorConfig
, P.fgHLight = selFgColor colorConfig
, P.borderColor = bgColor colorConfig
, P.promptBorderWidth = 0
, P.alwaysHighlight = True
, P.defaultPrompter = const ""
}