blob: 6c73454eb66af6b1342b3710ebb489ec08cc4acf [file] [log] [blame]
Skyler Greyb43ac6b2022-10-31 00:48:34 +00001-- spell-checker:words xmonad
Skyler Grey3a9a2b12023-02-13 08:04:05 +00002{-# OPTIONS_GHC -Wno-deferred-out-of-scope-variables #-}
Skyler Greyf2c55ae2022-11-05 17:48:02 +00003import XMonad
Skyler Greyb43ac6b2022-10-31 00:48:34 +00004
Skyler Greyf2c55ae2022-11-05 17:48:02 +00005import System.Exit
6import XMonad.Util.EZConfig
Skyler Greyb43ac6b2022-10-31 00:48:34 +00007
Skyler Greyf2c55ae2022-11-05 17:48:02 +00008import XMonad.Config.Desktop
9import XMonad.Hooks.EwmhDesktops
10import XMonad.Hooks.ManageDocks
Skyler Grey51a0c612022-11-05 09:59:04 +000011
Skyler Grey08082762023-01-26 00:35:19 +000012import qualified DBus.Client as D
Skyler Greyf2c55ae2022-11-05 17:48:02 +000013import XMonad.Hooks.DynamicLog
14import XMonadLog
Skyler Grey51a0c612022-11-05 09:59:04 +000015
Skyler Grey08082762023-01-26 00:35:19 +000016import Blaze.ByteString.Builder (toByteString)
17import Foreign.C
Skyler Grey3a9a2b12023-02-13 08:04:05 +000018import Graphics.X11.ExtraTypes (xF86XK_AudioLowerVolume,
19 xF86XK_AudioMute,
20 xF86XK_AudioRaiseVolume,
21 xF86XK_MonBrightnessDown,
22 xF86XK_MonBrightnessUp,
23 xF86XK_Xfer)
24import qualified XMonad as W
Skyler Grey08082762023-01-26 00:35:19 +000025import XMonad.Hooks.DynamicProperty (dynamicPropertyChange)
26import XMonad.Hooks.ManageHelpers (doFullFloat, doLower,
Skyler Grey3a9a2b12023-02-13 08:04:05 +000027 doRectFloat, isInProperty)
Skyler Grey08082762023-01-26 00:35:19 +000028import XMonad.Hooks.UrgencyHook
29import XMonad.Layout.Drawer (propertyToQuery)
Skyler Greyf2c55ae2022-11-05 17:48:02 +000030import XMonad.Layout.Gaps
31import XMonad.Layout.Spacing
Skyler Grey08082762023-01-26 00:35:19 +000032import qualified XMonad.StackSet as W
33import XMonad.Util.Hacks
Skyler Grey3a9a2b12023-02-13 08:04:05 +000034import XMonad.Util.PureX (curScreen, curScreenId)
35import XMonad.Util.Run (safeSpawn, safeSpawnProg)
Skyler Grey51a0c612022-11-05 09:59:04 +000036
Skyler Grey3a9a2b12023-02-13 08:04:05 +000037volumeChangeCmd = "${{./vol_change.py}}"
38
39terminal = "/usr/bin/env SHLVL=0 kitty" -- Kitty, my beloved <3
Skyler Greye2ec0de2022-11-02 08:07:25 +000040launcher = "pkill rofi; rofi -show combi"
Skyler Grey08082762023-01-26 00:35:19 +000041networkManager = "wpa_cli select_network $(wpa_cli list_networks | tail -n +3 | awk '!seen[$2]++' | rofi -dmenu -window-title 'Select Network' | awk '{print $1;}')"
42
43screenshot = "mkdir -p ~/Screenshots && maim | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | xclip -select clipboard -t image/png"
Skyler Greye631f4c2023-02-14 17:20:18 +000044selectScreenshot = "mkdir -p ~/Screenshots && maim -us | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | xclip -select clipboard -t image/png"
Skyler Grey08082762023-01-26 00:35:19 +000045
Skyler Greye2ec0de2022-11-02 08:07:25 +000046modifierKey = mod4Mask -- Use Super as our mod key
47
Skyler Grey3a9a2b12023-02-13 08:04:05 +000048statusBar = "pkill polybar; polybar main; polybar dp1; polybar dp2; polybar dp3; polybar dp4"
Skyler Grey51a0c612022-11-05 09:59:04 +000049compositor = "pkill picom; picom"
Skyler Grey08082762023-01-26 00:35:19 +000050background = "pkill show; show ~/.xmonad/wallpaper.glsl > /dev/null"
Skyler Grey9db914a2023-02-19 23:50:59 +000051colorSelection = "xcolor | xclip -sel clip"
Skyler Grey08082762023-01-26 00:35:19 +000052keybindings = "setxkbmap -option caps:none && xmodmap ~/.Xmodmap"
Skyler Grey34021e32022-11-04 09:28:03 +000053
Skyler Greye2ec0de2022-11-02 08:07:25 +000054shift = shiftMask
55
Skyler Grey3a9a2b12023-02-13 08:04:05 +000056-- spell-checker:words xobsock
57xobsock = "$XDG_RUNTIME_DIR/xob.sock"
58
Skyler Grey34021e32022-11-04 09:28:03 +000059startupHook = do
Skyler Grey51a0c612022-11-05 09:59:04 +000060 spawn Main.statusBar
61 spawn Main.compositor
62 spawn background
Skyler Grey08082762023-01-26 00:35:19 +000063 spawn keybindings
Skyler Grey3a9a2b12023-02-13 08:04:05 +000064 spawn "pgrep keepass || run_keepass"
65 spawn $ "pkill xob; rm -f " ++ xobsock ++ " && mkfifo " ++ xobsock ++ " && tail -f " ++ xobsock ++ " | xob"
Skyler Greyf2c55ae2022-11-05 17:48:02 +000066
Skyler Grey34021e32022-11-04 09:28:03 +000067
Skyler Greyb43ac6b2022-10-31 00:48:34 +000068main :: IO ()
Skyler Grey51a0c612022-11-05 09:59:04 +000069main = XMonadLog.xmonadLog >>= main'
70
71main' :: D.Client -> IO ()
Skyler Grey08082762023-01-26 00:35:19 +000072main' dbus = xmonad
73 $ javaHack
74 $ ewmh . setEwmhActivateHook doAskUrgent
75 $ docks
76 $ def
Skyler Greye2ec0de2022-11-02 08:07:25 +000077 { modMask = modifierKey -- Use Super as our mod key
Skyler Grey51a0c612022-11-05 09:59:04 +000078 , borderWidth = 0
Skyler Greye2ec0de2022-11-02 08:07:25 +000079 , XMonad.terminal = Main.terminal
Skyler Grey51a0c612022-11-05 09:59:04 +000080 , XMonad.startupHook = Main.startupHook
81 , XMonad.logHook = dynamicLogWithPP (polybarHook dbus)
Skyler Grey08082762023-01-26 00:35:19 +000082 , XMonad.layoutHook = avoidStruts
83 $ smartSpacing 5
84 $ gaps [(U, 5), (D, 5), (L, 5), (R, 5)]
85 $ layoutHook def
Skyler Greyf2c55ae2022-11-05 17:48:02 +000086 , XMonad.manageHook = composeAll
Skyler Grey08082762023-01-26 00:35:19 +000087 [ isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP"
88 --> doIgnore <+> doLower <+> doLower
Skyler Greyf2c55ae2022-11-05 17:48:02 +000089 ] <+> manageHook def
Skyler Grey08082762023-01-26 00:35:19 +000090 , XMonad.handleEventHook = composeAll
91 [ windowedFullscreenFixEventHook
92 , dynamicPropertyChange "_NET_WM_WINDOW_TYPE"
93 (isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP"
94 --> doLower
95 <+> (ask >>= \w -> liftX (modifyWindowSet (W.delete w))
96 >> mempty)
97 <+> (ask >>= \w -> liftX (withDisplay $ \dpy -> io (moveResizeWindow dpy w 0 0 (fromIntegral $ displayWidth dpy $ defaultScreen dpy) (fromIntegral $ displayHeight dpy $ defaultScreen dpy))) >> mempty))
98 ]
99 <+> handleEventHook def
Skyler Greye2ec0de2022-11-02 08:07:25 +0000100 } `additionalKeys`
101 [ ((modifierKey, xK_d), spawn launcher)
102 , ((modifierKey, xK_n), spawn networkManager)
Skyler Grey08082762023-01-26 00:35:19 +0000103 , ((modifierKey .|. Main.shift, xK_q), kill)
Skyler Greye2ec0de2022-11-02 08:07:25 +0000104 , ((modifierKey, xK_q), spawn "xmonad --restart")
Skyler Grey08082762023-01-26 00:35:19 +0000105 , ((modifierKey .|. Main.shift, xK_c), io exitSuccess)
106 , ((modifierKey .|. Main.shift, xK_s), spawn selectScreenshot)
Skyler Grey9db914a2023-02-19 23:50:59 +0000107 , ((modifierKey .|. Main.shift, xK_h), spawn colorSelection)
Skyler Grey08082762023-01-26 00:35:19 +0000108 , ((0, xK_Print), spawn screenshot)
Skyler Grey3a9a2b12023-02-13 08:04:05 +0000109 , ((modifierKey .|. Main.shift, xK_Return), spawn Main.terminal)
110 , ((0, xF86XK_AudioLowerVolume), spawn $ volumeChangeCmd ++ " -d")
111 , ((0, xF86XK_AudioRaiseVolume), spawn $ volumeChangeCmd ++ " -u")
112 , ((0, xF86XK_AudioMute), spawn $ volumeChangeCmd ++ " -m")
113 , ((modifierKey, xF86XK_AudioLowerVolume), spawn $ volumeChangeCmd ++ " -d -i")
114 , ((modifierKey, xF86XK_AudioRaiseVolume), spawn $ volumeChangeCmd ++ " -u -i")
115 , ((modifierKey, xF86XK_AudioMute), spawn $ volumeChangeCmd ++ " -m -i")
116 , ((0, xF86XK_MonBrightnessDown), spawn $ "light -U 6 && light -G | cut -d'.' -f1 > " ++ xobsock)
117 , ((0, xF86XK_MonBrightnessUp), spawn $ "light -A 6 && light -G | cut -d'.' -f1 > " ++ xobsock)
118 , ((modifierKey, xF86XK_MonBrightnessDown), spawn $ "light -U 3 && light -G | cut -d'.' -f1 > " ++ xobsock)
119 , ((modifierKey, xF86XK_MonBrightnessUp), spawn $ "light -A 3 && light -G | cut -d'.' -f1 > " ++ xobsock)
Skyler Greye2ec0de2022-11-02 08:07:25 +0000120 ]