2017-12-12 00:48:56 +01:00
|
|
|
|
|
|
|
module KeyBindings (
|
|
|
|
KeyBindings.modify
|
|
|
|
) where
|
|
|
|
|
2018-05-27 15:39:24 +02:00
|
|
|
import Control.Monad (void)
|
2017-12-12 00:48:56 +01:00
|
|
|
import Data.List (sort, isSuffixOf)
|
2018-05-27 15:39:24 +02:00
|
|
|
import Data.Maybe (isJust)
|
2017-12-12 00:48:56 +01:00
|
|
|
import Graphics.X11.Types
|
|
|
|
import System.Exit
|
|
|
|
import Text.EditDistance
|
|
|
|
import XMonad
|
2019-05-31 17:42:52 +02:00
|
|
|
import XMonad.Actions.CopyWindow (kill1,copy)
|
2017-12-12 00:48:56 +01:00
|
|
|
import XMonad.Actions.CycleWS
|
2018-05-26 17:08:13 +02:00
|
|
|
import XMonad.Actions.DynamicProjects
|
2017-12-12 00:48:56 +01:00
|
|
|
import XMonad.Core
|
|
|
|
import XMonad.Layout.ToggleLayouts
|
|
|
|
import XMonad.Operations
|
|
|
|
import XMonad.Prompt
|
|
|
|
import XMonad.Prompt.ConfirmPrompt
|
|
|
|
import XMonad.Prompt.Shell
|
2019-05-31 17:42:52 +02:00
|
|
|
import XMonad.Prompt.Workspace (workspacePrompt)
|
2017-12-12 00:48:56 +01:00
|
|
|
import XMonad.Util.EZConfig
|
2018-05-27 15:39:24 +02:00
|
|
|
import XMonad.Util.NamedScratchpad
|
2017-12-12 00:48:56 +01:00
|
|
|
import qualified Solarized as S
|
2018-05-27 15:39:24 +02:00
|
|
|
import qualified Scratchpad as R
|
2017-12-12 00:48:56 +01:00
|
|
|
import qualified XMonad.StackSet as W
|
|
|
|
|
2019-05-16 08:03:35 +02:00
|
|
|
-- Custom (in libs)
|
|
|
|
import Password (passPrompt)
|
|
|
|
|
2017-12-12 00:48:56 +01:00
|
|
|
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")
|
2019-04-17 16:14:19 +02:00
|
|
|
, ("<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")
|
2017-12-12 00:48:56 +01:00
|
|
|
, ("M-<Down>", windows W.focusDown)
|
|
|
|
, ("M-<Esc>", sendMessage (Toggle "Full"))
|
|
|
|
, ("M-$", sendMessage (Toggle "Full"))
|
|
|
|
, ("M-<Left>", prevWS)
|
2018-05-29 08:20:58 +02:00
|
|
|
, ("M-i", prevScreen)
|
2017-12-12 00:48:56 +01:00
|
|
|
, ("M-e", nextScreen)
|
|
|
|
, ("M-<Right>", nextWS)
|
2018-05-28 19:53:36 +02:00
|
|
|
, ("M-<Tab>", toggleWS' ["NSP"])
|
2017-12-12 00:48:56 +01:00
|
|
|
, ("M-<Up>", windows W.focusUp)
|
2019-04-17 16:14:19 +02:00
|
|
|
, ("M-S-<Delete>", spawn "/run/current-system/sw/bin/mpc pause; /run/current-system/sw/bin/xset s activate")
|
2017-12-12 00:48:56 +01:00
|
|
|
, ("M-S-<Left>", shiftToPrev >> prevWS)
|
|
|
|
, ("M-S-<Right>", shiftToNext >> nextWS)
|
2020-09-28 15:24:06 +02:00
|
|
|
, ("M-s s", spawn "/home/e/.nix-profile/bin/flameshot gui")
|
2018-05-31 12:47:45 +02:00
|
|
|
, ("M-s t", spawn "/run/current-system/sw/bin/scrot /tmp/screen.png")
|
2018-05-26 17:08:13 +02:00
|
|
|
-- Workspace and tasks
|
2018-05-28 19:53:36 +02:00
|
|
|
, ("M-b", switchProjectPrompt promptConfig)
|
2018-05-26 17:08:13 +02:00
|
|
|
, ("M-p m", shiftToProjectPrompt promptConfig)
|
2018-05-27 15:39:24 +02:00
|
|
|
, ("M-p n", switchProjectPrompt promptConfig)
|
|
|
|
, ("M-p r", renameProjectPrompt promptConfig)
|
2018-05-26 17:08:13 +02:00
|
|
|
, ("M-p s", shellPrompt promptConfig)
|
2019-05-16 08:03:35 +02:00
|
|
|
, ("M-d", passPrompt promptConfig)
|
2018-05-27 15:39:24 +02:00
|
|
|
-- Scratchpads
|
|
|
|
, ("M-p p", namedScratchpadAction R.pads "htop")
|
2019-05-31 17:42:52 +02:00
|
|
|
-- Copy windows to workspaces
|
|
|
|
, ("M-<Delete>", kill1)
|
|
|
|
, ("M-c", workspacePrompt promptConfig (\name -> windows $ copy name))
|
2017-12-12 00:48:56 +01:00
|
|
|
]
|
|
|
|
|
2018-05-27 15:39:24 +02:00
|
|
|
viewProject :: WorkspaceId -> X ()
|
|
|
|
viewProject id = do
|
|
|
|
project <- lookupProject id
|
|
|
|
case project of
|
|
|
|
Just p -> switchProject p
|
|
|
|
Nothing -> return ()
|
|
|
|
|
2017-12-12 00:48:56 +01:00
|
|
|
promptConfig = def
|
2018-05-28 19:53:36 +02:00
|
|
|
{ position = Bottom
|
2017-12-12 00:48:56 +01:00
|
|
|
, alwaysHighlight = True
|
|
|
|
, bgColor = S.magenta
|
|
|
|
, bgHLight = S.base0
|
|
|
|
, borderColor = S.magenta
|
|
|
|
, defaultText = ""
|
|
|
|
, fgColor = S.base02
|
|
|
|
, fgHLight = S.base03
|
2019-12-03 14:45:19 +01:00
|
|
|
, font = "xft:Iosevka Samae: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
|
|
|
|
|
2019-05-10 14:04:15 +02:00
|
|
|
-- https://github.com/MasseR/xmonad-masser/blob/master/src/XMonad/Password.hs
|