2017-12-12 00:48:56 +01:00
|
|
|
|
|
|
|
module KeyBindings (
|
|
|
|
KeyBindings.modify
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Data.List (sort, isSuffixOf)
|
|
|
|
import Graphics.X11.Types
|
|
|
|
import System.Exit
|
|
|
|
import Text.EditDistance
|
|
|
|
import XMonad
|
|
|
|
import XMonad.Actions.CycleWS
|
|
|
|
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 qualified Solarized as S
|
|
|
|
import qualified XMonad.StackSet as W
|
|
|
|
|
|
|
|
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))
|
|
|
|
, ("<Tab>-b", sendMessage (Toggle "Full"))
|
|
|
|
, ("<XF86MonBrightnessDown>", spawn "/run/current-system/sw/bin/xbacklight -10")
|
|
|
|
, ("<XF86MonBrightnessUp>", spawn "/run/current-system/sw/bin/xbacklight +10")
|
|
|
|
, ("M-<Delete>", kill)
|
|
|
|
, ("M-<Down>", windows W.focusDown)
|
|
|
|
, ("M-<Esc>", sendMessage (Toggle "Full"))
|
|
|
|
, ("M-$", sendMessage (Toggle "Full"))
|
|
|
|
, ("M-<Left>", prevWS)
|
|
|
|
, ("M-e", nextScreen)
|
|
|
|
, ("M-<Right>", nextWS)
|
|
|
|
, ("M-<Tab>", toggleWS)
|
|
|
|
, ("M-<Up>", windows W.focusUp)
|
|
|
|
, ("M-S-<Delete>", spawn "/run/current-system/sw/bin/i3lock-fancy -g -p")
|
|
|
|
, ("M-S-<Left>", shiftToPrev >> prevWS)
|
|
|
|
, ("M-S-<Right>", shiftToNext >> nextWS)
|
|
|
|
, ("M-S-p", shellPrompt promptConfig)
|
|
|
|
, ("M-S-s", spawn "sleep 0.2 ; /run/current-system/sw/bin/scrot -s /tmp/screenSel.png")
|
|
|
|
, ("M-p", fuzzyPrompt promptConfig)
|
|
|
|
, ("M-s", spawn "/run/current-system/sw/bin/scrot /tmp/screen.png")
|
|
|
|
]
|
|
|
|
|
|
|
|
`additionalKeys`-- Add some more (automatic) key bindings:
|
|
|
|
[ ((mod4Mask .|. mask, key), windows $ actionWith tag)
|
|
|
|
| (tag, key) <- zip (workspaces conf) [ xK_F1 .. ]
|
|
|
|
, (mask, actionWith) <- zip [ 0, shiftMask ] [ W.view, W.shift ] ]
|
|
|
|
|
|
|
|
promptConfig = def
|
|
|
|
{ position = Top
|
|
|
|
, alwaysHighlight = True
|
|
|
|
, bgColor = S.magenta
|
|
|
|
, bgHLight = S.base0
|
|
|
|
, borderColor = S.magenta
|
|
|
|
, defaultText = ""
|
|
|
|
, fgColor = S.base02
|
|
|
|
, fgHLight = S.base03
|
2018-01-27 14:03:59 +01:00
|
|
|
, font = "xft:Iosevka Term:style=Regular:size=8"
|
2017-12-12 00:48:56 +01:00
|
|
|
, 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
|
|
|
|
|