blob: b478be1d2064733395e7acf1bed42004b25c28c3 [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"
42keybindings = "setxkbmap -option caps:none && xmodmap ~/.Xmodmap"
Skyler Grey34021e32022-11-04 09:28:03 +000043
Skyler Greye2ec0de2022-11-02 08:07:25 +000044shift = shiftMask
45
Skyler Grey34021e32022-11-04 09:28:03 +000046startupHook = do
Skyler Grey51a0c612022-11-05 09:59:04 +000047 spawn Main.statusBar
48 spawn Main.compositor
49 spawn background
Skyler Grey08082762023-01-26 00:35:19 +000050 spawn keybindings
Skyler Greyf2c55ae2022-11-05 17:48:02 +000051
Skyler Grey34021e32022-11-04 09:28:03 +000052
Skyler Greyb43ac6b2022-10-31 00:48:34 +000053main :: IO ()
Skyler Grey51a0c612022-11-05 09:59:04 +000054main = XMonadLog.xmonadLog >>= main'
55
56main' :: D.Client -> IO ()
Skyler Grey08082762023-01-26 00:35:19 +000057main' dbus = xmonad
58 $ javaHack
59 $ ewmh . setEwmhActivateHook doAskUrgent
60 $ docks
61 $ def
Skyler Greye2ec0de2022-11-02 08:07:25 +000062 { modMask = modifierKey -- Use Super as our mod key
Skyler Grey51a0c612022-11-05 09:59:04 +000063 , borderWidth = 0
Skyler Greye2ec0de2022-11-02 08:07:25 +000064 , XMonad.terminal = Main.terminal
Skyler Grey51a0c612022-11-05 09:59:04 +000065 , XMonad.startupHook = Main.startupHook
66 , XMonad.logHook = dynamicLogWithPP (polybarHook dbus)
Skyler Grey08082762023-01-26 00:35:19 +000067 , XMonad.layoutHook = avoidStruts
68 $ smartSpacing 5
69 $ gaps [(U, 5), (D, 5), (L, 5), (R, 5)]
70 $ layoutHook def
Skyler Greyf2c55ae2022-11-05 17:48:02 +000071 , XMonad.manageHook = composeAll
Skyler Grey08082762023-01-26 00:35:19 +000072 [ isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP"
73 --> doIgnore <+> doLower <+> doLower
Skyler Greyf2c55ae2022-11-05 17:48:02 +000074 ] <+> manageHook def
Skyler Grey08082762023-01-26 00:35:19 +000075 , XMonad.handleEventHook = composeAll
76 [ windowedFullscreenFixEventHook
77 , dynamicPropertyChange "_NET_WM_WINDOW_TYPE"
78 (isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP"
79 --> doLower
80 <+> (ask >>= \w -> liftX (modifyWindowSet (W.delete w))
81 >> mempty)
82 <+> (ask >>= \w -> liftX (withDisplay $ \dpy -> io (moveResizeWindow dpy w 0 0 (fromIntegral $ displayWidth dpy $ defaultScreen dpy) (fromIntegral $ displayHeight dpy $ defaultScreen dpy))) >> mempty))
83 ]
84 <+> handleEventHook def
Skyler Greye2ec0de2022-11-02 08:07:25 +000085 } `additionalKeys`
86 [ ((modifierKey, xK_d), spawn launcher)
87 , ((modifierKey, xK_n), spawn networkManager)
Skyler Grey08082762023-01-26 00:35:19 +000088 , ((modifierKey .|. Main.shift, xK_q), kill)
Skyler Greye2ec0de2022-11-02 08:07:25 +000089 , ((modifierKey, xK_q), spawn "xmonad --restart")
Skyler Grey08082762023-01-26 00:35:19 +000090 , ((modifierKey .|. Main.shift, xK_c), io exitSuccess)
91 , ((modifierKey .|. Main.shift, xK_s), spawn selectScreenshot)
92 , ((0, xK_Print), spawn screenshot)
Skyler Greye2ec0de2022-11-02 08:07:25 +000093 ]