Adding xmonad_keys script to display bindings.

This commit is contained in:
Derek Taylor 2021-08-06 16:49:44 -05:00
parent 1c3b86e0b2
commit 24c6a4c3f8
5 changed files with 72 additions and 47 deletions

View File

@ -1,14 +1,14 @@
[xin_1]
file=/home/dt/wallpapers/0277.jpg
file=/home/dt/wallpapers/wp4470198.jpg
mode=0
bgcolor=#000000
[xin_0]
file=/home/dt/wallpapers/0277.jpg
file=/home/dt/wallpapers/wp4470198.jpg
mode=0
bgcolor=#000000
[xin_2]
file=/home/dt/wallpapers/0277.jpg
file=/home/dt/wallpapers/wp4470198.jpg
mode=0
bgcolor=#000000

View File

@ -1,8 +1,8 @@
[geometry]
posx=8
posy=28
sizex=944
sizey=1040
posx=16
posy=40
sizex=1884
sizey=1020
[nitrogen]
view=icon

View File

@ -67,7 +67,7 @@ import qualified Data.Map as M
import XMonad.Hooks.DynamicLog (dynamicLogWithPP, wrap, xmobarPP, xmobarColor, shorten, PP(..))
import XMonad.Hooks.EwmhDesktops -- for some fullscreen events, also for xcomposite in obs.
import XMonad.Hooks.ManageDocks (avoidStruts, docksEventHook, manageDocks, ToggleStruts(..))
import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat)
import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat, doCenterFloat)
import XMonad.Hooks.ServerMode
import XMonad.Hooks.SetWMName
import XMonad.Hooks.WorkspaceHistory
@ -409,6 +409,7 @@ myManageHook = composeAll
, className =? "pinentry-gtk-2" --> doFloat
, className =? "splash" --> doFloat
, className =? "toolbar" --> doFloat
, className =? "Yad" --> doCenterFloat
, title =? "Oracle VM VirtualBox Manager" --> doFloat
, title =? "Mozilla Firefox" --> doShift ( myWorkspaces !! 1 )
, className =? "brave-browser" --> doShift ( myWorkspaces !! 1 )
@ -450,17 +451,19 @@ I am using the Xmonad.Util.EZConfig module which allows keybindings to be writte
| MODKEY + t | force floating window back into tiling |
#+BEGIN_SRC haskell
-- START_KEYS
myKeys :: [(String, X ())]
myKeys =
-- Xmonad
-- KB_GROUP Xmonad
[ ("M-C-r", spawn "xmonad --recompile") -- Recompiles xmonad
, ("M-S-r", spawn "xmonad --restart") -- Restarts xmonad
, ("M-S-q", io exitSuccess) -- Quits xmonad
, ("M-S-/", spawn "~/.xmonad/xmonad_keys.sh")
-- Run Prompt
-- KB_GROUP Run Prompt
, ("M-S-<Return>", spawn "dmenu_run -i -p \"Run: \"") -- Dmenu
-- Other Dmenu Prompts
-- KB_GROUP Other Dmenu Prompts
-- In Xmonad and many tiling window managers, M-p is the default keybinding to
-- launch dmenu_run, so I've decided to use M-p plus KEY for these dmenu scripts.
, ("M-p a", spawn "dm-sounds") -- choose an ambient background
@ -476,38 +479,38 @@ myKeys =
, ("M-p r", spawn "dm-reddit") -- reddio (a reddit viewer)
, ("M-p s", spawn "dm-websearch") -- search various search engines
-- Useful programs to have a keybinding for launch
-- KB_GROUP Useful programs to have a keybinding for launch
, ("M-<Return>", spawn (myTerminal))
, ("M-b", spawn (myBrowser ++ " www.youtube.com/c/DistroTube/"))
, ("M-M1-h", spawn (myTerminal ++ " -e htop"))
-- Kill windows
-- KB_GROUP Kill windows
, ("M-S-c", kill1) -- Kill the currently focused client
, ("M-S-a", killAll) -- Kill all windows on current workspace
-- Workspaces
-- KB_GROUP Workspaces
, ("M-.", nextScreen) -- Switch focus to next monitor
, ("M-,", prevScreen) -- Switch focus to prev monitor
, ("M-S-<KP_Add>", shiftTo Next nonNSP >> moveTo Next nonNSP) -- Shifts focused window to next ws
, ("M-S-<KP_Subtract>", shiftTo Prev nonNSP >> moveTo Prev nonNSP) -- Shifts focused window to prev ws
-- Floating windows
-- KB_GROUP Floating windows
, ("M-f", sendMessage (T.Toggle "floats")) -- Toggles my 'floats' layout
, ("M-t", withFocused $ windows . W.sink) -- Push floating window back to tile
, ("M-S-t", sinkAll) -- Push ALL floating windows to tile
-- Increase/decrease spacing (gaps)
-- KB_GROUP Increase/decrease spacing (gaps)
, ("C-M1-j", decWindowSpacing 4) -- Decrease window spacing
, ("C-M1-k", incWindowSpacing 4) -- Increase window spacing
, ("C-M1-h", decScreenSpacing 4) -- Decrease screen spacing
, ("C-M1-l", incScreenSpacing 4) -- Increase screen spacing
-- Grid Select (CTR-g followed by a key)
-- KB_GROUP Grid Select (CTR-g followed by a key)
, ("C-g g", spawnSelected' myAppGrid) -- grid select favorite apps
, ("C-g t", goToSelected $ mygridConfig myColorizer) -- goto selected window
, ("C-g b", bringSelected $ mygridConfig myColorizer) -- bring selected window
-- Windows navigation
-- KB_GROUP Windows navigation
, ("M-m", windows W.focusMaster) -- Move focus to the master window
, ("M-j", windows W.focusDown) -- Move focus to the next window
, ("M-k", windows W.focusUp) -- Move focus to the prev window
@ -518,23 +521,23 @@ myKeys =
, ("M-S-<Tab>", rotSlavesDown) -- Rotate all windows except master and keep focus in place
, ("M-C-<Tab>", rotAllDown) -- Rotate all the windows in the current stack
-- Layouts
-- KB_GROUP Layouts
, ("M-<Tab>", sendMessage NextLayout) -- Switch to next layout
, ("M-<Space>", sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts) -- Toggles noborder/full
-- Increase/decrease windows in the master pane or the stack
-- KB_GROUP Increase/decrease windows in the master pane or the stack
, ("M-S-<Up>", sendMessage (IncMasterN 1)) -- Increase # of clients master pane
, ("M-S-<Down>", sendMessage (IncMasterN (-1))) -- Decrease # of clients master pane
, ("M-C-<Up>", increaseLimit) -- Increase # of windows
, ("M-C-<Down>", decreaseLimit) -- Decrease # of windows
-- Window resizing
-- KB_GROUP Window resizing
, ("M-h", sendMessage Shrink) -- Shrink horiz window width
, ("M-l", sendMessage Expand) -- Expand horiz window width
, ("M-M1-j", sendMessage MirrorShrink) -- Shrink vert window width
, ("M-M1-k", sendMessage MirrorExpand) -- Expand vert window width
-- Sublayouts
-- KB_GROUP Sublayouts
-- This is used to push windows to tabbed sublayouts, or pull them out of it.
, ("M-C-h", sendMessage $ pullGroup L)
, ("M-C-l", sendMessage $ pullGroup R)
@ -546,7 +549,7 @@ myKeys =
, ("M-C-.", onGroup W.focusUp') -- Switch focus to next tab
, ("M-C-,", onGroup W.focusDown') -- Switch focus to prev tab
-- Scratchpads
-- KB_GROUP Scratchpads
-- Toggle show/hide these programs. They run on a hidden workspace.
-- When you toggle them to show, it brings them to your current workspace.
-- Toggle them to hide and it sends them back to hidden workspace (NSP).
@ -554,19 +557,20 @@ myKeys =
, ("C-s m", namedScratchpadAction myScratchPads "mocp")
, ("C-s c", namedScratchpadAction myScratchPads "calculator")
-- KB_GROUP Set wallpaper
-- Set wallpaper with 'feh'. Type 'SUPER+F1' to launch sxiv in the wallpapers directory.
-- Then in sxiv, type 'C-x w' to set the wallpaper that you choose.
, ("M-<F1>", spawn "sxiv -r -q -t -o ~/wallpapers/*")
, ("M-<F2>", spawn "find ~/wallpapers/ -type f | shuf -n 1 | xargs xwallpaper --stretch")
--, ("M-<F2>", spawn "feh --randomize --bg-fill ~/wallpapers/*")
-- , ("M-<F2>", spawn "feh --randomize --bg-fill ~/wallpapers/*")
-- Controls for mocp music player (SUPER-u followed by a key)
-- KB_GROUP Controls for mocp music player (SUPER-u followed by a key)
, ("M-u p", spawn "mocp --play")
, ("M-u l", spawn "mocp --next")
, ("M-u h", spawn "mocp --previous")
, ("M-u <Space>", spawn "mocp --toggle-pause")
-- Emacs (CTRL-e followed by a key)
-- KB_GROUP Emacs (CTRL-e followed by a key)
-- , ("C-e e", spawn myEmacs) -- start emacs
, ("C-e e", spawn (myEmacs ++ ("--eval '(dashboard-refresh-buffer)'"))) -- emacs dashboard
, ("C-e b", spawn (myEmacs ++ ("--eval '(ibuffer)'"))) -- list buffers
@ -583,7 +587,7 @@ myKeys =
-- emms is an emacs audio player. I set it to auto start playing in a specific directory.
, ("C-e a", spawn (myEmacs ++ ("--eval '(emms)' --eval '(emms-play-directory-tree \"~/Music/Non-Classical/70s-80s/\")'")))
-- Multimedia Keys
-- KB_GROUP Multimedia Keys
, ("<XF86AudioPlay>", spawn (myTerminal ++ "mocp --play"))
, ("<XF86AudioPrev>", spawn (myTerminal ++ "mocp --previous"))
, ("<XF86AudioNext>", spawn (myTerminal ++ "mocp --next"))
@ -600,6 +604,7 @@ myKeys =
-- The following lines are needed for named scratchpads.
where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP"))
nonEmptyNonNSP = WSIs (return (\ws -> isJust (W.stack ws) && W.tag ws /= "NSP"))
-- END_KEYS
#+END_SRC
* Main

View File

@ -28,7 +28,7 @@ import qualified Data.Map as M
import XMonad.Hooks.DynamicLog (dynamicLogWithPP, wrap, xmobarPP, xmobarColor, shorten, PP(..))
import XMonad.Hooks.EwmhDesktops -- for some fullscreen events, also for xcomposite in obs.
import XMonad.Hooks.ManageDocks (avoidStruts, docksEventHook, manageDocks, ToggleStruts(..))
import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat)
import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat, doCenterFloat)
import XMonad.Hooks.ServerMode
import XMonad.Hooks.SetWMName
import XMonad.Hooks.WorkspaceHistory
@ -329,6 +329,7 @@ myManageHook = composeAll
, className =? "pinentry-gtk-2" --> doFloat
, className =? "splash" --> doFloat
, className =? "toolbar" --> doFloat
, className =? "Yad" --> doCenterFloat
, title =? "Oracle VM VirtualBox Manager" --> doFloat
, title =? "Mozilla Firefox" --> doShift ( myWorkspaces !! 1 )
, className =? "brave-browser" --> doShift ( myWorkspaces !! 1 )
@ -340,17 +341,19 @@ myManageHook = composeAll
, isFullscreen --> doFullFloat
] <+> namedScratchpadManageHook myScratchPads
-- START_KEYS
myKeys :: [(String, X ())]
myKeys =
-- Xmonad
-- KB_GROUP Xmonad
[ ("M-C-r", spawn "xmonad --recompile") -- Recompiles xmonad
, ("M-S-r", spawn "xmonad --restart") -- Restarts xmonad
, ("M-S-q", io exitSuccess) -- Quits xmonad
, ("M-S-/", spawn "~/.xmonad/xmonad_keys.sh")
-- Run Prompt
-- KB_GROUP Run Prompt
, ("M-S-<Return>", spawn "dmenu_run -i -p \"Run: \"") -- Dmenu
-- Other Dmenu Prompts
-- KB_GROUP Other Dmenu Prompts
-- In Xmonad and many tiling window managers, M-p is the default keybinding to
-- launch dmenu_run, so I've decided to use M-p plus KEY for these dmenu scripts.
, ("M-p a", spawn "dm-sounds") -- choose an ambient background
@ -366,38 +369,38 @@ myKeys =
, ("M-p r", spawn "dm-reddit") -- reddio (a reddit viewer)
, ("M-p s", spawn "dm-websearch") -- search various search engines
-- Useful programs to have a keybinding for launch
-- KB_GROUP Useful programs to have a keybinding for launch
, ("M-<Return>", spawn (myTerminal))
, ("M-b", spawn (myBrowser ++ " www.youtube.com/c/DistroTube/"))
, ("M-M1-h", spawn (myTerminal ++ " -e htop"))
-- Kill windows
-- KB_GROUP Kill windows
, ("M-S-c", kill1) -- Kill the currently focused client
, ("M-S-a", killAll) -- Kill all windows on current workspace
-- Workspaces
-- KB_GROUP Workspaces
, ("M-.", nextScreen) -- Switch focus to next monitor
, ("M-,", prevScreen) -- Switch focus to prev monitor
, ("M-S-<KP_Add>", shiftTo Next nonNSP >> moveTo Next nonNSP) -- Shifts focused window to next ws
, ("M-S-<KP_Subtract>", shiftTo Prev nonNSP >> moveTo Prev nonNSP) -- Shifts focused window to prev ws
-- Floating windows
-- KB_GROUP Floating windows
, ("M-f", sendMessage (T.Toggle "floats")) -- Toggles my 'floats' layout
, ("M-t", withFocused $ windows . W.sink) -- Push floating window back to tile
, ("M-S-t", sinkAll) -- Push ALL floating windows to tile
-- Increase/decrease spacing (gaps)
-- KB_GROUP Increase/decrease spacing (gaps)
, ("C-M1-j", decWindowSpacing 4) -- Decrease window spacing
, ("C-M1-k", incWindowSpacing 4) -- Increase window spacing
, ("C-M1-h", decScreenSpacing 4) -- Decrease screen spacing
, ("C-M1-l", incScreenSpacing 4) -- Increase screen spacing
-- Grid Select (CTR-g followed by a key)
-- KB_GROUP Grid Select (CTR-g followed by a key)
, ("C-g g", spawnSelected' myAppGrid) -- grid select favorite apps
, ("C-g t", goToSelected $ mygridConfig myColorizer) -- goto selected window
, ("C-g b", bringSelected $ mygridConfig myColorizer) -- bring selected window
-- Windows navigation
-- KB_GROUP Windows navigation
, ("M-m", windows W.focusMaster) -- Move focus to the master window
, ("M-j", windows W.focusDown) -- Move focus to the next window
, ("M-k", windows W.focusUp) -- Move focus to the prev window
@ -408,23 +411,23 @@ myKeys =
, ("M-S-<Tab>", rotSlavesDown) -- Rotate all windows except master and keep focus in place
, ("M-C-<Tab>", rotAllDown) -- Rotate all the windows in the current stack
-- Layouts
-- KB_GROUP Layouts
, ("M-<Tab>", sendMessage NextLayout) -- Switch to next layout
, ("M-<Space>", sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts) -- Toggles noborder/full
-- Increase/decrease windows in the master pane or the stack
-- KB_GROUP Increase/decrease windows in the master pane or the stack
, ("M-S-<Up>", sendMessage (IncMasterN 1)) -- Increase # of clients master pane
, ("M-S-<Down>", sendMessage (IncMasterN (-1))) -- Decrease # of clients master pane
, ("M-C-<Up>", increaseLimit) -- Increase # of windows
, ("M-C-<Down>", decreaseLimit) -- Decrease # of windows
-- Window resizing
-- KB_GROUP Window resizing
, ("M-h", sendMessage Shrink) -- Shrink horiz window width
, ("M-l", sendMessage Expand) -- Expand horiz window width
, ("M-M1-j", sendMessage MirrorShrink) -- Shrink vert window width
, ("M-M1-k", sendMessage MirrorExpand) -- Expand vert window width
-- Sublayouts
-- KB_GROUP Sublayouts
-- This is used to push windows to tabbed sublayouts, or pull them out of it.
, ("M-C-h", sendMessage $ pullGroup L)
, ("M-C-l", sendMessage $ pullGroup R)
@ -436,7 +439,7 @@ myKeys =
, ("M-C-.", onGroup W.focusUp') -- Switch focus to next tab
, ("M-C-,", onGroup W.focusDown') -- Switch focus to prev tab
-- Scratchpads
-- KB_GROUP Scratchpads
-- Toggle show/hide these programs. They run on a hidden workspace.
-- When you toggle them to show, it brings them to your current workspace.
-- Toggle them to hide and it sends them back to hidden workspace (NSP).
@ -444,19 +447,20 @@ myKeys =
, ("C-s m", namedScratchpadAction myScratchPads "mocp")
, ("C-s c", namedScratchpadAction myScratchPads "calculator")
-- KB_GROUP Set wallpaper
-- Set wallpaper with 'feh'. Type 'SUPER+F1' to launch sxiv in the wallpapers directory.
-- Then in sxiv, type 'C-x w' to set the wallpaper that you choose.
, ("M-<F1>", spawn "sxiv -r -q -t -o ~/wallpapers/*")
, ("M-<F2>", spawn "find ~/wallpapers/ -type f | shuf -n 1 | xargs xwallpaper --stretch")
--, ("M-<F2>", spawn "feh --randomize --bg-fill ~/wallpapers/*")
-- , ("M-<F2>", spawn "feh --randomize --bg-fill ~/wallpapers/*")
-- Controls for mocp music player (SUPER-u followed by a key)
-- KB_GROUP Controls for mocp music player (SUPER-u followed by a key)
, ("M-u p", spawn "mocp --play")
, ("M-u l", spawn "mocp --next")
, ("M-u h", spawn "mocp --previous")
, ("M-u <Space>", spawn "mocp --toggle-pause")
-- Emacs (CTRL-e followed by a key)
-- KB_GROUP Emacs (CTRL-e followed by a key)
-- , ("C-e e", spawn myEmacs) -- start emacs
, ("C-e e", spawn (myEmacs ++ ("--eval '(dashboard-refresh-buffer)'"))) -- emacs dashboard
, ("C-e b", spawn (myEmacs ++ ("--eval '(ibuffer)'"))) -- list buffers
@ -473,7 +477,7 @@ myKeys =
-- emms is an emacs audio player. I set it to auto start playing in a specific directory.
, ("C-e a", spawn (myEmacs ++ ("--eval '(emms)' --eval '(emms-play-directory-tree \"~/Music/Non-Classical/70s-80s/\")'")))
-- Multimedia Keys
-- KB_GROUP Multimedia Keys
, ("<XF86AudioPlay>", spawn (myTerminal ++ "mocp --play"))
, ("<XF86AudioPrev>", spawn (myTerminal ++ "mocp --previous"))
, ("<XF86AudioNext>", spawn (myTerminal ++ "mocp --next"))
@ -490,6 +494,7 @@ myKeys =
-- The following lines are needed for named scratchpads.
where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP"))
nonEmptyNonNSP = WSIs (return (\ws -> isJust (W.stack ws) && W.tag ws /= "NSP"))
-- END_KEYS
main :: IO ()
main = do

15
.xmonad/xmonad_keys.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
sed -n '/START_KEYS/,/END_KEYS/p' ~/.xmonad/xmonad.hs | \
grep -e ', ("' \
-e '\[ (' \
-e 'KB_GROUP' | \
grep -v '\-\- , ("' | \
sed -e 's/^[ \t]*//' \
-e 's/, (/(/' \
-e 's/\[ (/(/' \
-e 's/-- KB_GROUP /\n/' \
-e 's/", /"\t: /' | \
yad --text-info --back=#282c34 --fore=#46d9ff --geometry=1200x800