Use ALE fixers for XMonad config

This commit is contained in:
daniele 2024-12-23 19:32:36 +01:00
parent 2fc1f6c0a9
commit 4c67611b8e
Signed by: fuxino
GPG Key ID: 981A2B2A3BBF5514

View File

@ -1,12 +1,10 @@
-- Import -- Import
import XMonad
import Data.Default import Data.Default
import Data.Monoid import Data.Monoid
import Graphics.X11.ExtraTypes.XF86
-- Actions import XMonad
import XMonad.Actions.PhysicalScreens import XMonad.Actions.PhysicalScreens
-- Hooks
import XMonad.Hooks.DynamicLog import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.FloatConfigureReq import XMonad.Hooks.FloatConfigureReq
@ -15,35 +13,26 @@ 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
-- Layouts
import XMonad.Layout.Grid import XMonad.Layout.Grid
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.Magnifier
import XMonad.Layout.NoBorders import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
import XMonad.Layout.Renamed
import XMonad.Layout.Spiral import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns import XMonad.Layout.ThreeColumns
import qualified XMonad.StackSet as W
-- Layout modifiers
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.Magnifier
import XMonad.Layout.PerWorkspace
import XMonad.Layout.Renamed
-- Util
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.NamedScratchpad import XMonad.Util.NamedScratchpad
import XMonad.Util.SpawnOnce import XMonad.Util.SpawnOnce
-- Extra keys
import Graphics.X11.ExtraTypes.XF86
import qualified XMonad.StackSet as W
-- Main -- Main
main :: IO () main :: IO ()
main = xmonad main =
xmonad
. ewmhFullscreen . ewmhFullscreen
. ewmh . ewmh
. withEasySB (xmobar1 <> xmobar2) defToggleStrutsKey . withEasySB (xmobar1 <> xmobar2) defToggleStrutsKey
@ -67,7 +56,9 @@ myFocusBorderColor = "#41a6b5"
myKeyboardLayoutIT :: String myKeyboardLayoutIT :: String
myKeyboardLayoutIT = " -layout it" myKeyboardLayoutIT = " -layout it"
myKeyboardLayoutUS = " -layout us" myKeyboardLayoutUS = " -layout us"
myKeyboardLayoutSK = " -layout sk -variant qwerty" myKeyboardLayoutSK = " -layout sk -variant qwerty"
myScreenshotDir :: String myScreenshotDir :: String
@ -78,12 +69,12 @@ myScreenshotName = "Screenshot-%Y-%m-%d-%H%M%S.png"
myScratchpads :: [NamedScratchpad] myScratchpads :: [NamedScratchpad]
myScratchpads = myScratchpads =
[ NS "Windscribe" "windscribe" (className =? "Windscribe2") (customFloating $ W.RationalRect 0.4 0.4 0.6 0.6) [ NS "Windscribe" "windscribe" (className =? "Windscribe2") (customFloating $ W.RationalRect 0.4 0.4 0.6 0.6),
, NS "Terminal" spawnTerminal (title =? "kitty-float") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6) NS "Terminal" spawnTerminal (title =? "kitty-float") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6),
, NS "Music" spawnMusic (title =? "ncmpcpp") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6) NS "Music" spawnMusic (title =? "ncmpcpp") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6),
, NS "Mail" spawnMail (title =? "mutt") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6) NS "Mail" spawnMail (title =? "mutt") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6),
, NS "Cal" spawnCal (title =? "calcurse") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6) NS "Cal" spawnCal (title =? "calcurse") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6),
, NS "Btop" spawnBtop (title =? "btop") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6) NS "Btop" spawnBtop (title =? "btop") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6)
] ]
where where
spawnTerminal = myTerminal ++ " -T kitty-float" spawnTerminal = myTerminal ++ " -T kitty-float"
@ -93,53 +84,51 @@ myScratchpads =
spawnBtop = myTerminal ++ " -T btop btop" spawnBtop = myTerminal ++ " -T btop btop"
-- Config -- Config
myConfig = def myConfig =
{ modMask = myModMask def
, terminal = myTerminal { modMask = myModMask,
, workspaces = myWorkspaces terminal = myTerminal,
, focusedBorderColor = myFocusBorderColor workspaces = myWorkspaces,
, normalBorderColor = myNormBorderColor focusedBorderColor = myFocusBorderColor,
, layoutHook = myLayoutHook normalBorderColor = myNormBorderColor,
, startupHook = myStartupHook layoutHook = myLayoutHook,
, manageHook = myManageHook startupHook = myStartupHook,
, handleEventHook = myHandleEventHook manageHook = myManageHook,
handleEventHook = myHandleEventHook
} }
`additionalKeysP` `additionalKeysP` [ ("M-S-l", spawn "slock"),
[ ("M-S-l" , spawn "slock" ) ("<Print>", unGrab *> spawn ("scrot " ++ myScreenshotDir ++ myScreenshotName)),
, ("<Print>" , unGrab *> spawn ("scrot " ++ myScreenshotDir ++ myScreenshotName) ) ("S-<Print>", unGrab *> spawn ("scrot -s " ++ myScreenshotDir ++ myScreenshotName)),
, ("S-<Print>" , unGrab *> spawn ("scrot -s " ++ myScreenshotDir ++ myScreenshotName) ) ("M-S-<Print>", unGrab *> spawn ("scrot -u " ++ myScreenshotDir ++ myScreenshotName)),
, ("M-S-<Print>" , unGrab *> spawn ("scrot -u " ++ myScreenshotDir ++ myScreenshotName) ) ("M-d", spawn "dmenu_run"),
, ("M-d" , spawn "dmenu_run" ) ("M-p", spawn "passmenu -i"),
, ("M-p" , spawn "passmenu -i" ) ("M-f", sendMessage $ JumpToLayout "Tabbed"),
, ("M-f" , sendMessage $ JumpToLayout "Tabbed" ) ("M-i", spawn $ "setxkbmap" ++ myKeyboardLayoutIT),
, ("M-i" , spawn $ "setxkbmap" ++ myKeyboardLayoutIT ) ("M-u", spawn $ "setxkbmap" ++ myKeyboardLayoutUS),
, ("M-u" , spawn $ "setxkbmap" ++ myKeyboardLayoutUS ) ("M-s", spawn $ "setxkbmap" ++ myKeyboardLayoutSK),
, ("M-s" , spawn $ "setxkbmap" ++ myKeyboardLayoutSK ) ("M-S-v", namedScratchpadAction myScratchpads "Windscribe"),
, ("M-S-v" , namedScratchpadAction myScratchpads "Windscribe" ) ("M-S-s", namedScratchpadAction myScratchpads "Terminal"),
, ("M-S-s" , namedScratchpadAction myScratchpads "Terminal" ) ("M-S-a", namedScratchpadAction myScratchpads "Cal"),
, ("M-S-a" , namedScratchpadAction myScratchpads "Cal" ) ("M-o", namedScratchpadAction myScratchpads "Btop"),
, ("M-o" , namedScratchpadAction myScratchpads "Btop" ) ("M-x", spawn "bluetoothctl connect E8:EE:CC:3E:A6:0D"),
, ("M-x" , spawn "bluetoothctl connect E8:EE:CC:3E:A6:0D" ) ("M-S-x", spawn "bluetoothctl disconnect E8:EE:CC:3E:A6:0D")
, ("M-S-x" , spawn "bluetoothctl disconnect E8:EE:CC:3E:A6:0D" )
] ]
`additionalKeys` `additionalKeys` [ ((0, xF86XK_AudioMute), spawn "pactl set-sink-mute $(pactl get-default-sink) toggle"),
[ ((0, xF86XK_AudioMute) , spawn "pactl set-sink-mute $(pactl get-default-sink) toggle" ) ((0, xF86XK_AudioLowerVolume), spawn "pactl set-sink-volume $(pactl get-default-sink) -10%"),
, ((0, xF86XK_AudioLowerVolume) , spawn "pactl set-sink-volume $(pactl get-default-sink) -10%" ) ((0, xF86XK_AudioRaiseVolume), spawn "pactl set-sink-volume $(pactl get-default-sink) +10%"),
, ((0, xF86XK_AudioRaiseVolume) , spawn "pactl set-sink-volume $(pactl get-default-sink) +10%" ) ((0, xF86XK_Calculator), spawn "qalculate-gtk"),
, ((0, xF86XK_Calculator) , spawn "qalculate-gtk" ) ((0, xF86XK_HomePage), spawn myBrowser),
, ((0, xF86XK_HomePage) , spawn myBrowser ) ((0, xF86XK_Mail), namedScratchpadAction myScratchpads "Mail"),
, ((0, xF86XK_Mail) , namedScratchpadAction myScratchpads "Mail" ) ((0, xF86XK_Tools), namedScratchpadAction myScratchpads "Music")
, ((0, xF86XK_Tools) , namedScratchpadAction myScratchpads "Music" )
] ]
++ ++ [ ((myModMask .|. mask, key), f sc)
[((myModMask .|. mask, key), f sc) | (key, sc) <- zip [xK_w, xK_e] [0 ..],
| (key, sc) <- zip [xK_w, xK_e] [0..] (f, mask) <- [(viewScreen def, 0), (sendToScreen def, shiftMask)]
, (f, mask) <- [(viewScreen def, 0), (sendToScreen def, shiftMask)]
] ]
-- Workspaces -- Workspaces
myWorkspaces :: [String] myWorkspaces :: [String]
myWorkspaces = [ "1:\xf489 ", "2:\xe743 ", "3:\xf1b6 ", "4:\xf10b ", "5:\xead9 ", "6:\xeb69 " ] ++ map show [7..9] myWorkspaces = ["1:\xf489 ", "2:\xe743 ", "3:\xf1b6 ", "4:\xf10b ", "5:\xead9 ", "6:\xeb69 "] ++ map show [7 .. 9]
-- Layout -- Layout
myLayoutHook = onWorkspace "2:\xe743 " myWebLayout $ onWorkspace "3:\xf1b6 " myGamesLayout myDefaultLayout myLayoutHook = onWorkspace "2:\xe743 " myWebLayout $ onWorkspace "3:\xf1b6 " myGamesLayout myDefaultLayout
@ -147,35 +136,39 @@ myLayoutHook = onWorkspace "2:\xe743 " myWebLayout $ onWorkspace "3:\xf1b6 " myG
myWebLayout = avoidStruts $ smartBorders $ myTabbed ||| tiled ||| Mirror tiled ||| threeCol ||| Grid ||| spiral 0.856 myWebLayout = avoidStruts $ smartBorders $ myTabbed ||| tiled ||| Mirror tiled ||| threeCol ||| Grid ||| spiral 0.856
myGamesLayout = avoidStruts $ smartBorders Full myGamesLayout = avoidStruts $ smartBorders Full
myDefaultLayout = avoidStruts $ smartBorders $ tiled ||| Mirror tiled ||| myTabbed ||| threeCol ||| Grid ||| spiral 0.856 myDefaultLayout = avoidStruts $ smartBorders $ tiled ||| Mirror tiled ||| myTabbed ||| threeCol ||| Grid ||| spiral 0.856
threeCol threeCol =
= renamed [Replace "ThreeCol"] renamed [Replace "ThreeCol"] $
$ magnifiercz' 1.3 magnifiercz' 1.3 $
$ ThreeColMid nmaster delta ratio ThreeColMid nmaster delta ratio
myTabbed myTabbed =
= renamed [Replace "Tabbed"] renamed [Replace "Tabbed"] $
$ tabbed shrinkText myTabConfig tabbed shrinkText myTabConfig
myTabConfig = def { activeColor = "#737aa2" myTabConfig =
, inactiveColor = "#24283b" def
{ activeColor = "#737aa2",
inactiveColor = "#24283b"
} }
tiled = Tall nmaster delta ratio tiled = Tall nmaster delta ratio
nmaster = 1 nmaster = 1
ratio = 1/2 ratio = 1 / 2
delta = 3/100 delta = 3 / 100
-- Xmobar -- Xmobar
xmobar1 = statusBarProp "xmobar -x 0 ~/.config/xmobar/xmobarrc_laptop" (pure myXmobarPP) xmobar1 = statusBarProp "xmobar -x 0 ~/.config/xmobar/xmobarrc_laptop" (pure myXmobarPP)
xmobar2 = statusBarProp "xmobar -x 1 ~/.config/xmobar/xmobarrc_hdmi" (pure myXmobarPP) xmobar2 = statusBarProp "xmobar -x 1 ~/.config/xmobar/xmobarrc_hdmi" (pure myXmobarPP)
myXmobarPP :: PP myXmobarPP :: PP
myXmobarPP = def myXmobarPP =
{ ppSep = pink "" def
, ppTitleSanitize = xmobarStrip { ppSep = pink "",
, ppCurrent = wrap " " "" . xmobarBorder "Top" "#ff79c6" 2 ppTitleSanitize = xmobarStrip,
, ppHidden = cultured . wrap " " "" ppCurrent = wrap " " "" . xmobarBorder "Top" "#ff79c6" 2,
, ppHiddenNoWindows = outerspace . wrap " " "" ppHidden = cultured . wrap " " "",
, ppUrgent = sunsetorange . wrap (keylime "!") (keylime "!") ppHiddenNoWindows = outerspace . wrap " " "",
, ppOrder = \[ws, l, _, wins] -> [ws, l, wins] ppUrgent = sunsetorange . wrap (keylime "!") (keylime "!"),
, ppExtras = [logTitles formatFocused formatUnfocused] ppOrder = \[ws, l, _, wins] -> [ws, l, wins],
ppExtras = [logTitles formatFocused formatUnfocused]
} }
where where
formatFocused = wrap (cultured "[") (cultured "]") . pink . ppWindow formatFocused = wrap (cultured "[") (cultured "]") . pink . ppWindow
@ -198,7 +191,8 @@ myStartupHook = do
spawnOnce "xsetroot -cursor_name left_ptr" spawnOnce "xsetroot -cursor_name left_ptr"
spawnOnce "mons -e left && ~/.fehbg" spawnOnce "mons -e left && ~/.fehbg"
spawnOnce "xautolock -time 10 -locker slock -detectsleep" spawnOnce "xautolock -time 10 -locker slock -detectsleep"
spawnOnce "trayer -l --edge top --align right --SetDockType true \ spawnOnce
"trayer -l --edge top --align right --SetDockType true \
\--SetPartialStrut true --expand true --widthtype request \ \--SetPartialStrut true --expand true --widthtype request \
\--transparent true --tint 0x232634 --height 18 \ \--transparent true --tint 0x232634 --height 18 \
\--monitor 0" \--monitor 0"
@ -214,39 +208,42 @@ myStartupHook = do
-- Manage hook -- Manage hook
myManageHook :: ManageHook myManageHook :: ManageHook
myManageHook = composeAll myManageHook =
[ className =? "Gpodder" --> doShift "5:\xead9 " composeAll
, className =? "An Anime Game Launcher" --> doShift "3:\xf1b6 " [ className =? "Gpodder" --> doShift "5:\xead9 ",
, className =? "Qalculate-gtk" --> doFloat className =? "An Anime Game Launcher" --> doShift "3:\xf1b6 ",
, className =? "Signal" --> doShift "4:\xf10b " className =? "Qalculate-gtk" --> doFloat,
, className =? "Spotify" --> doShift "5:\xead9 " className =? "Signal" --> doShift "4:\xf10b ",
, className =? "Transmission-gtk" --> doShift "2:\xe743 " className =? "Spotify" --> doShift "5:\xead9 ",
, className =? "Viewnior" --> doFloat className =? "Transmission-gtk" --> doShift "2:\xe743 ",
, className =? "Vivaldi-stable" --> doShift "2:\xe743 " className =? "Viewnior" --> doFloat,
, className =? "Xmessage" --> doFloat className =? "Vivaldi-stable" --> doShift "2:\xe743 ",
, className =? "Xreader" --> doShift "6:\xeb69 " className =? "Xmessage" --> doFloat,
, className =? "calibre" --> doShift "6:\xeb69 " className =? "Xreader" --> doShift "6:\xeb69 ",
, className =? "discord" --> doShift "4:\xf10b " className =? "calibre" --> doShift "6:\xeb69 ",
, className =? "explorer.exe" --> doShift "3:\xf1b6 " className =? "discord" --> doShift "4:\xf10b ",
, className =? "feh" --> doFloat className =? "explorer.exe" --> doShift "3:\xf1b6 ",
, title =? "glxgears" --> doFloat className =? "feh" --> doFloat,
, className =? "library_manager" --> doShift "6:\xeb69 " title =? "glxgears" --> doFloat,
, className =? "libreoffice-calc" --> doShift "6:\xeb69 " className =? "library_manager" --> doShift "6:\xeb69 ",
, className =? "libreoffice-writer" --> doShift "6:\xeb69 " className =? "libreoffice-calc" --> doShift "6:\xeb69 ",
, className =? "mpv" --> doFullFloat className =? "libreoffice-writer" --> doShift "6:\xeb69 ",
, className =? "mpv" --> doShift "5:\xead9 " className =? "mpv" --> doFullFloat,
, className =? myTerminal --> doShift "1:\xf489 " className =? "mpv" --> doShift "5:\xead9 ",
, title =? "Neverwinter" --> doShift "3:\xf1b6 " className =? myTerminal --> doShift "1:\xf489 ",
, className =? "steam" --> doShift "3:\xf1b6 " title =? "Neverwinter" --> doShift "3:\xf1b6 ",
, className =? "steam_app_109600" --> doFloat className =? "steam" --> doShift "3:\xf1b6 ",
, className =? "transmission-gtk" --> doShift "2:\xe743 " className =? "steam_app_109600" --> doFloat,
, isDialog --> doFloat className =? "transmission-gtk" --> doShift "2:\xe743 ",
, isFullscreen --> doFullFloat isDialog --> doFloat,
] <+> namedScratchpadManageHook myScratchpads isFullscreen --> doFullFloat
]
<+> namedScratchpadManageHook myScratchpads
--Handle event hook -- Handle event hook
myHandleEventHook :: Event -> X All myHandleEventHook :: Event -> X All
myHandleEventHook = handleEventHook def myHandleEventHook =
handleEventHook def
<> Hacks.trayerAboveXmobarEventHook <> Hacks.trayerAboveXmobarEventHook
<> Hacks.trayerPaddingXmobarEventHook <> Hacks.trayerPaddingXmobarEventHook
<> Hacks.fixSteamFlicker <> Hacks.fixSteamFlicker