1
0
Fork 0
mirror of https://gitlab.com/dwt1/dotfiles.git synced 2023-02-13 20:55:19 -05:00
dwt1--dotfiles/.xmonad/xmonad.hs

612 lines
28 KiB
Haskell
Raw Normal View History

2021-04-21 15:32:19 -04:00
-- Base
2019-01-15 16:27:01 -05:00
import XMonad
2020-12-17 02:05:21 -05:00
import System.Directory
import System.IO (hClose, hPutStr, hPutStrLn)
import System.Exit (exitSuccess)
import qualified XMonad.StackSet as W
-- Actions
2021-04-29 20:21:23 -04:00
import XMonad.Actions.CopyWindow (kill1)
2021-04-14 00:56:09 -04:00
import XMonad.Actions.CycleWS (Direction1D(..), moveTo, shiftTo, WSType(..), nextScreen, prevScreen)
import XMonad.Actions.GridSelect
import XMonad.Actions.MouseResize
import XMonad.Actions.Promote
import XMonad.Actions.RotSlaves (rotSlavesDown, rotAllDown)
import XMonad.Actions.WindowGo (runOrRaise)
import XMonad.Actions.WithAll (sinkAll, killAll)
import qualified XMonad.Actions.Search as S
-- Data
2020-11-12 17:57:50 -05:00
import Data.Char (isSpace, toUpper)
2021-02-26 01:10:02 -05:00
import Data.Maybe (fromJust)
import Data.Monoid
import Data.Maybe (isJust)
import Data.Tree
import qualified Data.Map as M
2019-01-15 16:27:01 -05:00
-- Hooks
2020-05-24 22:27:19 -04:00
import XMonad.Hooks.DynamicLog (dynamicLogWithPP, wrap, xmobarPP, xmobarColor, shorten, PP(..))
import XMonad.Hooks.EwmhDesktops -- for some fullscreen events, also for xcomposite in obs.
2020-06-06 19:40:47 -04:00
import XMonad.Hooks.ManageDocks (avoidStruts, docksEventHook, manageDocks, ToggleStruts(..))
import XMonad.Hooks.ManageHelpers (isFullscreen, doFullFloat, doCenterFloat)
2020-06-06 19:40:47 -04:00
import XMonad.Hooks.ServerMode
2019-01-15 16:27:01 -05:00
import XMonad.Hooks.SetWMName
import XMonad.Hooks.WorkspaceHistory
2019-01-15 16:27:01 -05:00
-- Layouts
2021-04-20 18:54:29 -04:00
import XMonad.Layout.Accordion
import XMonad.Layout.GridVariants (Grid(Grid))
import XMonad.Layout.SimplestFloat
import XMonad.Layout.Spiral
import XMonad.Layout.ResizableTile
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
-- Layouts modifiers
import XMonad.Layout.LayoutModifier
import XMonad.Layout.LimitWindows (limitWindows, increaseLimit, decreaseLimit)
import XMonad.Layout.Magnifier
import XMonad.Layout.MultiToggle (mkToggle, single, EOT(EOT), (??))
import XMonad.Layout.MultiToggle.Instances (StdTransformers(NBFULL, MIRROR, NOBORDERS))
import XMonad.Layout.NoBorders
2020-11-12 17:57:50 -05:00
import XMonad.Layout.Renamed
import XMonad.Layout.ShowWName
2020-11-12 17:57:50 -05:00
import XMonad.Layout.Simplest
import XMonad.Layout.Spacing
2020-11-12 17:57:50 -05:00
import XMonad.Layout.SubLayouts
import XMonad.Layout.WindowArranger (windowArrange, WindowArrangerMsg(..))
import XMonad.Layout.WindowNavigation
import qualified XMonad.Layout.ToggleLayouts as T (toggleLayouts, ToggleLayout(Toggle))
import qualified XMonad.Layout.MultiToggle as MT (Toggle(..))
2020-10-23 21:39:58 -04:00
-- Utilities
2021-04-12 19:56:03 -04:00
import XMonad.Util.Dmenu
import XMonad.Util.EZConfig (additionalKeysP, mkNamedKeymap)
import XMonad.Util.NamedActions
import XMonad.Util.NamedScratchpad
import XMonad.Util.Run (runProcessWithInput, safeSpawn, spawnPipe)
import XMonad.Util.SpawnOnce
2019-01-15 16:27:01 -05:00
-- ColorScheme module (SET ONLY ONE!)
-- Possible choice are:
2021-12-03 14:39:39 -05:00
-- DoomOne
-- Dracula
-- GruvboxDark
-- MonokaiPro
-- Nord
-- OceanicNext
-- Palenight
-- SolarizedDark
-- SolarizedLight
-- TomorrowNight
2021-12-05 16:09:00 -05:00
import Colors.DoomOne
myFont :: String
2020-12-15 18:16:29 -05:00
myFont = "xft:SauceCodePro Nerd Font Mono:regular:size=9:antialias=true:hinting=true"
myModMask :: KeyMask
2021-04-14 00:56:09 -04:00
myModMask = mod4Mask -- Sets modkey to super/windows key
myTerminal :: String
2021-04-14 00:56:09 -04:00
myTerminal = "alacritty" -- Sets default terminal
myBrowser :: String
2021-04-14 00:56:09 -04:00
myBrowser = "qutebrowser " -- Sets qutebrowser as browser
myEmacs :: String
myEmacs = "emacsclient -c -a 'emacs' " -- Makes emacs keybindings easier to type
myEditor :: String
myEditor = "emacsclient -c -a 'emacs' " -- Sets emacs as editor
2021-04-14 00:56:09 -04:00
-- myEditor = myTerminal ++ " -e vim " -- Sets vim as editor
myBorderWidth :: Dimension
2021-04-14 00:56:09 -04:00
myBorderWidth = 2 -- Sets border width for windows
2021-12-03 14:39:39 -05:00
myNormColor :: String -- Border color of normal windows
myNormColor = colorBack -- This variable is imported from Colors.THEME
2021-12-03 14:39:39 -05:00
myFocusColor :: String -- Border color of focused windows
myFocusColor = color15 -- This variable is imported from Colors.THEME
2022-05-20 13:50:08 -04:00
mySoundPlayer :: String
mySoundPlayer = "ffplay -nodisp -autoexit " -- The program that will play system sounds
windowCount :: X (Maybe String)
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
2020-05-30 12:49:58 -04:00
myStartupHook :: X ()
2019-01-15 16:27:01 -05:00
myStartupHook = do
spawnOnce (mySoundPlayer ++ startupSound)
spawn "killall conky" -- kill current conky on each restart
spawn "killall trayer" -- kill current trayer on each restart
2021-12-05 16:09:00 -05:00
spawnOnce "lxsession"
spawnOnce "picom"
spawnOnce "nm-applet"
spawnOnce "volumeicon"
spawn "/usr/bin/emacs --daemon" -- emacs daemon for the emacsclient
2021-04-21 17:38:06 -04:00
spawn ("sleep 2 && conky -c $HOME/.config/conky/xmonad/" ++ colorScheme ++ "-01.conkyrc")
spawn ("sleep 2 && trayer --edge top --align right --widthtype request --padding 6 --SetDockType true --SetPartialStrut true --expand true --monitor 1 --transparent true --alpha 0 " ++ colorTrayer ++ " --height 22")
2021-12-05 16:09:00 -05:00
spawnOnce "xargs xwallpaper --stretch < ~/.cache/wall"
-- spawnOnce "~/.fehbg &" -- set last saved feh wallpaper
-- spawnOnce "feh --randomize --bg-fill ~/wallpapers/*" -- feh set random wallpaper
-- spawnOnce "nitrogen --restore &" -- if you prefer nitrogen to feh
setWMName "LG3D"
2019-01-15 16:27:01 -05:00
myColorizer :: Window -> Bool -> X (String, String)
myColorizer = colorRangeFromClassName
(0x28,0x2c,0x34) -- lowest inactive bg
(0x28,0x2c,0x34) -- highest inactive bg
(0xc7,0x92,0xea) -- active bg
(0xc0,0xa7,0x9a) -- inactive fg
(0x28,0x2c,0x34) -- active fg
-- gridSelect menu layout
mygridConfig :: p -> GSConfig Window
mygridConfig colorizer = (buildDefaultGSConfig myColorizer)
{ gs_cellheight = 40
, gs_cellwidth = 200
, gs_cellpadding = 6
, gs_originFractX = 0.5
, gs_originFractY = 0.5
, gs_font = myFont
}
spawnSelected' :: [(String, String)] -> X ()
spawnSelected' lst = gridselect conf lst >>= flip whenJust spawn
where conf = def
{ gs_cellheight = 40
, gs_cellwidth = 200
, gs_cellpadding = 6
, gs_originFractX = 0.5
, gs_originFractY = 0.5
, gs_font = myFont
}
2022-06-20 18:37:12 -04:00
myTestGrid = [ ("MyAppGrid", spawnSelected' myAppGrid)
, ("Accessories", spawnSelected' myAccessories)
, ("Education", spawnSelected' myOffice)
, ("Games", spawnSelected' myOffice)
, ("Internet", spawnSelected' myOffice)
, ("Multimedia", spawnSelected' myOffice)
, ("Office", spawnSelected' myOffice)
, ("System", spawnSelected' myOffice)
, ("Utilities", spawnSelected' myOffice)
]
myAppGrid = [ ("Audacity", "audacity")
, ("Deadbeef", "deadbeef")
, ("Emacs", "emacsclient -c -a emacs")
, ("Firefox", "firefox")
, ("Geany", "geany")
, ("Geary", "geary")
, ("Gimp", "gimp")
, ("Kdenlive", "kdenlive")
, ("LibreOffice Impress", "loimpress")
, ("LibreOffice Writer", "lowriter")
, ("OBS", "obs")
, ("PCManFM", "pcmanfm")
]
2022-06-20 18:37:12 -04:00
myAccessories = [ ("Audacity", "audacity")
, ("Deadbeef", "deadbeef")
, ("Emacs", "emacsclient -c -a emacs")
, ("Firefox", "firefox")
, ("Geany", "geany")
, ("Geary", "geary")
, ("Gimp", "gimp")
, ("Kdenlive", "kdenlive")
, ("LibreOffice Impress", "loimpress")
, ("LibreOffice Writer", "lowriter")
, ("OBS", "obs")
, ("PCManFM", "pcmanfm")
]
myOffice = [ ("Audacity", "audacity")
, ("Deadbeef", "deadbeef")
, ("Emacs", "emacsclient -c -a emacs")
, ("Firefox", "firefox")
, ("Geany", "geany")
, ("Geary", "geary")
, ("Gimp", "gimp")
, ("Kdenlive", "kdenlive")
, ("LibreOffice Impress", "loimpress")
, ("LibreOffice Writer", "lowriter")
, ("OBS", "obs")
, ("PCManFM", "pcmanfm")
]
myScratchPads :: [NamedScratchpad]
myScratchPads = [ NS "terminal" spawnTerm findTerm manageTerm
, NS "mocp" spawnMocp findMocp manageMocp
, NS "calculator" spawnCalc findCalc manageCalc
]
where
2021-04-14 00:56:09 -04:00
spawnTerm = myTerminal ++ " -t scratchpad"
findTerm = title =? "scratchpad"
manageTerm = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
l = 0.95 -w
2021-04-14 00:56:09 -04:00
spawnMocp = myTerminal ++ " -t mocp -e mocp"
findMocp = title =? "mocp"
manageMocp = customFloating $ W.RationalRect l t w h
where
h = 0.9
w = 0.9
t = 0.95 -h
2021-12-06 17:56:45 -05:00
l = 0.95 -w
spawnCalc = "qalculate-gtk"
findCalc = className =? "Qalculate-gtk"
manageCalc = customFloating $ W.RationalRect l t w h
where
h = 0.5
w = 0.4
t = 0.75 -h
l = 0.70 -w
2020-12-18 11:24:49 -05:00
--Makes setting the spacingRaw simpler to write. The spacingRaw module adds a configurable amount of space around windows.
mySpacing :: Integer -> l a -> XMonad.Layout.LayoutModifier.ModifiedLayout Spacing l a
mySpacing i = spacingRaw False (Border i i i i) True (Border i i i i) True
-- Below is a variation of the above except no borders are applied
-- if fewer than two windows. So a single window has no gaps.
mySpacing' :: Integer -> l a -> XMonad.Layout.LayoutModifier.ModifiedLayout Spacing l a
mySpacing' i = spacingRaw True (Border i i i i) True (Border i i i i) True
-- Defining a bunch of layouts, many that I don't use.
2020-12-18 11:24:49 -05:00
-- limitWindows n sets maximum number of windows displayed for layout.
-- mySpacing n sets the gap size around the windows.
tall = renamed [Replace "tall"]
$ smartBorders
$ windowNavigation
2020-11-12 17:57:50 -05:00
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 12
$ mySpacing 8
$ ResizableTall 1 (3/100) (1/2) []
magnify = renamed [Replace "magnify"]
$ smartBorders
$ windowNavigation
2020-11-12 17:57:50 -05:00
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ magnifier
$ limitWindows 12
$ mySpacing 8
$ ResizableTall 1 (3/100) (1/2) []
monocle = renamed [Replace "monocle"]
$ smartBorders
$ windowNavigation
2020-11-12 17:57:50 -05:00
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 20 Full
floats = renamed [Replace "floats"]
$ smartBorders
$ limitWindows 20 simplestFloat
grid = renamed [Replace "grid"]
$ smartBorders
$ windowNavigation
2020-11-12 17:57:50 -05:00
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 12
2021-04-20 18:54:29 -04:00
$ mySpacing 8
$ mkToggle (single MIRROR)
$ Grid (16/10)
spirals = renamed [Replace "spirals"]
$ smartBorders
$ windowNavigation
2020-11-12 17:57:50 -05:00
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ mySpacing' 8
$ spiral (6/7)
threeCol = renamed [Replace "threeCol"]
$ smartBorders
$ windowNavigation
2020-11-12 17:57:50 -05:00
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 7
$ ThreeCol 1 (3/100) (1/2)
threeRow = renamed [Replace "threeRow"]
$ smartBorders
$ windowNavigation
2020-11-12 17:57:50 -05:00
$ addTabs shrinkText myTabTheme
$ subLayout [] (smartBorders Simplest)
$ limitWindows 7
-- Mirror takes a layout and rotates it by 90 degrees.
-- So we are applying Mirror to the ThreeCol layout.
$ Mirror
$ ThreeCol 1 (3/100) (1/2)
tabs = renamed [Replace "tabs"]
-- I cannot add spacing to this layout because it will
-- add spacing between window and tabs which looks bad.
2020-11-12 17:57:50 -05:00
$ tabbed shrinkText myTabTheme
2021-04-20 18:54:29 -04:00
tallAccordion = renamed [Replace "tallAccordion"]
$ Accordion
wideAccordion = renamed [Replace "wideAccordion"]
$ Mirror Accordion
2020-11-12 17:57:50 -05:00
2020-12-18 11:24:49 -05:00
-- setting colors for tabs layout and tabs sublayout.
2020-11-12 17:57:50 -05:00
myTabTheme = def { fontName = myFont
2021-12-03 14:39:39 -05:00
, activeColor = color15
, inactiveColor = color08
, activeBorderColor = color15
, inactiveBorderColor = colorBack
, activeTextColor = colorBack
, inactiveTextColor = color16
2020-11-12 17:57:50 -05:00
}
-- Theme for showWName which prints current workspace when you change workspaces.
myShowWNameTheme :: SWNConfig
myShowWNameTheme = def
{ swn_font = "xft:Ubuntu:bold:size=60"
, swn_fade = 1.0
, swn_bgcolor = "#1c1f24"
, swn_color = "#ffffff"
}
-- The layout hook
myLayoutHook = avoidStruts
$ mouseResize
$ windowArrange
$ T.toggleLayouts floats
2020-11-12 17:57:50 -05:00
$ mkToggle (NBFULL ?? NOBORDERS ?? EOT) myDefaultLayout
where
myDefaultLayout = withBorder myBorderWidth tall
||| magnify
||| noBorders monocle
||| floats
||| noBorders tabs
||| grid
||| spirals
||| threeCol
||| threeRow
||| tallAccordion
||| wideAccordion
2020-11-12 17:57:50 -05:00
-- myWorkspaces = [" 1 ", " 2 ", " 3 ", " 4 ", " 5 ", " 6 ", " 7 ", " 8 ", " 9 "]
myWorkspaces = [" dev ", " www ", " sys ", " doc ", " vbox ", " chat ", " mus ", " vid ", " gfx "]
2021-02-26 01:10:02 -05:00
myWorkspaceIndices = M.fromList $ zipWith (,) myWorkspaces [1..] -- (,) == \x y -> (x,y)
2021-02-26 01:10:02 -05:00
clickable ws = "<action=xdotool key super+"++show i++">"++ws++"</action>"
where i = fromJust $ M.lookup ws myWorkspaceIndices
myManageHook :: XMonad.Query (Data.Monoid.Endo WindowSet)
myManageHook = composeAll
-- 'doFloat' forces a window to float. Useful for dialog boxes and such.
-- using 'doShift ( myWorkspaces !! 7)' sends program to workspace 8!
-- I'm doing it this way because otherwise I would have to write out the full
-- name of my workspaces and the names would be very long if using clickable workspaces.
[ className =? "confirm" --> doFloat
, className =? "file_progress" --> doFloat
, className =? "dialog" --> doFloat
, className =? "download" --> doFloat
, className =? "error" --> doFloat
, className =? "Gimp" --> doFloat
, className =? "notification" --> doFloat
, 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 )
, className =? "mpv" --> doShift ( myWorkspaces !! 7 )
, className =? "Gimp" --> doShift ( myWorkspaces !! 8 )
, className =? "VirtualBox Manager" --> doShift ( myWorkspaces !! 4 )
, (className =? "firefox" <&&> resource =? "Dialog") --> doFloat -- Float Firefox Dialog
, isFullscreen --> doFullFloat
] <+> namedScratchpadManageHook myScratchPads
2019-01-15 16:27:01 -05:00
2022-05-20 13:50:08 -04:00
soundDir = "/opt/dtos-sounds/" -- The directory that has the sound files
startupSound = soundDir ++ "startup-01.mp3"
shutdownSound = soundDir ++ "shutdown-01.mp3"
dmenuSound = soundDir ++ "menu-01.mp3"
2022-05-20 13:50:08 -04:00
showKeybindings :: [((KeyMask, KeySym), NamedAction)] -> NamedAction
showKeybindings x = addName "Show Keybindings" $ io $ do
2022-06-20 18:37:12 -04:00
h <- spawnPipe $ "yad --text-info --fontname=\"SauceCodePro Nerd Font Mono 12\" --fore=#46d9ff back=#282c36 --center --geometry=1200x800 --title \"XMonad keybindings\""
hPutStr h (unlines $ showKm x)
hClose h
return ()
myKeys :: XConfig l0 -> [((KeyMask, KeySym), NamedAction)]
myKeys c = (subtitle "Custom Keys":) $ mkNamedKeymap c $
2022-06-20 18:37:12 -04:00
-- Xmonad
[ ("M-C-r", addName "Recompile XMonad" $ spawn "xmonad --recompile")
, ("M-S-r", addName "Restart XMonad" $ spawn "xmonad --restart")
, ("M-S-q", addName "Quit XMonad" $ sequence_ [spawn (mySoundPlayer ++ shutdownSound), io exitSuccess])
, ("M-S-/", addName "List all keybindings" $ spawn "~/.xmonad/xmonad_keys.sh")
, ("M-/", addName "DTOS Help" $ spawn "dtos-help")
2022-06-20 18:37:12 -04:00
-- Run prompt (dmenu)
, ("M-S-<Return>", addName "Run prompt" $ sequence_ [spawn (mySoundPlayer ++ dmenuSound), spawn "dm-run"])
2022-06-20 18:37:12 -04:00
-- Dmenu scripts (dmscripts)
-- 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 h", addName "List all dmscripts" $ spawn "dm-hub")
, ("M-p a", addName "Choose ambient sound" $ spawn "dm-sounds")
, ("M-p b", addName "Set background" $ spawn "dm-setbg")
, ("M-p c", addName "Choose color scheme" $ spawn "dtos-colorscheme")
, ("M-p C", addName "Pick color from scheme" $ spawn "dm-colpick")
, ("M-p e", addName "Edit config files" $ spawn "dm-confedit")
, ("M-p i", addName "Take a screenshot" $ spawn "dm-maim")
, ("M-p k", addName "Kill processes" $ spawn "dm-kill")
, ("M-p m", addName "View manpages" $ spawn "dm-man")
, ("M-p n", addName "Store and copy notes" $ spawn "dm-note")
, ("M-p o", addName "Browser bookmarks" $ spawn "dm-bookman")
, ("M-p p", addName "Passmenu" $ spawn "passmenu -p \"Pass: \"")
, ("M-p q", addName "Logout Menu" $ spawn "dm-logout")
, ("M-p r", addName "Listen to online radio" $ spawn "dm-radio")
, ("M-p s", addName "Search various engines" $ spawn "dm-websearch")
, ("M-p t", addName "Translate text" $ spawn "dm-translate")
2022-06-20 18:37:12 -04:00
-- Useful programs to have a keybinding for launch
, ("M-<Return>", addName "Launch terminal" $ spawn (myTerminal))
, ("M-b", addName "Launch web browser" $ spawn (myBrowser))
, ("M-M1-h", addName "Launch htop" $ spawn (myTerminal ++ " -e htop"))
2022-06-20 18:37:12 -04:00
-- Kill windows
, ("M-S-c", addName "Kill focused window" $ kill1)
, ("M-S-a", addName "Kill all windows on WS" $ killAll)
2022-06-20 18:37:12 -04:00
-- Workspaces
, ("M-.", addName "Switch focus to next mon" $ nextScreen)
, ("M-,", addName "Switch focus to prev mon" $ prevScreen)
2022-06-20 18:37:12 -04:00
, ("M-S-<KP_Add>", 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)
-- Floating windows
, ("M-f", addName "Toggle float layout" $ sendMessage (T.Toggle "floats"))
, ("M-t", addName "Sink a floating window" $ withFocused $ windows . W.sink)
, ("M-S-t", addName "Sink all floated windows" $ sinkAll)
-- Increase/decrease spacing (gaps)
, ("C-M1-j", addName "Decrease window spacing" $ decWindowSpacing 4)
, ("C-M1-k", addName "Increase window spacing" $ incWindowSpacing 4)
, ("C-M1-h", addName "Decrease screen spacing" $ decScreenSpacing 4)
, ("C-M1-l", addName "Increase screen spacing" $ incScreenSpacing 4)
-- Grid Select (CTR-g followed by a key)
, ("C-g g", addName "Select favorite apps" $ runSelectedAction def myTestGrid)
, ("C-g t", addName "Goto selected window" $ goToSelected $ mygridConfig myColorizer)
, ("C-g b", addName "Bring selected window" $ bringSelected $ mygridConfig myColorizer)
2022-06-20 18:37:12 -04:00
-- Windows navigation
, ("M-m", addName "Move focus to master window" $ windows W.focusMaster)
, ("M-j", addName "Move focus to next window" $ windows W.focusDown)
, ("M-k", addName "Move focus to prev window" $ windows W.focusUp)
, ("M-S-m", addName "Swap focused window with master window" $ windows W.swapMaster)
, ("M-S-j", addName "Swap focused window with next window" $ windows W.swapDown)
, ("M-S-k", addName "Swap focused window with prev window" $ windows W.swapUp)
, ("M-<Backspace>", addName "Move focused window to master" $ promote)
, ("M-S-<Tab>", addName "Rotate all windows except master" $ rotSlavesDown)
, ("M-C-<Tab>", addName "Rotate all windows current stack" $ rotAllDown)
-- Layouts
, ("M-<Tab>", addName "Switch to next layout" $ sendMessage NextLayout)
, ("M-<Space>", addName "Toggle noborders/full" $ sendMessage (MT.Toggle NBFULL) >> sendMessage ToggleStruts)
-- Increase/decrease windows in the master pane or the stack
, ("M-S-<Up>", addName "Increase clients in master pane" $ sendMessage (IncMasterN 1))
, ("M-S-<Down>", addName "Decrease clients in master pane" $ sendMessage (IncMasterN (-1)))
, ("M-C-<Up>", addName "Increase # of windows" $ increaseLimit)
, ("M-C-<Down>", addName "Decrease # of windows" $ decreaseLimit)
-- Window resizing
, ("M-h", addName "Shrink window" $ sendMessage Shrink)
, ("M-l", addName "Expand window" $ sendMessage Expand)
, ("M-M1-j", addName "Shrink window vertically" $ sendMessage MirrorShrink)
, ("M-M1-k", addName "Expand window vertically" $ sendMessage MirrorExpand)
2022-06-20 18:37:12 -04:00
-- Sublayouts
-- This is used to push windows to tabbed sublayouts, or pull them out of it.
2022-06-20 18:37:12 -04:00
, ("M-C-h", addName "pullGroup L" $ sendMessage $ pullGroup L)
, ("M-C-l", addName "pullGroup R" $ sendMessage $ pullGroup R)
, ("M-C-k", addName "pullGroup U" $ sendMessage $ pullGroup U)
, ("M-C-j", addName "pullGroup D" $ sendMessage $ pullGroup D)
, ("M-C-m", addName "MergeAll" $ withFocused (sendMessage . MergeAll))
-- , ("M-C-u", addName "UnMerge" $ withFocused (sendMessage . UnMerge))
, ("M-C-/", addName "UnMergeAll" $ withFocused (sendMessage . UnMergeAll))
, ("M-C-.", addName "Switch focus next tab" $ onGroup W.focusUp') -- Switch focus to next tab
, ("M-C-,", addName "Switch focus prev tab" $ onGroup W.focusDown') -- Switch focus to prev tab
-- Scratchpads
-- Toggle show/hide these programs. They run on a hidden workspace.
-- When you toggle them to show, it brings them to current workspace.
-- Toggle them to hide and it sends them back to hidden workspace (NSP).
2022-06-20 18:37:12 -04:00
, ("M-s t", addName "Toggle scratchpad terminal" $ namedScratchpadAction myScratchPads "terminal")
, ("M-s m", addName "Toggle scratchpad mocp" $ namedScratchpadAction myScratchPads "mocp")
, ("M-s c", addName "Toggle scratchpad calculator" $ namedScratchpadAction myScratchPads "calculator")
-- Controls for mocp music player (SUPER-u followed by a key)
, ("M-u p", addName "mocp play" $ spawn "mocp --play")
, ("M-u l", addName "mocp next" $ spawn "mocp --next")
, ("M-u h", addName "mocp prev" $ spawn "mocp --previous")
, ("M-u <Space>", addName "mocp toggle pause" $ spawn "mocp --toggle-pause")
-- Emacs (SUPER-e followed by a key)
, ("M-e e", addName "Emacsclient Dashboard" $ spawn (myEmacs ++ ("--eval '(dashboard-refresh-buffer)'")))
, ("M-e b", addName "Emacsclient Ibuffer" $ spawn (myEmacs ++ ("--eval '(ibuffer)'")))
, ("M-e d", addName "Emacsclient Dired" $ spawn (myEmacs ++ ("--eval '(dired nil)'")))
, ("M-e i", addName "Emacsclient ERC (IRC)" $ spawn (myEmacs ++ ("--eval '(erc)'")))
, ("M-e n", addName "Emacsclient Elfeed (RSS)" $ spawn (myEmacs ++ ("--eval '(elfeed)'")))
, ("M-e s", addName "Emacsclient Eshell" $ spawn (myEmacs ++ ("--eval '(eshell)'")))
, ("M-e t", addName "Emacsclient Mastodon" $ spawn (myEmacs ++ ("--eval '(mastodon)'")))
, ("M-e v", addName "Emacsclient Vterm" $ spawn (myEmacs ++ ("--eval '(+vterm/here nil)'")))
, ("M-e w", addName "Emacsclient EWW browser" $ spawn (myEmacs ++ ("--eval '(doom/window-maximize-buffer(eww \"distro.tube\"))'")))
, ("M-e a", addName "Emacsclient EMMS (music)" $ spawn (myEmacs ++ ("--eval '(emms)' --eval '(emms-play-directory-tree \"~/Music/\")'")))
2022-06-20 18:37:12 -04:00
-- Multimedia Keys
, ("<XF86AudioPlay>", addName "mocp play" $ spawn "mocp --play")
, ("<XF86AudioPrev>", addName "mocp next" $ spawn "mocp --previous")
, ("<XF86AudioNext>", addName "mocp prev" $ spawn "mocp --next")
, ("<XF86AudioMute>", addName "Toggle audio mute" $ spawn "amixer set Master toggle")
, ("<XF86AudioLowerVolume>", addName "Lower vol" $ spawn "amixer set Master 5%- unmute")
, ("<XF86AudioRaiseVolume>", addName "Raise vol" $ spawn "amixer set Master 5%+ unmute")
, ("<XF86HomePage>", addName "Open home page" $ spawn (myBrowser ++ " https://www.youtube.com/c/DistroTube"))
, ("<XF86Search>", addName "Web search (dmscripts)" $ spawn "dm-websearch")
, ("<XF86Mail>", addName "Email client" $ runOrRaise "thunderbird" (resource =? "thunderbird"))
, ("<XF86Calculator>", addName "Calculator" $ runOrRaise "qalculate-gtk" (resource =? "qalculate-gtk"))
, ("<XF86Eject>", addName "Eject /dev/cdrom" $ spawn "eject /dev/cdrom")
, ("<Print>", addName "Take screenshot (dmscripts)" $ spawn "dm-maim")
]
-- 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"))
2020-05-24 22:27:19 -04:00
main :: IO ()
main = do
-- Launching three instances of xmobar on their monitors.
xmproc0 <- spawnPipe ("xmobar -x 0 $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")
-- the xmonad, ya know...what the WM is named after!
xmonad $ addDescrKeys ((mod4Mask, xK_F1), showKeybindings) myKeys $ ewmh def
{ manageHook = myManageHook <+> manageDocks
, handleEventHook = docksEventHook
-- Uncomment this line to enable fullscreen support on things like YouTube/Netflix.
-- This works perfect on SINGLE monitor systems. On multi-monitor systems,
-- it adds a border around the window if screen does not have focus. So, my solution
-- is to use a keybinding to toggle fullscreen noborders instead. (M-<Space>)
-- <+> fullscreenEventHook
, modMask = myModMask
, terminal = myTerminal
, startupHook = myStartupHook
, layoutHook = showWName' myShowWNameTheme $ myLayoutHook
, workspaces = myWorkspaces
, borderWidth = myBorderWidth
, normalBorderColor = myNormColor
, focusedBorderColor = myFocusColor
, logHook = dynamicLogWithPP $ namedScratchpadFilterOutWorkspacePP $ xmobarPP
{ ppOutput = \x -> hPutStrLn xmproc0 x -- xmobar on monitor 1
>> hPutStrLn xmproc1 x -- xmobar on monitor 2
>> hPutStrLn xmproc2 x -- xmobar on monitor 3
, ppCurrent = xmobarColor color06 "" . wrap
("<box type=Bottom width=2 mb=2 color=" ++ color06 ++ ">") "</box>"
-- Visible but not current workspace
, ppVisible = xmobarColor color06 "" . clickable
-- Hidden workspace
, ppHidden = xmobarColor color05 "" . wrap
("<box type=Top width=2 mt=2 color=" ++ color05 ++ ">") "</box>" . clickable
-- Hidden workspaces (no windows)
, ppHiddenNoWindows = xmobarColor color05 "" . clickable
-- Title of active window
, ppTitle = xmobarColor color16 "" . shorten 60
-- Separator character
, ppSep = "<fc=" ++ color09 ++ "> <fn=1>|</fn> </fc>"
-- Urgent workspace
, ppUrgent = xmobarColor color02 "" . wrap "!" "!"
-- Adding # of windows on current workspace to the bar
, ppExtras = [windowCount]
-- order of things in xmobar
, ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t]
}
}