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)
|
2023-08-03 08:12:05 +02:00
|
|
|
import Data.Foldable (forM_)
|
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
|
2023-08-03 08:12:05 +02:00
|
|
|
-- import Text.EditDistance
|
2017-12-12 00:48:56 +01:00
|
|
|
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
|
2023-08-03 08:12:05 +02:00
|
|
|
import XMonad.Prompt.FuzzyMatch
|
2017-12-12 00:48:56 +01:00
|
|
|
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
|
2024-05-14 12:27:44 +02:00
|
|
|
import qualified Catppuccin as C
|
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)
|
|
|
|
|
2023-08-04 09:57:48 +02:00
|
|
|
lockScreenCmd =
|
|
|
|
spawn "/etc/profiles/per-user/e/bin/mpc pause; /run/current-system/sw/bin/xset s activate"
|
|
|
|
|
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))
|
2022-12-22 11:37:22 +01:00
|
|
|
, ("<XF86MonBrightnessDown>", spawn "/run/current-system/sw/bin/light -U 10")
|
|
|
|
, ("<XF86MonBrightnessUp>", spawn "/run/current-system/sw/bin/light -A 10")
|
|
|
|
, ("<XF86AudioPlay>", spawn "/etc/profiles/per-user/e/bin/mpc toggle")
|
|
|
|
, ("<XF86AudioNext>", spawn "/etc/profiles/per-user/e/bin/mpc next")
|
|
|
|
, ("<XF86AudioPrev>", spawn "/etc/profiles/per-user/e/bin/mpc prev")
|
2023-08-04 09:57:48 +02:00
|
|
|
-- KP_1 -> KP_6 macros
|
|
|
|
, ("<XF86Tools>", viewProject "sound")
|
|
|
|
, ("<XF86Launch5>", viewProject "frs")
|
|
|
|
, ("<XF86Launch6>", viewProject "chat")
|
|
|
|
, ("<XF86Launch7>", viewProject "isengard")
|
|
|
|
, ("<XF86Launch8>", viewProject "moria")
|
|
|
|
, ("<XF86Launch9>", viewProject "fre")
|
|
|
|
-- KP_Delete
|
|
|
|
, ("Cancel", lockScreenCmd)
|
2017-12-12 00:48:56 +01:00
|
|
|
, ("M-<Down>", windows W.focusDown)
|
|
|
|
, ("M-<Esc>", sendMessage (Toggle "Full"))
|
2021-04-06 08:29:14 +02:00
|
|
|
, ("M-$", sendMessage (Toggle "Full"))
|
2017-12-12 00:48:56 +01:00
|
|
|
, ("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)
|
2023-08-04 09:57:48 +02:00
|
|
|
, ("M-S-<Delete>", lockScreenCmd)
|
2017-12-12 00:48:56 +01:00
|
|
|
, ("M-S-<Left>", shiftToPrev >> prevWS)
|
|
|
|
, ("M-S-<Right>", shiftToNext >> nextWS)
|
2022-12-07 13:54:45 +01:00
|
|
|
, ("M-s s", spawn "/etc/profiles/per-user/e/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)
|
2021-01-20 11:16:59 +01:00
|
|
|
, ("M-p c", withFocused centerWindow)
|
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))
|
2021-03-03 13:09:35 +01:00
|
|
|
-- Mouse stuff
|
2021-04-06 08:29:14 +02:00
|
|
|
, ("<F9>", spawn "find-cursor")
|
|
|
|
-- , ("M-$ $", spawn "xdotool click 3")
|
|
|
|
-- , ("M-$ M-$", spawn "xdotool click 3") -- helpfull to combine M + right click
|
2021-11-01 11:18:25 +01:00
|
|
|
-- resizing the master/slave ratio
|
|
|
|
, ("M-h", sendMessage Shrink) -- Shrink the master area
|
|
|
|
, ("M-l", sendMessage Expand) -- Expand the master area
|
2021-12-15 11:38:09 +01:00
|
|
|
-- dunstctl calls
|
2023-04-18 09:10:27 +02:00
|
|
|
-- , ("C-<Space>", spawn "dunstctl close")
|
2021-12-15 11:38:09 +01:00
|
|
|
, ("C-S-<Space>", spawn "dunstctl close-all")
|
2023-11-03 16:13:33 +01:00
|
|
|
, ("M-n p", spawn "dunstctl set-paused toggle")
|
2017-12-12 00:48:56 +01:00
|
|
|
]
|
|
|
|
|
2021-01-20 11:16:59 +01:00
|
|
|
|
|
|
|
-- Borrowed from https://www.reddit.com/r/xmonad/comments/gzq316/how_can_i_centre_a_floating_window_without/fthtx29/
|
|
|
|
centerWindow :: Window -> X ()
|
|
|
|
centerWindow win = do
|
|
|
|
(_, W.RationalRect x y w h) <- floatLocation win
|
|
|
|
windows $ W.float win (W.RationalRect ((1 - w) / 2) ((1 - h) / 2) w h)
|
|
|
|
return ()
|
|
|
|
|
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
|
2024-05-14 12:27:44 +02:00
|
|
|
, bgColor = C.lavender
|
|
|
|
, bgHLight = C.surface0
|
|
|
|
, borderColor = C.lavender
|
2017-12-12 00:48:56 +01:00
|
|
|
, defaultText = ""
|
2024-05-14 12:27:44 +02:00
|
|
|
, fgColor = C.surface2
|
|
|
|
, fgHLight = C.text
|
2021-11-01 11:18:25 +01:00
|
|
|
, font = "xft:Iosevka Samae:style=Regular:size=10:charwidth=6.5"
|
2017-12-12 00:48:56 +01:00
|
|
|
, height = 24
|
|
|
|
, promptBorderWidth = 5
|
2023-08-03 08:12:05 +02:00
|
|
|
-- Fuzzysearch by default
|
|
|
|
, searchPredicate = fuzzyMatch
|
|
|
|
, sorter = fuzzySort
|
2017-12-12 00:48:56 +01:00
|
|
|
}
|
|
|
|
|
2023-08-03 08:12:05 +02:00
|
|
|
-- -- 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
|
|
|
|
--
|