ENH update keybindings

This commit is contained in:
Nathan Dwarshuis 2020-02-07 22:28:50 -05:00
parent a5258311b4
commit eb2cc3b3a9
1 changed files with 161 additions and 39 deletions

200
xmonad.hs
View File

@ -6,38 +6,56 @@
module Main (main) where module Main (main) where
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
import System.Exit -- import System.Exit
import System.IO
import XMonad import XMonad
import XMonad.Config.Desktop import XMonad.Actions.CopyWindow
import XMonad.Hooks.DynamicLog import XMonad.Actions.CycleWS
import XMonad.Hooks.ManageHelpers -- import XMonad.Config.Desktop
import XMonad.Layout.BinarySpacePartition (emptyBSP) -- import XMonad.Hooks.DynamicLog
import XMonad.Layout.NoBorders (noBorders) import XMonad.Hooks.EwmhDesktops
import XMonad.Layout.ResizableTile (ResizableTall(..)) -- import XMonad.Layout.IndependentScreens
import XMonad.Layout.ToggleLayouts (ToggleLayout(..), toggleLayouts) -- import XMonad.Hooks.ManageHelpers
import XMonad.Prompt -- import XMonad.Layout.BinarySpacePartition (emptyBSP)
import XMonad.Prompt.ConfirmPrompt -- import XMonad.Layout.NoBorders (noBorders)
import XMonad.Prompt.Shell -- import XMonad.Layout.ResizableTile (ResizableTall(..))
-- import XMonad.Layout.ToggleLayouts (ToggleLayout(..), toggleLayouts)
-- import XMonad.Prompt
-- import XMonad.Prompt.ConfirmPrompt
-- import XMonad.Prompt.Shell
import XMonad.Util.EZConfig import XMonad.Util.EZConfig
import XMonad.Util.NamedActions
import XMonad.Util.Run
import qualified XMonad.StackSet as W
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
main = do main = do
spawn "xmobar" -- Start a task bar such as xmobar. -- spawn "xmobar" -- Start a task bar such as xmobar.
xmonad
$ ewmh
$ addDescrKeys' ((myModMask, xK_F1), showKeybindings) myKeys
$ def { terminal = myTerm
, modMask = myModMask
-- , workspaces = withScreens 2 ["name1", "name2"]
-- , layoutHook = myLayoutHook
}
-- Start xmonad using the main desktop configuration with a few -- Start xmonad using the main desktop configuration with a few
-- simple overrides: -- simple overrides:
xmonad $ desktopConfig -- xmonad $ desktopConfig
{ modMask = mod4Mask -- Use the "Win" key for the mod key -- { modMask = mod4Mask -- Use the "Win" key for the mod key
, manageHook = myManageHook <+> manageHook desktopConfig -- , manageHook = myManageHook <+> manageHook desktopConfig
, layoutHook = desktopLayoutModifiers $ myLayouts -- , layoutHook = desktopLayoutModifiers $ myLayouts
, logHook = dynamicLogString def >>= xmonadPropLog -- , logHook = dynamicLogString def >>= xmonadPropLog
} -- }
`additionalKeysP` -- Add some extra key bindings: -- `additionalKeysP` -- Add some extra key bindings:
[ ("M-S-q", confirmPrompt myXPConfig "exit" (io exitSuccess)) -- [ ("M-S-q", confirmPrompt myXPConfig "exit" (io exitSuccess))
, ("M-p", shellPrompt myXPConfig) -- , ("M-p", shellPrompt myXPConfig)
, ("M-<Esc>", sendMessage (Toggle "Full")) -- , ("M-<Esc>", sendMessage (Toggle "Full"))
] -- ]
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Customize layouts. -- | Customize layouts.
@ -46,19 +64,19 @@ main = do
-- and 'BinarySpacePartition'. You can also use the 'M-<Esc>' key -- and 'BinarySpacePartition'. You can also use the 'M-<Esc>' key
-- binding defined above to toggle between the current layout and a -- binding defined above to toggle between the current layout and a
-- full screen layout. -- full screen layout.
myLayouts = toggleLayouts (noBorders Full) others -- myLayouts = toggleLayouts (noBorders Full) others
where -- where
others = ResizableTall 1 (1.5/100) (3/5) [] ||| emptyBSP -- others = ResizableTall 1 (1.5/100) (3/5) [] ||| emptyBSP
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Customize the way 'XMonad.Prompt' looks and behaves. It's a -- | Customize the way 'XMonad.Prompt' looks and behaves. It's a
-- great replacement for dzen. -- great replacement for dzen.
myXPConfig = def -- myXPConfig = def
{ position = Top -- { position = Top
, alwaysHighlight = True -- , alwaysHighlight = True
, promptBorderWidth = 0 -- , promptBorderWidth = 0
, font = "xft:monospace:size=9" -- , font = "xft:monospace:size=9"
} -- }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Manipulate windows as they are created. The list given to -- | Manipulate windows as they are created. The list given to
@ -67,12 +85,116 @@ myXPConfig = def
-- --
-- Use the `xprop' tool to get the info you need for these matches. -- Use the `xprop' tool to get the info you need for these matches.
-- For className, use the second value that xprop gives you. -- For className, use the second value that xprop gives you.
myManageHook = composeOne -- myManageHook = composeOne
[ className =? "Pidgin" -?> doFloat -- [ className =? "Pidgin" -?> doFloat
, className =? "XCalc" -?> doFloat -- , className =? "XCalc" -?> doFloat
, className =? "mpv" -?> doFloat -- , className =? "mpv" -?> doFloat
, isDialog -?> doCenterFloat -- , isDialog -?> doCenterFloat
-- Move transient windows to their parent: -- -- Move transient windows to their parent:
, transience -- , transience
-- ]
-- keybindings
myModMask = mod4Mask
myTerm = "urxvt"
myBrowser = "brave"
myVBox = "VBoxManage startvm win8raw"
myEditor = "emacsclient -c -e \"(select-frame-set-input-focus (selected-frame))\""
myCalc = "urxvt -e R"
myRun = "rofi -show run"
myAppRun = "rofi -show drun"
myClipboard = "rofi -modi \"clipboard:greenclip print\" \
\-show clipboard -run-command '{cmd}' \
\-theme-str '#element.selected.normal \
\{ background-color: #00c44e; }'"
myNetSel = "networkmanager_dmenu"
myWinSel = "rofi -show window"
myScreenCap = "screencap -s" --external script
myWindowCap = "screencap -w" --external script
myScreenLock = "screenlock" --external script
showKeybindings :: [((KeyMask, KeySym), NamedAction)] -> NamedAction
showKeybindings x = addName "Show Keybindings" $ io $ do
h <- spawnPipe "zenity --text-info --font=DejaVu Sans"
hPutStr h (unlines $ showKm x)
hClose h
return ()
mkNamedSubmap c sectionName bindings =
(subtitle sectionName:) $ mkNamedKeymap c bindings
myKeys c =
mkNamedSubmap c "Window Focus"
[ ("M-j", addName "focus down" $ windows W.focusDown)
, ("M-k", addName "focus up" $ windows W.focusUp)
, ("M-m", addName "focus master" $ windows W.focusMaster)
] ++
mkNamedSubmap c "Window Layouts"
[ ("M-S-j", addName "swap down" $ windows W.swapDown)
, ("M-S-k", addName "swap up" $ windows W.swapUp)
, ("M-<Return>", addName "swap master" $ windows W.swapMaster)
, ("M-<Space>", addName "next layout" $ sendMessage NextLayout)
, ("M-S-<Space>", addName "reset layout" $ setLayout $ XMonad.layoutHook c)
, ("M-t", addName "sink tiling" $ withFocused $ windows . W.sink)
] ++
mkNamedSubmap c "Window Sizing"
[ ("M--", addName "shrink" $ sendMessage Shrink)
, ("M-=", addName "expand" $ sendMessage Expand)
] ++
-- mkNamedSubmap c "Master Windows"
-- [ ("M-=", addName "add master window" $ sendMessage (IncMasterN 1))
-- , ("M--", addName "remove master window" $ sendMessage (IncMasterN (-1)))
-- ] ++
mkNamedSubmap c "Workspaces"
[ (mods ++ show i, addName (msg ++ " " ++ show i) $ windows $ f w)
| (w, i) <- zip (XMonad.workspaces c) [1..] :: [(String, Int)]
, (mods, msg, f) <-
[ ("M-", "switch to workspace", W.view)
, ("M-S-", "move client to workspace", W.shift)]
] ++
mkNamedSubmap c "Screens"
[ ("M-l", addName "move up screen" nextScreen)
, ("M-h", addName "move down screen" prevScreen)
, ("M-C-l", addName "move client up screen" $ shiftNextScreen >> nextScreen)
, ("M-C-h", addName "move client down screen" $ shiftPrevScreen >> prevScreen)
, ("M-S-l", addName "shift up screen" $ swapNextScreen >> nextScreen)
, ("M-S-h", addName "shift down screen" $ swapPrevScreen >> prevScreen)
] ++
mkNamedSubmap c "Actions"
[ ("M-q", addName "close window" kill1)
, ("M-r", addName "run program" $ spawn myRun)
, ("M-C-s", addName "capture screen" $ spawn myScreenCap)
, ("M-C-S-s", addName "capture focused window" $ spawn myWindowCap)
, ("M-<Delete>", addName "lock screen" $ spawn myScreenLock)
] ++
mkNamedSubmap c "Launchers"
[ ("<XF86Search>", addName "select/launch app" $ spawn myAppRun )
, ("M-g", addName "launch clipboard manager" $ spawn myClipboard )
, ("M-a", addName "launch network selector" $ spawn myNetSel )
, ("M-w", addName "launch window selector" $ spawn myWinSel )
, ("M-C-e", addName "run editor" $ spawn myEditor)
, ("M-C-w", addName "run browser" $ spawn myBrowser)
, ("M-C-t", addName "run terminal" $ spawn myTerm)
, ("M-C-q", addName "run calc" $ spawn myCalc)
, ("M-C-v", addName "run windows VM" $ spawn myVBox)
] ++
mkNamedSubmap c "System"
[ ("M-.", addName "backlight up" $ spawn "adj_backlight up")
, ("M-,", addName "backlight down" $ spawn "adj_backlight down")
, ("M-<F2>", addName "restart xmonad" $ spawn "xmonad --restart")
, ("M-S-<F2>", addName "recompile xmonad" $ spawn "xmonad --recompile && xmonad --restart")
-- , ("M-<Home>", addName "quit xmonad" $
-- confirmPrompt hotPromptTheme "Quit XMonad?" $
-- io (exitWith ExitSuccess))
] ]