Adding NamedActions to xmonad to display all keybindings.

This commit is contained in:
Derek Taylor
2022-06-19 18:49:37 -05:00
parent 404d307e3d
commit 780cfcce88
2 changed files with 228 additions and 224 deletions
+114 -112
View File
@@ -42,7 +42,7 @@ These are Haskell modules that we must import so that we can use their functions
-- Base -- Base
import XMonad import XMonad
import System.Directory import System.Directory
import System.IO (hPutStrLn) import System.IO (hClose, hPutStr, hPutStrLn)
import System.Exit (exitSuccess) import System.Exit (exitSuccess)
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
@@ -102,7 +102,8 @@ import qualified XMonad.Layout.MultiToggle as MT (Toggle(..))
-- Utilities -- Utilities
import XMonad.Util.Dmenu import XMonad.Util.Dmenu
import XMonad.Util.EZConfig (additionalKeysP) import XMonad.Util.EZConfig (additionalKeysP, mkNamedKeymap)
import XMonad.Util.NamedActions
import XMonad.Util.NamedScratchpad import XMonad.Util.NamedScratchpad
import XMonad.Util.Run (runProcessWithInput, safeSpawn, spawnPipe) import XMonad.Util.Run (runProcessWithInput, safeSpawn, spawnPipe)
import XMonad.Util.SpawnOnce import XMonad.Util.SpawnOnce
@@ -497,152 +498,153 @@ I am using the Xmonad.Util.EZConfig module which allows keybindings to be writte
| MODKEY + t | force floating window back into tiling | | MODKEY + t | force floating window back into tiling |
#+BEGIN_SRC haskell #+BEGIN_SRC haskell
-- START_KEYS showKeybindings :: [((KeyMask, KeySym), NamedAction)] -> NamedAction
myKeys :: [(String, X ())] showKeybindings x = addName "Show Keybindings" $ io $ do
myKeys = h <- spawnPipe $ "yad --text-info --fontname=" ++ myFont ++ " --width 800 --height 600 --center --title \"XMonad keybindings\""
hPutStr h (unlines $ showKm x)
hClose h
return ()
myKeys :: XConfig l0 -> [((KeyMask, KeySym), NamedAction)]
myKeys c = (subtitle "Custom Keys":) $ mkNamedKeymap c $
-- KB_GROUP Xmonad -- KB_GROUP Xmonad
[ ("M-C-r", spawn "xmonad --recompile") -- Recompiles xmonad [ ("M-C-r", addName "Recompile XMonad" $ spawn "xmonad --recompile")
, ("M-S-r", spawn "xmonad --restart") -- Restarts xmonad , ("M-S-r", addName "Restart XMonad" $ spawn "xmonad --restart")
, ("M-S-q", sequence_ [spawn (mySoundPlayer ++ shutdownSound) , ("M-S-q", addName "Quit XMonad" $ sequence_ [spawn (mySoundPlayer ++ shutdownSound), io exitSuccess])
, io exitSuccess]) -- Quits xmonad , ("M-S-/", addName "List all keybindings" $ spawn "~/.xmonad/xmonad_keys.sh")
, ("M-/", addName "DTOS Help" $ spawn "dtos-help")
-- KB_GROUP Get Help , ("M-S-<Return>", addName "Run prompt" $ sequence_ [spawn (mySoundPlayer ++ dmenuSound), spawn "dm-run"])
, ("M-S-/", spawn "~/.xmonad/xmonad_keys.sh") -- Get list of keybindings
, ("M-/", spawn "dtos-help") -- DTOS help/tutorial videos
-- KB_GROUP Run Prompt
, ("M-S-<Return>", sequence_ [spawn (mySoundPlayer ++ dmenuSound)
, spawn "dm-run"]) -- Dmenu
-- KB_GROUP Other Dmenu Prompts
-- In Xmonad and many tiling window managers, M-p is the default keybinding to -- 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. -- launch dmenu_run, so I've decided to use M-p plus KEY for these dmenu scripts.
, ("M-p h", spawn "dm-hub") -- allows access to all dmscripts , ("M-p h", addName "List all dmscripts" $ spawn "dm-hub")
, ("M-p a", spawn "dm-sounds") -- choose an ambient background , ("M-p a", addName "Choose ambient sound" $ spawn "dm-sounds")
, ("M-p b", spawn "dm-setbg") -- set a background , ("M-p b", addName "Set background" $ spawn "dm-setbg")
, ("M-p c", spawn "dtos-colorscheme") -- choose a colorscheme , ("M-p c", addName "Choose color scheme" $ spawn "dtos-colorscheme")
, ("M-p C", spawn "dm-colpick") -- pick color from our scheme , ("M-p C", addName "Pick color from scheme" $ spawn "dm-colpick")
, ("M-p e", spawn "dm-confedit") -- edit config files , ("M-p e", addName "Edit config files" $ spawn "dm-confedit")
, ("M-p i", spawn "dm-maim") -- screenshots (images) , ("M-p i", addName "Take a screenshot" $ spawn "dm-maim")
, ("M-p k", spawn "dm-kill") -- kill processes , ("M-p k", addName "Kill processes" $ spawn "dm-kill")
, ("M-p m", spawn "dm-man") -- manpages , ("M-p m", addName "View manpages" $ spawn "dm-man")
, ("M-p n", spawn "dm-note") -- store one-line notes and copy them , ("M-p n", addName "Store and copy notes" $ spawn "dm-note")
, ("M-p o", spawn "dm-bookman") -- qutebrowser bookmarks/history , ("M-p o", addName "Browser bookmarks" $ spawn "dm-bookman")
, ("M-p p", spawn "passmenu -p \"Pass: \"") -- passmenu , ("M-p p", addName "Passmenu" $ spawn "passmenu -p \"Pass: \"")
, ("M-p q", spawn "dm-logout") -- logout menu , ("M-p q", addName "Logout Menu" $ spawn "dm-logout")
, ("M-p r", spawn "dm-radio") -- online radio , ("M-p r", addName "Listen to online radio" $ spawn "dm-radio")
, ("M-p s", spawn "dm-websearch") -- search various search engines , ("M-p s", addName "Search various engines" $ spawn "dm-websearch")
, ("M-p t", spawn "dm-translate") -- translate text (Google Translate) , ("M-p t", addName "Translate text" $ spawn "dm-translate")
-- KB_GROUP Useful programs to have a keybinding for launch -- KB_GROUP Useful programs to have a keybinding for launch
, ("M-<Return>", spawn (myTerminal)) , ("M-<Return>", addName "Launch terminal" $ spawn (myTerminal))
, ("M-b", spawn (myBrowser)) , ("M-b", addName "Launch web browser" $ spawn (myBrowser))
, ("M-M1-h", spawn (myTerminal ++ " -e htop")) , ("M-M1-h", addName "Launch htop" $ spawn (myTerminal ++ " -e htop"))
-- KB_GROUP Kill windows -- KB_GROUP Kill windows
, ("M-S-c", kill1) -- Kill the currently focused client , ("M-S-c", addName "Kill focused window" $ kill1)
, ("M-S-a", killAll) -- Kill all windows on current workspace , ("M-S-a", addName "Kill all windows on WS" $ killAll)
-- KB_GROUP Workspaces -- KB_GROUP Workspaces
, ("M-.", nextScreen) -- Switch focus to next monitor , ("M-.", addName "Switch focus to next mon" $ nextScreen)
, ("M-,", prevScreen) -- Switch focus to prev monitor , ("M-,", addName "Switch focus to prev mon" $ prevScreen)
, ("M-S-<KP_Add>", shiftTo Next nonNSP >> moveTo Next nonNSP) -- Shifts focused window to next ws , ("M-S-<KP_Add>"
, ("M-S-<KP_Subtract>", shiftTo Prev nonNSP >> moveTo Prev nonNSP) -- Shifts focused window to prev ws , addName "Move window to next WS" $ shiftTo Next nonNSP >> moveTo Next nonNSP)
, ("M-S-<KP_Subtract>"
, addName "Move window to prev WS" $ shiftTo Prev nonNSP >> moveTo Prev nonNSP)
-- KB_GROUP Floating windows -- KB_GROUP Floating windows
, ("M-f", sendMessage (T.Toggle "floats")) -- Toggles my 'floats' layout , ("M-f", addName "Toggle float layout" $ sendMessage (T.Toggle "floats"))
, ("M-t", withFocused $ windows . W.sink) -- Push floating window back to tile , ("M-t", addName "Sink a floating window" $ withFocused $ windows . W.sink)
, ("M-S-t", sinkAll) -- Push ALL floating windows to tile , ("M-S-t", addName "Sink all floated windows" $ sinkAll)
-- KB_GROUP Increase/decrease spacing (gaps) -- KB_GROUP Increase/decrease spacing (gaps)
, ("C-M1-j", decWindowSpacing 4) -- Decrease window spacing , ("C-M1-j", addName "Decrease window spacing" $ decWindowSpacing 4)
, ("C-M1-k", incWindowSpacing 4) -- Increase window spacing , ("C-M1-k", addName "Increase window spacing" $ incWindowSpacing 4)
, ("C-M1-h", decScreenSpacing 4) -- Decrease screen spacing , ("C-M1-h", addName "Decrease screen spacing" $ decScreenSpacing 4)
, ("C-M1-l", incScreenSpacing 4) -- Increase screen spacing , ("C-M1-l", addName "Increase screen spacing" $ incScreenSpacing 4)
-- KB_GROUP 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 g", addName "Select favorite apps" $ spawnSelected' myAppGrid)
, ("C-g t", goToSelected $ mygridConfig myColorizer) -- goto selected window , ("C-g t", addName "Goto selected window" $ goToSelected $ mygridConfig myColorizer)
, ("C-g b", bringSelected $ mygridConfig myColorizer) -- bring selected window , ("C-g b", addName "Bring selected window" $ bringSelected $ mygridConfig myColorizer)
-- KB_GROUP Windows navigation -- KB_GROUP Windows navigation
, ("M-m", windows W.focusMaster) -- Move focus to the master window , ("M-m", addName "" $ windows W.focusMaster) -- Move focus to the master window
, ("M-j", windows W.focusDown) -- Move focus to the next window , ("M-j", addName "" $ windows W.focusDown) -- Move focus to the next window
, ("M-k", windows W.focusUp) -- Move focus to the prev window , ("M-k", addName "" $ windows W.focusUp) -- Move focus to the prev window
, ("M-S-m", windows W.swapMaster) -- Swap the focused window and the master window , ("M-S-m", addName "" $ windows W.swapMaster) -- Swap the focused window and the master window
, ("M-S-j", windows W.swapDown) -- Swap focused window with next window , ("M-S-j", addName "" $ windows W.swapDown) -- Swap focused window with next window
, ("M-S-k", windows W.swapUp) -- Swap focused window with prev window , ("M-S-k", addName "" $ windows W.swapUp) -- Swap focused window with prev window
, ("M-<Backspace>", promote) -- Moves focused window to master, others maintain order , ("M-<Backspace>", addName "" $ promote) -- Moves focused window to master, others maintain order
, ("M-S-<Tab>", rotSlavesDown) -- Rotate all windows except master and keep focus in place , ("M-S-<Tab>", addName "" $ rotSlavesDown) -- Rotate all windows except master and keep focus in place
, ("M-C-<Tab>", rotAllDown) -- Rotate all the windows in the current stack , ("M-C-<Tab>", addName "" $ rotAllDown) -- Rotate all the windows in the current stack
-- KB_GROUP Layouts -- KB_GROUP Layouts
, ("M-<Tab>", sendMessage NextLayout) -- Switch to next layout , ("M-<Tab>", addName "" $ sendMessage NextLayout) -- Switch to next layout
, ("M-<Space>", sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts) -- Toggles noborder/full , ("M-<Space>", addName "" $ sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts) -- Toggles noborder/full
-- KB_GROUP 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-<Up>", addName "" $ sendMessage (IncMasterN 1)) -- Increase # of clients master pane
, ("M-S-<Down>", sendMessage (IncMasterN (-1))) -- Decrease # of clients master pane , ("M-S-<Down>", addName "" $ sendMessage (IncMasterN (-1))) -- Decrease # of clients master pane
, ("M-C-<Up>", increaseLimit) -- Increase # of windows , ("M-C-<Up>", addName "" $ increaseLimit) -- Increase # of windows
, ("M-C-<Down>", decreaseLimit) -- Decrease # of windows , ("M-C-<Down>", addName "" $ decreaseLimit) -- Decrease # of windows
-- KB_GROUP Window resizing -- KB_GROUP Window resizing
, ("M-h", sendMessage Shrink) -- Shrink horiz window width , ("M-h", addName "Shrink window" $ sendMessage Shrink) -- Shrink horiz window width
, ("M-l", sendMessage Expand) -- Expand horiz window width , ("M-l", addName "Expand window" $ sendMessage Expand) -- Expand horiz window width
, ("M-M1-j", sendMessage MirrorShrink) -- Shrink vert window width , ("M-M1-j", addName "Shrink window vertically" $ sendMessage MirrorShrink) -- Shrink vert window width
, ("M-M1-k", sendMessage MirrorExpand) -- Expand vert window width , ("M-M1-k", addName "Expand window vertically" $ sendMessage MirrorExpand) -- Expand vert window width
-- KB_GROUP Sublayouts -- KB_GROUP Sublayouts
-- This is used to push windows to tabbed sublayouts, or pull them out of it. -- This is used to push windows to tabbed sublayouts, or pull them out of it.
, ("M-C-h", sendMessage $ pullGroup L) , ("M-C-h", addName "" $ sendMessage $ pullGroup L)
, ("M-C-l", sendMessage $ pullGroup R) , ("M-C-l", addName "" $ sendMessage $ pullGroup R)
, ("M-C-k", sendMessage $ pullGroup U) , ("M-C-k", addName "" $ sendMessage $ pullGroup U)
, ("M-C-j", sendMessage $ pullGroup D) , ("M-C-j", addName "" $ sendMessage $ pullGroup D)
, ("M-C-m", withFocused (sendMessage . MergeAll)) , ("M-C-m", addName "" $ withFocused (sendMessage . MergeAll))
-- , ("M-C-u", withFocused (sendMessage . UnMerge)) -- , ("M-C-u", withFocused (sendMessage . UnMerge))
, ("M-C-/", withFocused (sendMessage . UnMergeAll)) , ("M-C-/", addName "" $ withFocused (sendMessage . UnMergeAll))
, ("M-C-.", onGroup W.focusUp') -- Switch focus to next tab , ("M-C-.", addName "" $ onGroup W.focusUp') -- Switch focus to next tab
, ("M-C-,", onGroup W.focusDown') -- Switch focus to prev tab , ("M-C-,", addName "" $ onGroup W.focusDown') -- Switch focus to prev tab
-- KB_GROUP Scratchpads -- KB_GROUP Scratchpads
-- Toggle show/hide these programs. They run on a hidden workspace. -- Toggle show/hide these programs. They run on a hidden workspace.
-- When you toggle them to show, it brings them to your current 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). -- Toggle them to hide and it sends them back to hidden workspace (NSP).
, ("M-s t", namedScratchpadAction myScratchPads "terminal") , ("M-s t", addName "" $ namedScratchpadAction myScratchPads "terminal")
, ("M-s m", namedScratchpadAction myScratchPads "mocp") , ("M-s m", addName "" $ namedScratchpadAction myScratchPads "mocp")
, ("M-s c", namedScratchpadAction myScratchPads "calculator") , ("M-s c", addName "" $ namedScratchpadAction myScratchPads "calculator")
-- KB_GROUP 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 p", addName "" $ spawn "mocp --play")
, ("M-u l", spawn "mocp --next") , ("M-u l", addName "" $ spawn "mocp --next")
, ("M-u h", spawn "mocp --previous") , ("M-u h", addName "" $ spawn "mocp --previous")
, ("M-u <Space>", spawn "mocp --toggle-pause") , ("M-u <Space>", addName "" $ spawn "mocp --toggle-pause")
-- KB_GROUP Emacs (SUPER-e followed by a key) -- KB_GROUP Emacs (SUPER-e followed by a key)
, ("M-e e", spawn (myEmacs ++ ("--eval '(dashboard-refresh-buffer)'"))) -- emacs dashboard , ("M-e e", addName "" $ spawn (myEmacs ++ ("--eval '(dashboard-refresh-buffer)'"))) -- emacs dashboard
, ("M-e b", spawn (myEmacs ++ ("--eval '(ibuffer)'"))) -- list buffers , ("M-e b", addName "" $ spawn (myEmacs ++ ("--eval '(ibuffer)'"))) -- list buffers
, ("M-e d", spawn (myEmacs ++ ("--eval '(dired nil)'"))) -- dired , ("M-e d", addName "" $ spawn (myEmacs ++ ("--eval '(dired nil)'"))) -- dired
, ("M-e i", spawn (myEmacs ++ ("--eval '(erc)'"))) -- erc irc client , ("M-e i", addName "" $ spawn (myEmacs ++ ("--eval '(erc)'"))) -- erc irc client
, ("M-e n", spawn (myEmacs ++ ("--eval '(elfeed)'"))) -- elfeed rss , ("M-e n", addName "" $ spawn (myEmacs ++ ("--eval '(elfeed)'"))) -- elfeed rss
, ("M-e s", spawn (myEmacs ++ ("--eval '(eshell)'"))) -- eshell , ("M-e s", addName "" $ spawn (myEmacs ++ ("--eval '(eshell)'"))) -- eshell
, ("M-e t", spawn (myEmacs ++ ("--eval '(mastodon)'"))) -- mastodon.el , ("M-e t", addName "" $ spawn (myEmacs ++ ("--eval '(mastodon)'"))) -- mastodon.el
, ("M-e v", spawn (myEmacs ++ ("--eval '(+vterm/here nil)'"))) -- vterm if on Doom Emacs , ("M-e v", addName "" $ spawn (myEmacs ++ ("--eval '(+vterm/here nil)'"))) -- vterm if on Doom Emacs
, ("M-e w", spawn (myEmacs ++ ("--eval '(doom/window-maximize-buffer(eww \"distro.tube\"))'"))) -- eww browser if on Doom Emacs , ("M-e w", addName "" $ spawn (myEmacs ++ ("--eval '(doom/window-maximize-buffer(eww \"distro.tube\"))'"))) -- eww browser if on Doom Emacs
, ("M-e a", spawn (myEmacs ++ ("--eval '(emms)' --eval '(emms-play-directory-tree \"~/Music/\")'"))) , ("M-e a", addName "" $ spawn (myEmacs ++ ("--eval '(emms)' --eval '(emms-play-directory-tree \"~/Music/\")'")))
-- KB_GROUP Multimedia Keys -- KB_GROUP Multimedia Keys
, ("<XF86AudioPlay>", spawn "mocp --play") , ("<XF86AudioPlay>", addName "" $ spawn "mocp --play")
, ("<XF86AudioPrev>", spawn "mocp --previous") , ("<XF86AudioPrev>", addName "" $ spawn "mocp --previous")
, ("<XF86AudioNext>", spawn "mocp --next") , ("<XF86AudioNext>", addName "" $ spawn "mocp --next")
, ("<XF86AudioMute>", spawn "amixer set Master toggle") , ("<XF86AudioMute>", addName "" $ spawn "amixer set Master toggle")
, ("<XF86AudioLowerVolume>", spawn "amixer set Master 5%- unmute") , ("<XF86AudioLowerVolume>", addName "" $ spawn "amixer set Master 5%- unmute")
, ("<XF86AudioRaiseVolume>", spawn "amixer set Master 5%+ unmute") , ("<XF86AudioRaiseVolume>", addName "" $ spawn "amixer set Master 5%+ unmute")
, ("<XF86HomePage>", spawn "qutebrowser https://www.youtube.com/c/DistroTube") , ("<XF86HomePage>", addName "" $ spawn "qutebrowser https://www.youtube.com/c/DistroTube")
, ("<XF86Search>", spawn "dm-websearch") , ("<XF86Search>", addName "" $ spawn "dm-websearch")
, ("<XF86Mail>", runOrRaise "thunderbird" (resource =? "thunderbird")) , ("<XF86Mail>", addName "" $ runOrRaise "thunderbird" (resource =? "thunderbird"))
, ("<XF86Calculator>", runOrRaise "qalculate-gtk" (resource =? "qalculate-gtk")) , ("<XF86Calculator>", addName "" $ runOrRaise "qalculate-gtk" (resource =? "qalculate-gtk"))
, ("<XF86Eject>", spawn "toggleeject") , ("<XF86Eject>", addName "" $ spawn "toggleeject")
, ("<Print>", spawn "dm-maim") , ("<Print>", addName "" $ spawn "dm-maim")
] ]
-- The following lines are needed for named scratchpads. -- The following lines are needed for named scratchpads.
where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP")) where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP"))
@@ -661,7 +663,7 @@ main = do
xmproc1 <- spawnPipe ("xmobar -x 1 $HOME/.config/xmobar/" ++ colorScheme ++ "-xmobarrc") xmproc1 <- spawnPipe ("xmobar -x 1 $HOME/.config/xmobar/" ++ colorScheme ++ "-xmobarrc")
xmproc2 <- spawnPipe ("xmobar -x 2 $HOME/.config/xmobar/" ++ colorScheme ++ "-xmobarrc") xmproc2 <- spawnPipe ("xmobar -x 2 $HOME/.config/xmobar/" ++ colorScheme ++ "-xmobarrc")
-- the xmonad, ya know...what the WM is named after! -- the xmonad, ya know...what the WM is named after!
xmonad $ ewmh def xmonad $ addDescrKeys ((mod4Mask, xK_F1), showKeybindings) myKeys $ ewmh def
{ manageHook = myManageHook <+> manageDocks { manageHook = myManageHook <+> manageDocks
, handleEventHook = docksEventHook , handleEventHook = docksEventHook
-- Uncomment this line to enable fullscreen support on things like YouTube/Netflix. -- Uncomment this line to enable fullscreen support on things like YouTube/Netflix.
@@ -703,5 +705,5 @@ main = do
-- order of things in xmobar -- order of things in xmobar
, ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t] , ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t]
} }
} `additionalKeysP` myKeys } -- `additionalKeysP` myKeys
#+END_SRC #+END_SRC
+114 -112
View File
@@ -1,7 +1,7 @@
-- Base -- Base
import XMonad import XMonad
import System.Directory import System.Directory
import System.IO (hPutStrLn) import System.IO (hClose, hPutStr, hPutStrLn)
import System.Exit (exitSuccess) import System.Exit (exitSuccess)
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
@@ -61,7 +61,8 @@ import qualified XMonad.Layout.MultiToggle as MT (Toggle(..))
-- Utilities -- Utilities
import XMonad.Util.Dmenu import XMonad.Util.Dmenu
import XMonad.Util.EZConfig (additionalKeysP) import XMonad.Util.EZConfig (additionalKeysP, mkNamedKeymap)
import XMonad.Util.NamedActions
import XMonad.Util.NamedScratchpad import XMonad.Util.NamedScratchpad
import XMonad.Util.Run (runProcessWithInput, safeSpawn, spawnPipe) import XMonad.Util.Run (runProcessWithInput, safeSpawn, spawnPipe)
import XMonad.Util.SpawnOnce import XMonad.Util.SpawnOnce
@@ -365,152 +366,153 @@ startupSound = soundDir ++ "startup-01.mp3"
shutdownSound = soundDir ++ "shutdown-01.mp3" shutdownSound = soundDir ++ "shutdown-01.mp3"
dmenuSound = soundDir ++ "menu-01.mp3" dmenuSound = soundDir ++ "menu-01.mp3"
-- START_KEYS showKeybindings :: [((KeyMask, KeySym), NamedAction)] -> NamedAction
myKeys :: [(String, X ())] showKeybindings x = addName "Show Keybindings" $ io $ do
myKeys = h <- spawnPipe $ "yad --text-info --fontname=" ++ myFont ++ " --width 800 --height 600 --center --title \"XMonad keybindings\""
hPutStr h (unlines $ showKm x)
hClose h
return ()
myKeys :: XConfig l0 -> [((KeyMask, KeySym), NamedAction)]
myKeys c = (subtitle "Custom Keys":) $ mkNamedKeymap c $
-- KB_GROUP Xmonad -- KB_GROUP Xmonad
[ ("M-C-r", spawn "xmonad --recompile") -- Recompiles xmonad [ ("M-C-r", addName "Recompile XMonad" $ spawn "xmonad --recompile")
, ("M-S-r", spawn "xmonad --restart") -- Restarts xmonad , ("M-S-r", addName "Restart XMonad" $ spawn "xmonad --restart")
, ("M-S-q", sequence_ [spawn (mySoundPlayer ++ shutdownSound) , ("M-S-q", addName "Quit XMonad" $ sequence_ [spawn (mySoundPlayer ++ shutdownSound), io exitSuccess])
, io exitSuccess]) -- Quits xmonad , ("M-S-/", addName "List all keybindings" $ spawn "~/.xmonad/xmonad_keys.sh")
, ("M-/", addName "DTOS Help" $ spawn "dtos-help")
-- KB_GROUP Get Help , ("M-S-<Return>", addName "Run prompt" $ sequence_ [spawn (mySoundPlayer ++ dmenuSound), spawn "dm-run"])
, ("M-S-/", spawn "~/.xmonad/xmonad_keys.sh") -- Get list of keybindings
, ("M-/", spawn "dtos-help") -- DTOS help/tutorial videos
-- KB_GROUP Run Prompt
, ("M-S-<Return>", sequence_ [spawn (mySoundPlayer ++ dmenuSound)
, spawn "dm-run"]) -- Dmenu
-- KB_GROUP Other Dmenu Prompts
-- In Xmonad and many tiling window managers, M-p is the default keybinding to -- 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. -- launch dmenu_run, so I've decided to use M-p plus KEY for these dmenu scripts.
, ("M-p h", spawn "dm-hub") -- allows access to all dmscripts , ("M-p h", addName "List all dmscripts" $ spawn "dm-hub")
, ("M-p a", spawn "dm-sounds") -- choose an ambient background , ("M-p a", addName "Choose ambient sound" $ spawn "dm-sounds")
, ("M-p b", spawn "dm-setbg") -- set a background , ("M-p b", addName "Set background" $ spawn "dm-setbg")
, ("M-p c", spawn "dtos-colorscheme") -- choose a colorscheme , ("M-p c", addName "Choose color scheme" $ spawn "dtos-colorscheme")
, ("M-p C", spawn "dm-colpick") -- pick color from our scheme , ("M-p C", addName "Pick color from scheme" $ spawn "dm-colpick")
, ("M-p e", spawn "dm-confedit") -- edit config files , ("M-p e", addName "Edit config files" $ spawn "dm-confedit")
, ("M-p i", spawn "dm-maim") -- screenshots (images) , ("M-p i", addName "Take a screenshot" $ spawn "dm-maim")
, ("M-p k", spawn "dm-kill") -- kill processes , ("M-p k", addName "Kill processes" $ spawn "dm-kill")
, ("M-p m", spawn "dm-man") -- manpages , ("M-p m", addName "View manpages" $ spawn "dm-man")
, ("M-p n", spawn "dm-note") -- store one-line notes and copy them , ("M-p n", addName "Store and copy notes" $ spawn "dm-note")
, ("M-p o", spawn "dm-bookman") -- qutebrowser bookmarks/history , ("M-p o", addName "Browser bookmarks" $ spawn "dm-bookman")
, ("M-p p", spawn "passmenu -p \"Pass: \"") -- passmenu , ("M-p p", addName "Passmenu" $ spawn "passmenu -p \"Pass: \"")
, ("M-p q", spawn "dm-logout") -- logout menu , ("M-p q", addName "Logout Menu" $ spawn "dm-logout")
, ("M-p r", spawn "dm-radio") -- online radio , ("M-p r", addName "Listen to online radio" $ spawn "dm-radio")
, ("M-p s", spawn "dm-websearch") -- search various search engines , ("M-p s", addName "Search various engines" $ spawn "dm-websearch")
, ("M-p t", spawn "dm-translate") -- translate text (Google Translate) , ("M-p t", addName "Translate text" $ spawn "dm-translate")
-- KB_GROUP Useful programs to have a keybinding for launch -- KB_GROUP Useful programs to have a keybinding for launch
, ("M-<Return>", spawn (myTerminal)) , ("M-<Return>", addName "Launch terminal" $ spawn (myTerminal))
, ("M-b", spawn (myBrowser)) , ("M-b", addName "Launch web browser" $ spawn (myBrowser))
, ("M-M1-h", spawn (myTerminal ++ " -e htop")) , ("M-M1-h", addName "Launch htop" $ spawn (myTerminal ++ " -e htop"))
-- KB_GROUP Kill windows -- KB_GROUP Kill windows
, ("M-S-c", kill1) -- Kill the currently focused client , ("M-S-c", addName "Kill focused window" $ kill1)
, ("M-S-a", killAll) -- Kill all windows on current workspace , ("M-S-a", addName "Kill all windows on WS" $ killAll)
-- KB_GROUP Workspaces -- KB_GROUP Workspaces
, ("M-.", nextScreen) -- Switch focus to next monitor , ("M-.", addName "Switch focus to next mon" $ nextScreen)
, ("M-,", prevScreen) -- Switch focus to prev monitor , ("M-,", addName "Switch focus to prev mon" $ prevScreen)
, ("M-S-<KP_Add>", shiftTo Next nonNSP >> moveTo Next nonNSP) -- Shifts focused window to next ws , ("M-S-<KP_Add>"
, ("M-S-<KP_Subtract>", shiftTo Prev nonNSP >> moveTo Prev nonNSP) -- Shifts focused window to prev ws , addName "Move window to next WS" $ shiftTo Next nonNSP >> moveTo Next nonNSP)
, ("M-S-<KP_Subtract>"
, addName "Move window to prev WS" $ shiftTo Prev nonNSP >> moveTo Prev nonNSP)
-- KB_GROUP Floating windows -- KB_GROUP Floating windows
, ("M-f", sendMessage (T.Toggle "floats")) -- Toggles my 'floats' layout , ("M-f", addName "Toggle float layout" $ sendMessage (T.Toggle "floats"))
, ("M-t", withFocused $ windows . W.sink) -- Push floating window back to tile , ("M-t", addName "Sink a floating window" $ withFocused $ windows . W.sink)
, ("M-S-t", sinkAll) -- Push ALL floating windows to tile , ("M-S-t", addName "Sink all floated windows" $ sinkAll)
-- KB_GROUP Increase/decrease spacing (gaps) -- KB_GROUP Increase/decrease spacing (gaps)
, ("C-M1-j", decWindowSpacing 4) -- Decrease window spacing , ("C-M1-j", addName "Decrease window spacing" $ decWindowSpacing 4)
, ("C-M1-k", incWindowSpacing 4) -- Increase window spacing , ("C-M1-k", addName "Increase window spacing" $ incWindowSpacing 4)
, ("C-M1-h", decScreenSpacing 4) -- Decrease screen spacing , ("C-M1-h", addName "Decrease screen spacing" $ decScreenSpacing 4)
, ("C-M1-l", incScreenSpacing 4) -- Increase screen spacing , ("C-M1-l", addName "Increase screen spacing" $ incScreenSpacing 4)
-- KB_GROUP 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 g", addName "Select favorite apps" $ spawnSelected' myAppGrid)
, ("C-g t", goToSelected $ mygridConfig myColorizer) -- goto selected window , ("C-g t", addName "Goto selected window" $ goToSelected $ mygridConfig myColorizer)
, ("C-g b", bringSelected $ mygridConfig myColorizer) -- bring selected window , ("C-g b", addName "Bring selected window" $ bringSelected $ mygridConfig myColorizer)
-- KB_GROUP Windows navigation -- KB_GROUP Windows navigation
, ("M-m", windows W.focusMaster) -- Move focus to the master window , ("M-m", addName "" $ windows W.focusMaster) -- Move focus to the master window
, ("M-j", windows W.focusDown) -- Move focus to the next window , ("M-j", addName "" $ windows W.focusDown) -- Move focus to the next window
, ("M-k", windows W.focusUp) -- Move focus to the prev window , ("M-k", addName "" $ windows W.focusUp) -- Move focus to the prev window
, ("M-S-m", windows W.swapMaster) -- Swap the focused window and the master window , ("M-S-m", addName "" $ windows W.swapMaster) -- Swap the focused window and the master window
, ("M-S-j", windows W.swapDown) -- Swap focused window with next window , ("M-S-j", addName "" $ windows W.swapDown) -- Swap focused window with next window
, ("M-S-k", windows W.swapUp) -- Swap focused window with prev window , ("M-S-k", addName "" $ windows W.swapUp) -- Swap focused window with prev window
, ("M-<Backspace>", promote) -- Moves focused window to master, others maintain order , ("M-<Backspace>", addName "" $ promote) -- Moves focused window to master, others maintain order
, ("M-S-<Tab>", rotSlavesDown) -- Rotate all windows except master and keep focus in place , ("M-S-<Tab>", addName "" $ rotSlavesDown) -- Rotate all windows except master and keep focus in place
, ("M-C-<Tab>", rotAllDown) -- Rotate all the windows in the current stack , ("M-C-<Tab>", addName "" $ rotAllDown) -- Rotate all the windows in the current stack
-- KB_GROUP Layouts -- KB_GROUP Layouts
, ("M-<Tab>", sendMessage NextLayout) -- Switch to next layout , ("M-<Tab>", addName "" $ sendMessage NextLayout) -- Switch to next layout
, ("M-<Space>", sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts) -- Toggles noborder/full , ("M-<Space>", addName "" $ sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts) -- Toggles noborder/full
-- KB_GROUP 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-<Up>", addName "" $ sendMessage (IncMasterN 1)) -- Increase # of clients master pane
, ("M-S-<Down>", sendMessage (IncMasterN (-1))) -- Decrease # of clients master pane , ("M-S-<Down>", addName "" $ sendMessage (IncMasterN (-1))) -- Decrease # of clients master pane
, ("M-C-<Up>", increaseLimit) -- Increase # of windows , ("M-C-<Up>", addName "" $ increaseLimit) -- Increase # of windows
, ("M-C-<Down>", decreaseLimit) -- Decrease # of windows , ("M-C-<Down>", addName "" $ decreaseLimit) -- Decrease # of windows
-- KB_GROUP Window resizing -- KB_GROUP Window resizing
, ("M-h", sendMessage Shrink) -- Shrink horiz window width , ("M-h", addName "Shrink window" $ sendMessage Shrink) -- Shrink horiz window width
, ("M-l", sendMessage Expand) -- Expand horiz window width , ("M-l", addName "Expand window" $ sendMessage Expand) -- Expand horiz window width
, ("M-M1-j", sendMessage MirrorShrink) -- Shrink vert window width , ("M-M1-j", addName "Shrink window vertically" $ sendMessage MirrorShrink) -- Shrink vert window width
, ("M-M1-k", sendMessage MirrorExpand) -- Expand vert window width , ("M-M1-k", addName "Expand window vertically" $ sendMessage MirrorExpand) -- Expand vert window width
-- KB_GROUP Sublayouts -- KB_GROUP Sublayouts
-- This is used to push windows to tabbed sublayouts, or pull them out of it. -- This is used to push windows to tabbed sublayouts, or pull them out of it.
, ("M-C-h", sendMessage $ pullGroup L) , ("M-C-h", addName "" $ sendMessage $ pullGroup L)
, ("M-C-l", sendMessage $ pullGroup R) , ("M-C-l", addName "" $ sendMessage $ pullGroup R)
, ("M-C-k", sendMessage $ pullGroup U) , ("M-C-k", addName "" $ sendMessage $ pullGroup U)
, ("M-C-j", sendMessage $ pullGroup D) , ("M-C-j", addName "" $ sendMessage $ pullGroup D)
, ("M-C-m", withFocused (sendMessage . MergeAll)) , ("M-C-m", addName "" $ withFocused (sendMessage . MergeAll))
-- , ("M-C-u", withFocused (sendMessage . UnMerge)) -- , ("M-C-u", withFocused (sendMessage . UnMerge))
, ("M-C-/", withFocused (sendMessage . UnMergeAll)) , ("M-C-/", addName "" $ withFocused (sendMessage . UnMergeAll))
, ("M-C-.", onGroup W.focusUp') -- Switch focus to next tab , ("M-C-.", addName "" $ onGroup W.focusUp') -- Switch focus to next tab
, ("M-C-,", onGroup W.focusDown') -- Switch focus to prev tab , ("M-C-,", addName "" $ onGroup W.focusDown') -- Switch focus to prev tab
-- KB_GROUP Scratchpads -- KB_GROUP Scratchpads
-- Toggle show/hide these programs. They run on a hidden workspace. -- Toggle show/hide these programs. They run on a hidden workspace.
-- When you toggle them to show, it brings them to your current 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). -- Toggle them to hide and it sends them back to hidden workspace (NSP).
, ("M-s t", namedScratchpadAction myScratchPads "terminal") , ("M-s t", addName "" $ namedScratchpadAction myScratchPads "terminal")
, ("M-s m", namedScratchpadAction myScratchPads "mocp") , ("M-s m", addName "" $ namedScratchpadAction myScratchPads "mocp")
, ("M-s c", namedScratchpadAction myScratchPads "calculator") , ("M-s c", addName "" $ namedScratchpadAction myScratchPads "calculator")
-- KB_GROUP 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 p", addName "" $ spawn "mocp --play")
, ("M-u l", spawn "mocp --next") , ("M-u l", addName "" $ spawn "mocp --next")
, ("M-u h", spawn "mocp --previous") , ("M-u h", addName "" $ spawn "mocp --previous")
, ("M-u <Space>", spawn "mocp --toggle-pause") , ("M-u <Space>", addName "" $ spawn "mocp --toggle-pause")
-- KB_GROUP Emacs (SUPER-e followed by a key) -- KB_GROUP Emacs (SUPER-e followed by a key)
, ("M-e e", spawn (myEmacs ++ ("--eval '(dashboard-refresh-buffer)'"))) -- emacs dashboard , ("M-e e", addName "" $ spawn (myEmacs ++ ("--eval '(dashboard-refresh-buffer)'"))) -- emacs dashboard
, ("M-e b", spawn (myEmacs ++ ("--eval '(ibuffer)'"))) -- list buffers , ("M-e b", addName "" $ spawn (myEmacs ++ ("--eval '(ibuffer)'"))) -- list buffers
, ("M-e d", spawn (myEmacs ++ ("--eval '(dired nil)'"))) -- dired , ("M-e d", addName "" $ spawn (myEmacs ++ ("--eval '(dired nil)'"))) -- dired
, ("M-e i", spawn (myEmacs ++ ("--eval '(erc)'"))) -- erc irc client , ("M-e i", addName "" $ spawn (myEmacs ++ ("--eval '(erc)'"))) -- erc irc client
, ("M-e n", spawn (myEmacs ++ ("--eval '(elfeed)'"))) -- elfeed rss , ("M-e n", addName "" $ spawn (myEmacs ++ ("--eval '(elfeed)'"))) -- elfeed rss
, ("M-e s", spawn (myEmacs ++ ("--eval '(eshell)'"))) -- eshell , ("M-e s", addName "" $ spawn (myEmacs ++ ("--eval '(eshell)'"))) -- eshell
, ("M-e t", spawn (myEmacs ++ ("--eval '(mastodon)'"))) -- mastodon.el , ("M-e t", addName "" $ spawn (myEmacs ++ ("--eval '(mastodon)'"))) -- mastodon.el
, ("M-e v", spawn (myEmacs ++ ("--eval '(+vterm/here nil)'"))) -- vterm if on Doom Emacs , ("M-e v", addName "" $ spawn (myEmacs ++ ("--eval '(+vterm/here nil)'"))) -- vterm if on Doom Emacs
, ("M-e w", spawn (myEmacs ++ ("--eval '(doom/window-maximize-buffer(eww \"distro.tube\"))'"))) -- eww browser if on Doom Emacs , ("M-e w", addName "" $ spawn (myEmacs ++ ("--eval '(doom/window-maximize-buffer(eww \"distro.tube\"))'"))) -- eww browser if on Doom Emacs
, ("M-e a", spawn (myEmacs ++ ("--eval '(emms)' --eval '(emms-play-directory-tree \"~/Music/\")'"))) , ("M-e a", addName "" $ spawn (myEmacs ++ ("--eval '(emms)' --eval '(emms-play-directory-tree \"~/Music/\")'")))
-- KB_GROUP Multimedia Keys -- KB_GROUP Multimedia Keys
, ("<XF86AudioPlay>", spawn "mocp --play") , ("<XF86AudioPlay>", addName "" $ spawn "mocp --play")
, ("<XF86AudioPrev>", spawn "mocp --previous") , ("<XF86AudioPrev>", addName "" $ spawn "mocp --previous")
, ("<XF86AudioNext>", spawn "mocp --next") , ("<XF86AudioNext>", addName "" $ spawn "mocp --next")
, ("<XF86AudioMute>", spawn "amixer set Master toggle") , ("<XF86AudioMute>", addName "" $ spawn "amixer set Master toggle")
, ("<XF86AudioLowerVolume>", spawn "amixer set Master 5%- unmute") , ("<XF86AudioLowerVolume>", addName "" $ spawn "amixer set Master 5%- unmute")
, ("<XF86AudioRaiseVolume>", spawn "amixer set Master 5%+ unmute") , ("<XF86AudioRaiseVolume>", addName "" $ spawn "amixer set Master 5%+ unmute")
, ("<XF86HomePage>", spawn "qutebrowser https://www.youtube.com/c/DistroTube") , ("<XF86HomePage>", addName "" $ spawn "qutebrowser https://www.youtube.com/c/DistroTube")
, ("<XF86Search>", spawn "dm-websearch") , ("<XF86Search>", addName "" $ spawn "dm-websearch")
, ("<XF86Mail>", runOrRaise "thunderbird" (resource =? "thunderbird")) , ("<XF86Mail>", addName "" $ runOrRaise "thunderbird" (resource =? "thunderbird"))
, ("<XF86Calculator>", runOrRaise "qalculate-gtk" (resource =? "qalculate-gtk")) , ("<XF86Calculator>", addName "" $ runOrRaise "qalculate-gtk" (resource =? "qalculate-gtk"))
, ("<XF86Eject>", spawn "toggleeject") , ("<XF86Eject>", addName "" $ spawn "toggleeject")
, ("<Print>", spawn "dm-maim") , ("<Print>", addName "" $ spawn "dm-maim")
] ]
-- The following lines are needed for named scratchpads. -- The following lines are needed for named scratchpads.
where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP")) where nonNSP = WSIs (return (\ws -> W.tag ws /= "NSP"))
@@ -524,7 +526,7 @@ main = do
xmproc1 <- spawnPipe ("xmobar -x 1 $HOME/.config/xmobar/" ++ colorScheme ++ "-xmobarrc") xmproc1 <- spawnPipe ("xmobar -x 1 $HOME/.config/xmobar/" ++ colorScheme ++ "-xmobarrc")
xmproc2 <- spawnPipe ("xmobar -x 2 $HOME/.config/xmobar/" ++ colorScheme ++ "-xmobarrc") xmproc2 <- spawnPipe ("xmobar -x 2 $HOME/.config/xmobar/" ++ colorScheme ++ "-xmobarrc")
-- the xmonad, ya know...what the WM is named after! -- the xmonad, ya know...what the WM is named after!
xmonad $ ewmh def xmonad $ addDescrKeys ((mod4Mask, xK_F1), showKeybindings) myKeys $ ewmh def
{ manageHook = myManageHook <+> manageDocks { manageHook = myManageHook <+> manageDocks
, handleEventHook = docksEventHook , handleEventHook = docksEventHook
-- Uncomment this line to enable fullscreen support on things like YouTube/Netflix. -- Uncomment this line to enable fullscreen support on things like YouTube/Netflix.
@@ -566,4 +568,4 @@ main = do
-- order of things in xmobar -- order of things in xmobar
, ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t] , ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t]
} }
} `additionalKeysP` myKeys } -- `additionalKeysP` myKeys