Update 'xmonad' config

master
Hektor Misplon 2022-12-01 16:21:19 +01:00
parent 01a3f64612
commit 19e9241ac8
1 changed files with 144 additions and 120 deletions

View File

@ -1,12 +1,10 @@
import XMonad import XMonad
import XMonad.Hooks.DynamicLog import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.StatusBar import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP import XMonad.Hooks.StatusBar.PP
import XMonad.Layout.Magnifier import XMonad.Layout.Magnifier
import qualified XMonad.Layout.Magnifier as Mag (MagnifyMsg (..)) import qualified XMonad.Layout.Magnifier as Mag (MagnifyMsg (..))
import XMonad.Layout.NoBorders (hasBorder, smartBorders) import XMonad.Layout.NoBorders (hasBorder, smartBorders)
@ -14,18 +12,20 @@ import XMonad.Layout.PerScreen
import XMonad.Layout.ResizableTile import XMonad.Layout.ResizableTile
import XMonad.Layout.Spacing import XMonad.Layout.Spacing
import XMonad.Layout.ThreeColumns import XMonad.Layout.ThreeColumns
import XMonad.Layout.ToggleLayouts (ToggleLayout (..), import XMonad.Layout.ToggleLayouts
toggleLayouts) ( ToggleLayout (..),
toggleLayouts,
)
import XMonad.Layout.WindowNavigation import XMonad.Layout.WindowNavigation
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig import XMonad.Util.EZConfig
import qualified XMonad.Util.Hacks as Hacks import qualified XMonad.Util.Hacks as Hacks
import XMonad.Util.Loggers import XMonad.Util.Loggers
import XMonad.Util.Paste import XMonad.Util.Paste
import XMonad.Util.Run (spawnExternalProcess, import XMonad.Util.Run
spawnPipe) ( spawnExternalProcess,
spawnPipe,
)
import XMonad.Util.Ungrab import XMonad.Util.Ungrab
-- Statusbar -- Statusbar
@ -68,31 +68,32 @@ myXmobarPP =
shiftAndView id = doF (W.view id) <> doF (W.shift id) shiftAndView id = doF (W.view id) <> doF (W.shift id)
-- manageHook -- manageHook
myManageHook = composeAll myManageHook =
[ composeAll
className =? "Zathura" --> doShift "pdf" [ className =? "Zathura" --> doShift "pdf",
, className =? "firefox" --> shiftAndView "www" className =? "firefox" --> shiftAndView "www",
, className =? "Anki" --> shiftAndView "etc" className =? "Anki" --> shiftAndView "etc",
, className =? "Obsidian" --> shiftAndView "etc" className =? "Obsidian" --> shiftAndView "etc",
, className =? "Launcher" --> doRectFloat (W.RationalRect 0.05 0.4 0.9 0.5) className =? "Launcher" --> doRectFloat (W.RationalRect 0.05 0.4 0.9 0.5),
, className =? "Calculator" --> doCenterFloat className =? "Calculator" --> doCenterFloat,
, className =? "feh" --> doCenterFloat className =? "feh" --> doCenterFloat,
, className =? "albert" --> hasBorder False className =? "albert" --> hasBorder False,
, className =? "Xournalpp" --> doRectFloat (W.RationalRect 0.5 0.5 0.5 0.5) className =? "Xournalpp" --> doRectFloat (W.RationalRect 0.5 0.5 0.5 0.5)
] ]
-- layoutHook -- layoutHook
myLayoutHook= smartBorders $ myLayoutHook =
smartBorders $
-- Column layouts -- Column layouts
threeCol ||| threeCol
threeColMid ||| ||| threeColMid
-- Tiled layouts -- Tiled layouts
-- Note: magnifier is off by default -- Note: magnifier is off by default
-- (controllable usingarrow keys) -- (controllable usingarrow keys)
magnifiercz magnificationFactorH tiled ||| ||| magnifiercz magnificationFactorH tiled
magnifiercz magnificationFactorV (Mirror tiled) ||| ||| magnifiercz magnificationFactorV (Mirror tiled)
-- Single window / monocle layout -- Single window / monocle layout
Full ||| Full
where where
magnificationFactorV = 1.384 magnificationFactorV = 1.384
magnificationFactorH = 1.621 magnificationFactorH = 1.621
@ -103,77 +104,100 @@ myLayoutHook= smartBorders $
ratio = 1 / 2 ratio = 1 / 2
delta = 4 / 100 delta = 4 / 100
myConfig = def myConfig =
{ def
terminal = "alacritty" { terminal = "alacritty",
-- Use Win key instead of Alt -- Use Win key instead of Alt
, modMask = mod4Mask modMask = mod4Mask,
, workspaces = ["α", "β", "γ", "δ", "ε", "ζ", "η"] -- , workspaces = ["α", "β", "γ", "δ", "ε", "ζ", "η"]
workspaces =
[ "sh",
"www",
"dev",
-- "nix",
"pdf",
"etc"
],
-- Styling -- Styling
, focusedBorderColor = "#888" focusedBorderColor = "#888",
, normalBorderColor = "#000" normalBorderColor = "#000",
, borderWidth = 2 borderWidth = 2,
-- Hooks -- Hooks
, manageHook = myManageHook <+> manageHook def manageHook = myManageHook <+> manageHook def,
, layoutHook = avoidStruts myLayoutHook layoutHook = avoidStruts myLayoutHook,
, handleEventHook = handleEventHook def <> Hacks.windowedFullscreenFixEventHook handleEventHook = handleEventHook def <> Hacks.windowedFullscreenFixEventHook
} `additionalKeysP` myKeysP }
`additionalKeysP` myKeysP
`removeKeysP` myRemoveKeysP `removeKeysP` myRemoveKeysP
-- Keybindings to be added/overridden -- Keybindings to be added/overridden
myKeysP = [ myKeysP =
-- Fit floating windows back to layout [ -- Fit floating windows back to layout
("M-S-<Space>", withFocused $ windows . W.sink) ("M-S-<Space>", withFocused $ windows . W.sink),
-- Launchers -- Launchers
, ("M-p", spawn "albert toggle") ("M-S-p", spawn "alacritty --class Launcher,Launcher"),
("M-p", spawn "albert toggle"),
-- Map insert key to paste from clipboard -- Map insert key to paste from clipboard
, ("<Insert>", pasteSelection) ("<Insert>", pasteSelection),
-- Map print screen to take a screenshot with flameshot -- Map print screen to take a screenshot with flameshot
, ("<Print>", spawn "flameshot gui") ("<Print>", spawn "flameshot gui"),
-- Map audio keys to control volume -- Map audio keys to control volume
, ("<XF86AudioRaiseVolume>", spawn "pactl set-sink-volume @DEFAULT_SINK@ +5%") ("<XF86AudioRaiseVolume>", spawn "pactl set-sink-volume @DEFAULT_SINK@ +5%"),
, ("<XF86AudioLowerVolume>", spawn "pactl set-sink-volume @DEFAULT_SINK@ -5%") ("<XF86AudioLowerVolume>", spawn "pactl set-sink-volume @DEFAULT_SINK@ -5%"),
, ("<XF86AudioMute>", spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle") ("<XF86AudioMute>", spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle"),
-- Map brightness keys to control brightness with brightnessctl -- Map brightness keys to control brightness with brightnessctl
, ("<XF86MonBrightnessUp>", spawn "brightnessctl set 20+") ("<XF86MonBrightnessUp>", spawn "brightnessctl set 20+"),
, ("<XF86MonBrightnessDown>", spawn "brightnessctl set 20-") ("<XF86MonBrightnessDown>", spawn "brightnessctl set 20-"),
-- Map brightness keys + shift to adjust redshift temperature -- Map brightness keys + shift to adjust redshift temperature
, ("S-<XF86MonBrightnessUp>", spawn "echo $(($(cat /tmp/temperature) + 50)) > /tmp/temperature && redshift -O $(cat /tmp/temperature) -P && notify < /tmp/temperature -h string:x-canonical-private-synchronous:anything") ("S-<XF86MonBrightnessUp>", spawn "echo $(($(cat /tmp/temperature) + 50)) > /tmp/temperature && redshift -O $(cat /tmp/temperature) -P && notify < /tmp/temperature -h string:x-canonical-private-synchronous:anything"),
, ("S-<XF86MonBrightnessDown>", spawn "echo $(($(cat /tmp/temperature) - 50)) > /tmp/temperature && redshift -O $(cat /tmp/temperature) -P && notify < /tmp/temperature -h string:x-canonical-private-synchronous:anything") ("S-<XF86MonBrightnessDown>", spawn "echo $(($(cat /tmp/temperature) - 50)) > /tmp/temperature && redshift -O $(cat /tmp/temperature) -P && notify < /tmp/temperature -h string:x-canonical-private-synchronous:anything"),
-- Reset redshift temperature -- Reset redshift temperature
, ("M-S-<XF86MonBrightnessUp>", spawn "echo 3000 > /tmp/temperature && redshift -x") ("M-S-<XF86MonBrightnessUp>", spawn "echo 3000 > /tmp/temperature && redshift -x"),
, ("M-S-<XF86MonBrightnessDown>", spawn "echo 3000 > /tmp/temperature && redshift -x") ("M-S-<XF86MonBrightnessDown>", spawn "echo 3000 > /tmp/temperature && redshift -x"),
-- Use power down key to suspend -- Use power down key to suspend
, ("<XF86PowerOff>", spawn "systemctl suspend") ("<XF86PowerOff>", spawn "systemctl suspend"),
-- FIXME: Spawn firefox in fullscreen, but not in kiosk mode -- FIXME: Spawn firefox in fullscreen, but not in kiosk mode
, ("M-S-b", spawn "firefox --fullscreen") ("M-S-b", spawn "firefox --fullscreen"),
-- Magnify window using arrow keys -- Magnify window using arrow keys
, ("M-=", sendMessage MagnifyMore >> sendMessage Mag.ToggleOn) ("M-=", sendMessage MagnifyMore >> sendMessage Mag.ToggleOn),
, ("M--", sendMessage MagnifyLess >> sendMessage Mag.ToggleOn) ("M--", sendMessage MagnifyLess >> sendMessage Mag.ToggleOn),
-- Reset magnification -- Reset magnification
, ("M-S-=", sendMessage Mag.ToggleOff) ("M-S-=", sendMessage Mag.ToggleOff),
-- Layouts ("<XF86Calculator>", spawn "alacritty --class 'Calculator' -e ipython -i /home/h/.bin/calc.py"),
, ("M-t", sendMessage $ JumpToLayout "Magnifier Tall") -- playerctl ncspot using arrow keys
, ("M-c", sendMessage $ JumpToLayout "ThreeCol") ("M-<Right>", spawn "playerctl next"),
, ("M-f", sendMessage $ JumpToLayout "Full") ("M-<Left>", spawn "playerctl previous"),
("M-<Up>", spawn "playerctl play"),
("M-<Down>", spawn "playerctl pause"),
-- Use a,s,d,f,g to switch to workspaces
("M-a", windows $ W.greedyView "sh"),
("M-s", windows $ W.greedyView "www"),
("M-d", windows $ W.greedyView "dev"),
("M-f", windows $ W.greedyView "pdf"),
("M-g", windows $ W.greedyView "etc"),
-- Use shift + a,s,d,f,g to move window to workspace
("M-S-a", windows $ W.shift "sh"),
("M-S-s", windows $ W.shift "www"),
("M-S-d", windows $ W.shift "dev"),
("M-S-f", windows $ W.shift "pdf"),
("M-S-g", windows $ W.shift "etc")
] ]
-- Keybindings to be removed -- Keybindings to be removed
myRemoveKeysP = [ ] myRemoveKeysP =
[ -- Remove 1,2,3,4,5 bindings for workspaces
"M-1",
"M-2",
"M-3",
"M-4",
"M-5",
-- Remove shift + 1,2,3,4,5 bindings for workspaces
"M-S-1",
"M-S-2",
"M-S-3",
"M-S-4",
"M-S-5"
]
main :: IO () main :: IO ()
main = do xmonad $ docks $ ewmh $ withEasySB (statusBarProp "xmobar" (pure myXmobarPP)) defToggleStrutsKey myConfig main = do xmonad $ docks $ ewmh $ withEasySB (statusBarProp "xmobar" (pure myXmobarPP)) defToggleStrutsKey myConfig