blob: b1b321915a48df885a0ca7bcdc9638331b7f4489 [file] [log] [blame]
Skyler Greyb43ac6b2022-10-31 00:48:34 +00001-- spell-checker:words xmonad
Skyler Greyf2c55ae2022-11-05 17:48:02 +00002import XMonad
Skyler Greyb43ac6b2022-10-31 00:48:34 +00003
Skyler Greyf2c55ae2022-11-05 17:48:02 +00004import System.Exit
5import XMonad.Util.EZConfig
Skyler Greyb43ac6b2022-10-31 00:48:34 +00006
Skyler Greyf2c55ae2022-11-05 17:48:02 +00007import XMonad.Config.Desktop
8import XMonad.Hooks.EwmhDesktops
9import XMonad.Hooks.ManageDocks
Skyler Grey51a0c612022-11-05 09:59:04 +000010
Skyler Grey08082762023-01-26 00:35:19 +000011import qualified DBus.Client as D
Skyler Greyf2c55ae2022-11-05 17:48:02 +000012import XMonad.Hooks.DynamicLog
13import XMonadLog
Skyler Grey51a0c612022-11-05 09:59:04 +000014
Skyler Grey08082762023-01-26 00:35:19 +000015import Blaze.ByteString.Builder (toByteString)
16import Foreign.C
17import XMonad
18import XMonad.Hooks.DynamicProperty (dynamicPropertyChange)
19import XMonad.Hooks.ManageHelpers (doFullFloat, doLower,
20 isInProperty, doRectFloat)
21import XMonad.Hooks.UrgencyHook
22import XMonad.Layout.Drawer (propertyToQuery)
Skyler Greyf2c55ae2022-11-05 17:48:02 +000023import XMonad.Layout.Gaps
24import XMonad.Layout.Spacing
Skyler Grey08082762023-01-26 00:35:19 +000025import qualified XMonad.StackSet as W
26import XMonad.Util.Hacks
27import qualified XMonad as W
28import XMonad.Util.PureX (curScreenId, curScreen)
Skyler Grey51a0c612022-11-05 09:59:04 +000029
Skyler Greye2ec0de2022-11-02 08:07:25 +000030terminal = "kitty" -- Kitty, my beloved <3
31launcher = "pkill rofi; rofi -show combi"
Skyler Grey08082762023-01-26 00:35:19 +000032networkManager = "wpa_cli select_network $(wpa_cli list_networks | tail -n +3 | awk '!seen[$2]++' | rofi -dmenu -window-title 'Select Network' | awk '{print $1;}')"
33
34screenshot = "mkdir -p ~/Screenshots && maim | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | xclip -select clipboard -t image/png"
35selectScreenshot = "mkdir -p ~/Screenshots && maim -s | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | xclip -select clipboard -t image/png"
36
Skyler Greye2ec0de2022-11-02 08:07:25 +000037modifierKey = mod4Mask -- Use Super as our mod key
38
Skyler Grey34021e32022-11-04 09:28:03 +000039statusBar = "pkill polybar; polybar"
Skyler Grey51a0c612022-11-05 09:59:04 +000040compositor = "pkill picom; picom"
Skyler Grey08082762023-01-26 00:35:19 +000041background = "pkill show; show ~/.xmonad/wallpaper.glsl > /dev/null"
Skyler Grey9db914a2023-02-19 23:50:59 +000042colorSelection = "xcolor | xclip -sel clip"
Skyler Grey08082762023-01-26 00:35:19 +000043keybindings = "setxkbmap -option caps:none && xmodmap ~/.Xmodmap"
Skyler Grey34021e32022-11-04 09:28:03 +000044
Skyler Greye2ec0de2022-11-02 08:07:25 +000045shift = shiftMask
46
Skyler Grey34021e32022-11-04 09:28:03 +000047startupHook = do
Skyler Grey51a0c612022-11-05 09:59:04 +000048 spawn Main.statusBar
49 spawn Main.compositor
50 spawn background
Skyler Grey08082762023-01-26 00:35:19 +000051 spawn keybindings
Skyler Greyf2c55ae2022-11-05 17:48:02 +000052
Skyler Grey34021e32022-11-04 09:28:03 +000053
Skyler Greyb43ac6b2022-10-31 00:48:34 +000054main :: IO ()
Skyler Grey51a0c612022-11-05 09:59:04 +000055main = XMonadLog.xmonadLog >>= main'
56
57main' :: D.Client -> IO ()
Skyler Grey08082762023-01-26 00:35:19 +000058main' dbus = xmonad
59 $ javaHack
60 $ ewmh . setEwmhActivateHook doAskUrgent
61 $ docks
62 $ def
Skyler Greye2ec0de2022-11-02 08:07:25 +000063 { modMask = modifierKey -- Use Super as our mod key
Skyler Grey51a0c612022-11-05 09:59:04 +000064 , borderWidth = 0
Skyler Greye2ec0de2022-11-02 08:07:25 +000065 , XMonad.terminal = Main.terminal
Skyler Grey51a0c612022-11-05 09:59:04 +000066 , XMonad.startupHook = Main.startupHook
67 , XMonad.logHook = dynamicLogWithPP (polybarHook dbus)
Skyler Grey08082762023-01-26 00:35:19 +000068 , XMonad.layoutHook = avoidStruts
69 $ smartSpacing 5
70 $ gaps [(U, 5), (D, 5), (L, 5), (R, 5)]
71 $ layoutHook def
Skyler Greyf2c55ae2022-11-05 17:48:02 +000072 , XMonad.manageHook = composeAll
Skyler Grey08082762023-01-26 00:35:19 +000073 [ isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP"
74 --> doIgnore <+> doLower <+> doLower
Skyler Greyf2c55ae2022-11-05 17:48:02 +000075 ] <+> manageHook def
Skyler Grey08082762023-01-26 00:35:19 +000076 , XMonad.handleEventHook = composeAll
77 [ windowedFullscreenFixEventHook
78 , dynamicPropertyChange "_NET_WM_WINDOW_TYPE"
79 (isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP"
80 --> doLower
81 <+> (ask >>= \w -> liftX (modifyWindowSet (W.delete w))
82 >> mempty)
83 <+> (ask >>= \w -> liftX (withDisplay $ \dpy -> io (moveResizeWindow dpy w 0 0 (fromIntegral $ displayWidth dpy $ defaultScreen dpy) (fromIntegral $ displayHeight dpy $ defaultScreen dpy))) >> mempty))
84 ]
85 <+> handleEventHook def
Skyler Greye2ec0de2022-11-02 08:07:25 +000086 } `additionalKeys`
87 [ ((modifierKey, xK_d), spawn launcher)
88 , ((modifierKey, xK_n), spawn networkManager)
Skyler Grey08082762023-01-26 00:35:19 +000089 , ((modifierKey .|. Main.shift, xK_q), kill)
Skyler Greye2ec0de2022-11-02 08:07:25 +000090 , ((modifierKey, xK_q), spawn "xmonad --restart")
Skyler Grey08082762023-01-26 00:35:19 +000091 , ((modifierKey .|. Main.shift, xK_c), io exitSuccess)
92 , ((modifierKey .|. Main.shift, xK_s), spawn selectScreenshot)
Skyler Grey9db914a2023-02-19 23:50:59 +000093 , ((modifierKey .|. Main.shift, xK_h), spawn colorSelection)
Skyler Grey08082762023-01-26 00:35:19 +000094 , ((0, xK_Print), spawn screenshot)
Skyler Greye2ec0de2022-11-02 08:07:25 +000095 ]