100 lines
3.3 KiB
Haskell
100 lines
3.3 KiB
Haskell
|
|
module KeyBindings (
|
|
KeyBindings.modify
|
|
) where
|
|
|
|
import Control.Monad (void)
|
|
import Data.List (sort, isSuffixOf)
|
|
import Data.Maybe (isJust)
|
|
import Graphics.X11.Types
|
|
import System.Exit
|
|
-- import Text.EditDistance
|
|
import XMonad
|
|
import XMonad.Actions.CycleWS
|
|
import XMonad.Actions.DynamicProjects
|
|
import XMonad.Core
|
|
import XMonad.Layout.ToggleLayouts
|
|
import XMonad.Operations
|
|
import XMonad.Prompt
|
|
import XMonad.Prompt.ConfirmPrompt
|
|
import XMonad.Prompt.Shell
|
|
import XMonad.Util.EZConfig
|
|
import XMonad.Util.NamedScratchpad
|
|
import qualified Solarized as S
|
|
import qualified Scratchpad as R
|
|
import qualified XMonad.StackSet as W
|
|
|
|
-- Custom (in libs)
|
|
import Password (passPrompt)
|
|
|
|
modify :: XConfig l -> XConfig l
|
|
modify conf = conf
|
|
{ modMask = mod4Mask -- Use the "Win" key for the mod key
|
|
}
|
|
|
|
`additionalKeysP` -- Add some extra key bindings:
|
|
[ ("M-S-q", confirmPrompt promptConfig "exit" (io exitSuccess))
|
|
, ("<XF86MonBrightnessDown>", spawn "/run/current-system/sw/bin/xbacklight -10")
|
|
, ("<XF86MonBrightnessUp>", spawn "/run/current-system/sw/bin/xbacklight +10")
|
|
, ("<XF86AudioPlay>", spawn "/run/current-system/sw/bin/mpc toggle")
|
|
, ("<XF86AudioNext>", spawn "/run/current-system/sw/bin/mpc next")
|
|
, ("<XF86AudioPrev>", spawn "/run/current-system/sw/bin/mpc prev")
|
|
, ("M-<Delete>", kill)
|
|
, ("M-<Down>", windows W.focusDown)
|
|
, ("M-<Esc>", sendMessage (Toggle "Full"))
|
|
, ("M-$", sendMessage (Toggle "Full"))
|
|
, ("M-<Left>", prevWS)
|
|
, ("M-i", prevScreen)
|
|
, ("M-e", nextScreen)
|
|
, ("M-<Right>", nextWS)
|
|
, ("M-<Tab>", toggleWS' ["NSP"])
|
|
, ("M-<Up>", windows W.focusUp)
|
|
, ("M-S-<Delete>", spawn "/run/current-system/sw/bin/mpc pause; /run/current-system/sw/bin/xset s activate")
|
|
, ("M-S-<Left>", shiftToPrev >> prevWS)
|
|
, ("M-S-<Right>", shiftToNext >> nextWS)
|
|
, ("M-s s", spawn "flameshot gui")
|
|
, ("M-s t", spawn "/run/current-system/sw/bin/scrot /tmp/screen.png")
|
|
-- Workspace and tasks
|
|
, ("M-b", switchProjectPrompt promptConfig)
|
|
, ("M-p m", shiftToProjectPrompt promptConfig)
|
|
, ("M-p n", switchProjectPrompt promptConfig)
|
|
, ("M-p r", renameProjectPrompt promptConfig)
|
|
, ("M-p s", shellPrompt promptConfig)
|
|
, ("M-d", passPrompt promptConfig)
|
|
-- Scratchpads
|
|
, ("M-p p", namedScratchpadAction R.pads "htop")
|
|
]
|
|
|
|
viewProject :: WorkspaceId -> X ()
|
|
viewProject id = do
|
|
project <- lookupProject id
|
|
case project of
|
|
Just p -> switchProject p
|
|
Nothing -> return ()
|
|
|
|
promptConfig = def
|
|
{ position = Bottom
|
|
, alwaysHighlight = True
|
|
, bgColor = S.magenta
|
|
, bgHLight = S.base0
|
|
, borderColor = S.magenta
|
|
, defaultText = ""
|
|
, fgColor = S.base02
|
|
, fgHLight = S.base03
|
|
, font = "xft:Iosevka Samae:style=Regular:size=8"
|
|
, height = 24
|
|
, promptBorderWidth = 5
|
|
}
|
|
|
|
-- -- Slightly taken from
|
|
-- -- https://mail.haskell.org/pipermail/xmonad/2010-October/010671.html
|
|
-- data FuzzySpawn = FuzzySpawn deriving (Read, Show)
|
|
-- instance XPrompt FuzzySpawn where showXPrompt _ = "RunC: "
|
|
-- fuzzyPrompt config = do
|
|
-- cmds <- io getCommands
|
|
-- let compl s
|
|
-- | null s = []
|
|
-- | otherwise = let weight c = levenshteinDistance defaultEditCosts s c
|
|
-- in map snd $ take 20 $ sort $ map (\c -> (weight c,c)) cmds
|
|
-- mkXPrompt FuzzySpawn config (return . compl) spawn
|
|
--
|