xmonad: formatting

This commit is contained in:
Primrose 2025-08-10 23:55:19 +02:00
parent 29110fffba
commit 8080d204ca
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -31,196 +31,197 @@ import Leanamonad.GreekChar
-- Note: `xmonad --restart` will make Firefox's fullscreen work duck the xmobar stop working -- Note: `xmonad --restart` will make Firefox's fullscreen work duck the xmobar stop working
-- You need restart Firefox -- You need restart Firefox
main :: IO () main :: IO ()
main = xmonad main =
-- Fix all java things that don't scale with XMonad xmonad
-- https://wiki.archlinux.org/title/java#Gray_window,_applications_not_resizing_with_WM,_menus_immediately_closing -- Fix all java things that don't scale with XMonad
. javaHack -- https://wiki.archlinux.org/title/java#Gray_window,_applications_not_resizing_with_WM,_menus_immediately_closing
. dynamicEasySBs xmonadOn . javaHack
. ewmhFullscreen . ewmh . dynamicEasySBs xmonadOn
$ def . ewmhFullscreen . ewmh
{ modMask = superMask $ def
, borderWidth = 5 { modMask = superMask
, normalBorderColor = "#18005f" , borderWidth = 5
, focusedBorderColor = "#875fff" , normalBorderColor = "#18005f"
, focusFollowsMouse = True , focusedBorderColor = "#875fff"
, terminal = myTerm , focusFollowsMouse = True
, workspaces = myWorkspaces , terminal = myTerm
, workspaces = myWorkspaces
, logHook = , logHook =
let let
fadeHook = fadeHook =
composeAll composeAll
[ opaque [ opaque
, className ~? "steam" --> opaque , className ~? "steam" --> opaque
-- Based on state -- Based on state
, isUnfocused --> transparency 0.08 , isUnfocused --> transparency 0.08
, isFloating --> transparency 0.08 , isFloating --> transparency 0.08
, isFirefoxFullscreen --> opaque , isFirefoxFullscreen --> opaque
, isFirefoxPIP --> opaque , isFirefoxPIP --> opaque
, isFirefoxVideo --> opaque , isFirefoxVideo --> opaque
]
in
fadeWindowsLogHook fadeHook
<+> refocusLastLogHook
, startupHook = do
spawnOnce "fcitx5 &" -- Input method
spawn "feh --no-fehbg --bg-fill ~/.wallpaper &" -- wallpaper
-- Needed to make gnome keyring work
-- https://wiki.archlinux.org/title/GNOME/Keyring#Using_gnome-keyring-daemon_outside_desktop_environments_(KDE,_GNOME,_XFCE,_...)
spawn "dbus-update-activation-environment DISPLAY XAUTHORITY WAYLAND_DISPLAY"
, layoutHook =
let tallr = reflectMsg . reflectHoriz
$ ResizableTall 1 (1/10) (3/7) []
in smartBorders
( named "Normal"
(smartSpacingWithEdge 5 tallr)
||| Full
)
, manageHook =
let
hasEvenWindows :: X Bool
hasEvenWindows = g <$> get
where g =
even . length . W.integrate'
. W.stack . W.workspace . W.current . windowset
in
composeAll
[ className ~? "NautilusPreviewer" --> customFloating centeredFloat
, className =? "feh" --> doFloat
, isFirefoxPIP --> doFloat
, namedScratchpadManageHook myScratchpads
]
<+>
composeOne
[ className =? "firefox" -?> insertPosition Above Newer
, className =? "sioyek" -?> insertPosition Below Older
, className =? "kitty" -?> insertPosition Below Newer
, className ~? "Nautilus" -?> insertPosition Below Older -- For some reason Older doesn't work
, ifM
(liftX hasEvenWindows)
(Just <$> insertPosition Below Newer) -- New window is odd
(Just <$> insertPosition Above Newer) -- New window is even
]
}
-- Only remove mappings that needs pass through (it's a map).
`removeKeys`
[ (superMask, xK_h)
, (superMask, xK_l)
, (superMask, xK_p)
-- It has been more than once that I actidently killed xmonad >:(
, (superMask .|. shiftMask, xK_q)
]
++ [ (superMask , n) | n <- [xK_1 .. xK_9] ]
++ [ (superMask .|. shiftMask, n) | n <- [xK_1 .. xK_9] ]
`additionalKeys`
[
-- Display
((0, xF86XK_MonBrightnessDown), spawn "light -U 5")
, ((0, xF86XK_MonBrightnessUp ), spawn "light -A 5")
, ((shiftMask, xF86XK_MonBrightnessDown), spawn "light -U 1")
, ((shiftMask, xF86XK_MonBrightnessUp ), spawn "light -A 1")
-- Volume adjustments
-- Don't overload the mute button
-- In case of doubt, smashing the button becomes deterministic
, ((0, xF86XK_AudioMute), spawn "pactl -- set-sink-mute 0 1" ) -- mute
, ((controlMask, xF86XK_AudioMute), spawn "pactl -- set-sink-mute 0 0" ) -- unmute
, ((0, xF86XK_AudioLowerVolume), spawn "pactl -- set-sink-volume 0 -5%")
, ((0, xF86XK_AudioRaiseVolume), spawn "pactl -- set-sink-volume 0 +5%")
, ((shiftMask, xF86XK_AudioLowerVolume), spawn "pactl -- set-sink-volume 0 -1%")
, ((shiftMask, xF86XK_AudioRaiseVolume), spawn "pactl -- set-sink-volume 0 +1%")
-- Playback control
, ((0, xF86XK_AudioPrev), spawn "playerctl previous" )
, ((0, xF86XK_AudioPlay), spawn "playerctl play-pause")
, ((0, xF86XK_AudioNext), spawn "playerctl next" )
-- Toggle fullscreen
, ((superMask, xK_Escape), sendMessage NextLayout)
-- Resize windows
, ((superMask, xK_equal ), sendMessage $ IncMasterN 1)
, ((superMask, xK_minus ), sendMessage $ IncMasterN -1)
, ((superMask, xK_comma ), sendMessage Shrink )
, ((superMask, xK_period ), sendMessage Expand )
, ((superMask .|. shiftMask, xK_comma ), sendMessage MirrorShrink )
, ((superMask .|. shiftMask, xK_period), sendMessage MirrorExpand )
-- [D]o sink and lift
, ( (superMask, xK_d)
, submap $ M.fromList
[ ((0, xK_t), withFocused $ windows . W.sink)
, ((0, xK_l), withFocused $ windows . flip W.float centeredFloat)
] ]
) in
] fadeWindowsLogHook fadeHook
<+> refocusLastLogHook
-- Screenshots , startupHook = do
++ (let spawnOnce "fcitx5 &" -- Input method
fullscreen = "maim -u | xclip -in -selection clipboard -t image/png" spawn "feh --no-fehbg --bg-fill ~/.wallpaper &" -- wallpaper
withSelection = "maim -u -s -b 5 -o | xclip -in -selection clipboard -t image/png"
toFloat = "maim -u -s -b 5 -o | feh --auto-zoom -"
in
[ ((0, xK_Print), spawn fullscreen )
, ((superMask .|. shiftMask, xK_3 ), spawn fullscreen )
, ((superMask .|. shiftMask, xK_4 ), spawn withSelection)
, ((superMask .|. shiftMask, xK_5 ), spawn toFloat )
])
-- Yeet -- Needed to make gnome keyring work
++ (let -- https://wiki.archlinux.org/title/GNOME/Keyring#Using_gnome-keyring-daemon_outside_desktop_environments_(KDE,_GNOME,_XFCE,_...)
workspaceKeys = [xK_h, xK_t, xK_n, xK_s, xK_m, xK_w, xK_v, xK_z] spawn "dbus-update-activation-environment DISPLAY XAUTHORITY WAYLAND_DISPLAY"
in
[ ((superMask, k), windows $ W.greedyView space)
| (k, space) <- zip workspaceKeys myWorkspaces
]
++
[ ((superMask .|. altMask, k), windows $ W.greedyView space . W.shift space)
| (k, space) <- zip workspaceKeys myWorkspaces
]
++
[ ((superMask .|. controlMask, k), windows $ swapWithCurrent space)
| (k, space) <- zip workspaceKeys myWorkspaces
])
-- Launcher , layoutHook =
++ (let let tallr = reflectMsg . reflectHoriz
launchFirefox = "if type firefox; then firefox; else firefox-esr; fi" $ ResizableTall 1 (1/10) (3/7) []
launchDmenu = "dmenu_run -i -fn \"Iosevka-14\" -nb \"#36363a\" -nf \"#e2e2e4\" -sb \"#f7f7f8\" -sf \"#36363a\" -l 10" in smartBorders
lock = "xscreensaver-command -lock" ( named "Normal"
in (smartSpacingWithEdge 5 tallr)
[ ((controlMask .|. altMask, xK_m), namedScratchpadAction myScratchpads "cmus" ) ||| Full
, ((controlMask .|. altMask, xK_t), namedScratchpadAction myScratchpads "btop" ) )
, ((controlMask .|. altMask, xK_p), namedScratchpadAction myScratchpads "pass" )
, ((controlMask .|. altMask, xK_e), namedScratchpadAction myScratchpads "emoji-picker")
, ((controlMask .|. altMask, xK_b), spawn launchFirefox )
, ((superMask, xK_o), spawn launchDmenu )
, ((superMask, xK_l), spawn lock )
])
++ (let , manageHook =
powerprofile p = (p, spawn $ "powerprofilesctl set " ++ p) let
hasEvenWindows :: X Bool
hasEvenWindows = g <$> get
where g =
even . length . W.integrate'
. W.stack . W.workspace . W.current . windowset
in in
[ ( (superMask, xK_p), visualSubmap def $ M.fromList composeAll
[ ((0, xK_1), powerprofile "power-saver") [ className ~? "NautilusPreviewer" --> customFloating centeredFloat
, ((0, xK_2), powerprofile "balanced" ) , className =? "feh" --> doFloat
, ((0, xK_3), powerprofile "performance") , isFirefoxPIP --> doFloat
]
) , namedScratchpadManageHook myScratchpads
]) ]
<+>
composeOne
[ className =? "firefox" -?> insertPosition Above Newer
, className =? "sioyek" -?> insertPosition Below Older
, className =? "kitty" -?> insertPosition Below Newer
, className ~? "Nautilus" -?> insertPosition Below Older -- For some reason Older doesn't work
, ifM
(liftX hasEvenWindows)
(Just <$> insertPosition Below Newer) -- New window is odd
(Just <$> insertPosition Above Newer) -- New window is even
]
}
-- Only remove mappings that needs pass through (it's a map).
`removeKeys`
[ (superMask, xK_h)
, (superMask, xK_l)
, (superMask, xK_p)
-- It has been more than once that I actidently killed xmonad >:(
, (superMask .|. shiftMask, xK_q)
]
++ [ (superMask , n) | n <- [xK_1 .. xK_9] ]
++ [ (superMask .|. shiftMask, n) | n <- [xK_1 .. xK_9] ]
`additionalKeys`
[
-- Display
((0, xF86XK_MonBrightnessDown), spawn "light -U 5")
, ((0, xF86XK_MonBrightnessUp ), spawn "light -A 5")
, ((shiftMask, xF86XK_MonBrightnessDown), spawn "light -U 1")
, ((shiftMask, xF86XK_MonBrightnessUp ), spawn "light -A 1")
-- Volume adjustments
-- Don't overload the mute button
-- In case of doubt, smashing the button becomes deterministic
, ((0, xF86XK_AudioMute), spawn "pactl -- set-sink-mute 0 1" ) -- mute
, ((controlMask, xF86XK_AudioMute), spawn "pactl -- set-sink-mute 0 0" ) -- unmute
, ((0, xF86XK_AudioLowerVolume), spawn "pactl -- set-sink-volume 0 -5%")
, ((0, xF86XK_AudioRaiseVolume), spawn "pactl -- set-sink-volume 0 +5%")
, ((shiftMask, xF86XK_AudioLowerVolume), spawn "pactl -- set-sink-volume 0 -1%")
, ((shiftMask, xF86XK_AudioRaiseVolume), spawn "pactl -- set-sink-volume 0 +1%")
-- Playback control
, ((0, xF86XK_AudioPrev), spawn "playerctl previous" )
, ((0, xF86XK_AudioPlay), spawn "playerctl play-pause")
, ((0, xF86XK_AudioNext), spawn "playerctl next" )
-- Toggle fullscreen
, ((superMask, xK_Escape), sendMessage NextLayout)
-- Resize windows
, ((superMask, xK_equal ), sendMessage $ IncMasterN 1)
, ((superMask, xK_minus ), sendMessage $ IncMasterN -1)
, ((superMask, xK_comma ), sendMessage Shrink )
, ((superMask, xK_period ), sendMessage Expand )
, ((superMask .|. shiftMask, xK_comma ), sendMessage MirrorShrink )
, ((superMask .|. shiftMask, xK_period), sendMessage MirrorExpand )
-- [D]o sink and lift
, ( (superMask, xK_d)
, submap $ M.fromList
[ ((0, xK_t), withFocused $ windows . W.sink)
, ((0, xK_l), withFocused $ windows . flip W.float centeredFloat)
]
)
]
-- Screenshots
++ (let
fullscreen = "maim -u | xclip -in -selection clipboard -t image/png"
withSelection = "maim -u -s -b 5 -o | xclip -in -selection clipboard -t image/png"
toFloat = "maim -u -s -b 5 -o | feh --auto-zoom -"
in
[ ((0, xK_Print), spawn fullscreen )
, ((superMask .|. shiftMask, xK_3 ), spawn fullscreen )
, ((superMask .|. shiftMask, xK_4 ), spawn withSelection)
, ((superMask .|. shiftMask, xK_5 ), spawn toFloat )
])
-- Yeet
++ (let
workspaceKeys = [xK_h, xK_t, xK_n, xK_s, xK_m, xK_w, xK_v, xK_z]
in
[ ((superMask, k), windows $ W.greedyView space)
| (k, space) <- zip workspaceKeys myWorkspaces
]
++
[ ((superMask .|. altMask, k), windows $ W.greedyView space . W.shift space)
| (k, space) <- zip workspaceKeys myWorkspaces
]
++
[ ((superMask .|. controlMask, k), windows $ swapWithCurrent space)
| (k, space) <- zip workspaceKeys myWorkspaces
])
-- Launcher
++ (let
launchFirefox = "if type firefox; then firefox; else firefox-esr; fi"
launchDmenu = "dmenu_run -i -fn \"Iosevka-14\" -nb \"#36363a\" -nf \"#e2e2e4\" -sb \"#f7f7f8\" -sf \"#36363a\" -l 10"
lock = "xscreensaver-command -lock"
in
[ ((controlMask .|. altMask, xK_m), namedScratchpadAction myScratchpads "cmus" )
, ((controlMask .|. altMask, xK_t), namedScratchpadAction myScratchpads "btop" )
, ((controlMask .|. altMask, xK_p), namedScratchpadAction myScratchpads "pass" )
, ((controlMask .|. altMask, xK_e), namedScratchpadAction myScratchpads "emoji-picker")
, ((controlMask .|. altMask, xK_b), spawn launchFirefox )
, ((superMask, xK_o), spawn launchDmenu )
, ((superMask, xK_l), spawn lock )
])
++ (let
powerprofile p = (p, spawn $ "powerprofilesctl set " ++ p)
in
[ ( (superMask, xK_p), visualSubmap def $ M.fromList
[ ((0, xK_1), powerprofile "power-saver")
, ((0, xK_2), powerprofile "balanced" )
, ((0, xK_3), powerprofile "performance")
]
)
])
myTerm :: String myTerm :: String
myTerm = "kitty" myTerm = "kitty"