Skyler Grey | b43ac6b | 2022-10-31 00:48:34 +0000 | [diff] [blame] | 1 | -- spell-checker:words xmonad |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 2 | {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} |
| 3 | {-# HLINT ignore "Move brackets to avoid $" #-} |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 4 | import XMonad |
Skyler Grey | b43ac6b | 2022-10-31 00:48:34 +0000 | [diff] [blame] | 5 | |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 6 | import System.Exit |
| 7 | import XMonad.Util.EZConfig |
Skyler Grey | b43ac6b | 2022-10-31 00:48:34 +0000 | [diff] [blame] | 8 | |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 9 | import XMonad.Config.Desktop |
| 10 | import XMonad.Hooks.EwmhDesktops |
| 11 | import XMonad.Hooks.ManageDocks |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 12 | |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 13 | import qualified DBus.Client as D |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 14 | import XMonad.Hooks.DynamicLog |
| 15 | import XMonadLog |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 16 | |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 17 | import Blaze.ByteString.Builder (toByteString) |
| 18 | import Foreign.C |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 19 | import Graphics.X11.ExtraTypes (xF86XK_AudioLowerVolume, |
| 20 | xF86XK_AudioMute, |
| 21 | xF86XK_AudioRaiseVolume, |
| 22 | xF86XK_MonBrightnessDown, |
| 23 | xF86XK_MonBrightnessUp, |
| 24 | xF86XK_Xfer) |
| 25 | import qualified XMonad as W |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 26 | import XMonad.Hooks.DynamicProperty (dynamicPropertyChange) |
| 27 | import XMonad.Hooks.ManageHelpers (doFullFloat, doLower, |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 28 | doRectFloat, isInProperty) |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 29 | import XMonad.Hooks.UrgencyHook |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 30 | import XMonad.Layout (Tall) |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 31 | import XMonad.Layout.Drawer (propertyToQuery) |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 32 | import XMonad.Layout.Gaps |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 33 | import XMonad.Layout.Grid |
| 34 | import XMonad.Layout.MultiToggle (mkToggle) |
| 35 | import XMonad.Layout.NoBorders (smartBorders, SetsAmbiguous, hiddens, Ambiguity (OnlyScreenFloat, Combine), lessBorders, With (Union), hasBorder) |
| 36 | import XMonad.Layout.ResizableTile (ResizableTall (ResizableTall), MirrorResize (MirrorShrink, MirrorExpand)) |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 37 | import XMonad.Layout.Spacing |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 38 | import qualified XMonad.StackSet as W |
| 39 | import XMonad.Util.Hacks |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 40 | import XMonad.Util.PureX (curScreen, curScreenId) |
| 41 | import XMonad.Util.Run (safeSpawn, safeSpawnProg) |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 42 | import qualified Data.Map as M |
| 43 | import XMonad.StackSet (allWindows) |
| 44 | import Data.Containers |
| 45 | import Data.List ((\\)) |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 46 | |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 47 | volumeChangeCmd = "${{./vol_change.py}}" |
| 48 | |
| 49 | terminal = "/usr/bin/env SHLVL=0 kitty" -- Kitty, my beloved <3 |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 50 | launcher = "pkill rofi; rofi -show combi" |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 51 | networkManager = "wpa_cli select_network $(wpa_cli list_networks | tail -n +3 | awk '!seen[$2]++' | rofi -dmenu -window-title 'Select Network' | awk '{print $1;}')" |
| 52 | |
| 53 | screenshot = "mkdir -p ~/Screenshots && maim | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | xclip -select clipboard -t image/png" |
Skyler Grey | e631f4c | 2023-02-14 17:20:18 +0000 | [diff] [blame] | 54 | selectScreenshot = "mkdir -p ~/Screenshots && maim -us | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | xclip -select clipboard -t image/png" |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 55 | |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 56 | modifierKey = mod4Mask -- Use Super as our mod key |
| 57 | |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 58 | statusBar = "pkill polybar; polybar main; polybar dp1; polybar dp2; polybar dp3; polybar dp4" |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 59 | compositor = "pkill picom; picom" |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 60 | background = "pkill show; show ~/.xmonad/wallpaper.glsl > /dev/null" |
Skyler Grey | 9db914a | 2023-02-19 23:50:59 +0000 | [diff] [blame] | 61 | colorSelection = "xcolor | xclip -sel clip" |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 62 | keybindings = "setxkbmap -option caps:none && xmodmap ~/.Xmodmap" |
Skyler Grey | 34021e3 | 2022-11-04 09:28:03 +0000 | [diff] [blame] | 63 | |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 64 | shift = shiftMask |
| 65 | |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 66 | -- spell-checker:words xobsock |
| 67 | xobsock = "$XDG_RUNTIME_DIR/xob.sock" |
| 68 | |
Skyler Grey | 7030149 | 2023-02-24 09:04:51 +0000 | [diff] [blame] | 69 | workspaces = ["7", "5", "3", "1", "9", "0", "2", "4", "6", "8"]; |
| 70 | |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 71 | data NonFloats = NonFloats deriving (Read, Show) |
| 72 | |
| 73 | instance SetsAmbiguous NonFloats where |
| 74 | hiddens _ wset _ _ _ = allWindows wset \\ M.keys (W.floating wset) |
| 75 | |
Skyler Grey | 34021e3 | 2022-11-04 09:28:03 +0000 | [diff] [blame] | 76 | startupHook = do |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 77 | spawn Main.statusBar |
| 78 | spawn Main.compositor |
| 79 | spawn background |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 80 | spawn keybindings |
Skyler Grey | a23445b | 2023-02-25 07:01:35 +0000 | [diff] [blame] | 81 | windows $ W.view "0" |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 82 | spawn "pgrep keepass || run_keepass" |
| 83 | spawn $ "pkill xob; rm -f " ++ xobsock ++ " && mkfifo " ++ xobsock ++ " && tail -f " ++ xobsock ++ " | xob" |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 84 | |
Skyler Grey | 7030149 | 2023-02-24 09:04:51 +0000 | [diff] [blame] | 85 | numRowKeys = [xK_bracketleft |
| 86 | , xK_braceleft |
| 87 | , xK_braceright |
| 88 | , xK_parenleft |
| 89 | , xK_equal |
| 90 | , xK_asterisk |
| 91 | , xK_parenright |
| 92 | , xK_plus |
| 93 | , xK_bracketright |
| 94 | , xK_exclam |
| 95 | ] |
Skyler Grey | 34021e3 | 2022-11-04 09:28:03 +0000 | [diff] [blame] | 96 | |
Skyler Grey | b43ac6b | 2022-10-31 00:48:34 +0000 | [diff] [blame] | 97 | main :: IO () |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 98 | main = XMonadLog.xmonadLog >>= main' |
| 99 | |
| 100 | main' :: D.Client -> IO () |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 101 | main' dbus = xmonad |
| 102 | $ javaHack |
| 103 | $ ewmh . setEwmhActivateHook doAskUrgent |
| 104 | $ docks |
| 105 | $ def |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 106 | { modMask = modifierKey -- Use Super as our mod key |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 107 | , borderWidth = 2 |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 108 | , XMonad.terminal = Main.terminal |
Skyler Grey | 7030149 | 2023-02-24 09:04:51 +0000 | [diff] [blame] | 109 | , XMonad.workspaces = Main.workspaces |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 110 | , XMonad.startupHook = Main.startupHook |
| 111 | , XMonad.logHook = dynamicLogWithPP (polybarHook dbus) |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 112 | , XMonad.layoutHook = lessBorders NonFloats |
| 113 | $ (smartSpacing 5 |
| 114 | |
| 115 | $ avoidStruts |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 116 | $ gaps [(U, 5), (D, 5), (L, 5), (R, 5)] |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 117 | $ ResizableTall 1 (3/100) (1/2) [] |
| 118 | ||| Mirror (ResizableTall 1 (3/100) (1/2) []) |
| 119 | ||| Grid |
| 120 | ||| Full) |
| 121 | ||| gaps [(U, 0), (D, 0), (L, 0), (R, 0)] Full |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 122 | , XMonad.manageHook = composeAll |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 123 | [ isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP" |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 124 | --> hasBorder False <+> doIgnore <+> doLower <+> doLower |
| 125 | , checkDock --> doLower <+> doLower |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 126 | ] <+> manageHook def |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 127 | , XMonad.handleEventHook = composeAll |
| 128 | [ windowedFullscreenFixEventHook |
| 129 | , dynamicPropertyChange "_NET_WM_WINDOW_TYPE" |
| 130 | (isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP" |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 131 | --> hasBorder False <+> doLower |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 132 | <+> (ask >>= \w -> liftX (modifyWindowSet (W.delete w)) |
| 133 | >> mempty) |
| 134 | <+> (ask >>= \w -> liftX (withDisplay $ \dpy -> io (moveResizeWindow dpy w 0 0 (fromIntegral $ displayWidth dpy $ defaultScreen dpy) (fromIntegral $ displayHeight dpy $ defaultScreen dpy))) >> mempty)) |
| 135 | ] |
| 136 | <+> handleEventHook def |
Skyler Grey | 7030149 | 2023-02-24 09:04:51 +0000 | [diff] [blame] | 137 | } `additionalKeys` ( |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 138 | [ ((modifierKey, xK_d), spawn launcher) |
| 139 | , ((modifierKey, xK_n), spawn networkManager) |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 140 | , ((modifierKey .|. Main.shift, xK_q), kill) |
Skyler Grey | 37e2a40 | 2023-02-25 10:11:07 +0000 | [diff] [blame^] | 141 | , ((modifierKey, xK_o), sendMessage MirrorShrink) |
| 142 | , ((modifierKey, xK_e), sendMessage MirrorExpand) |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 143 | , ((modifierKey, xK_q), spawn "xmonad --restart") |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 144 | , ((modifierKey .|. Main.shift, xK_c), io exitSuccess) |
| 145 | , ((modifierKey .|. Main.shift, xK_s), spawn selectScreenshot) |
Skyler Grey | 9db914a | 2023-02-19 23:50:59 +0000 | [diff] [blame] | 146 | , ((modifierKey .|. Main.shift, xK_h), spawn colorSelection) |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 147 | , ((0, xK_Print), spawn screenshot) |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 148 | , ((modifierKey .|. Main.shift, xK_Return), spawn Main.terminal) |
| 149 | , ((0, xF86XK_AudioLowerVolume), spawn $ volumeChangeCmd ++ " -d") |
| 150 | , ((0, xF86XK_AudioRaiseVolume), spawn $ volumeChangeCmd ++ " -u") |
| 151 | , ((0, xF86XK_AudioMute), spawn $ volumeChangeCmd ++ " -m") |
| 152 | , ((modifierKey, xF86XK_AudioLowerVolume), spawn $ volumeChangeCmd ++ " -d -i") |
| 153 | , ((modifierKey, xF86XK_AudioRaiseVolume), spawn $ volumeChangeCmd ++ " -u -i") |
| 154 | , ((modifierKey, xF86XK_AudioMute), spawn $ volumeChangeCmd ++ " -m -i") |
| 155 | , ((0, xF86XK_MonBrightnessDown), spawn $ "light -U 6 && light -G | cut -d'.' -f1 > " ++ xobsock) |
| 156 | , ((0, xF86XK_MonBrightnessUp), spawn $ "light -A 6 && light -G | cut -d'.' -f1 > " ++ xobsock) |
| 157 | , ((modifierKey, xF86XK_MonBrightnessDown), spawn $ "light -U 3 && light -G | cut -d'.' -f1 > " ++ xobsock) |
| 158 | , ((modifierKey, xF86XK_MonBrightnessUp), spawn $ "light -A 3 && light -G | cut -d'.' -f1 > " ++ xobsock) |
Skyler Grey | 7030149 | 2023-02-24 09:04:51 +0000 | [diff] [blame] | 159 | ] ++ (zip numRowKeys Main.workspaces >>= (\(key, workspace) -> [((modifierKey, key), windows $ W.view workspace) |
| 160 | , ((modifierKey .|. Main.shift, key), windows $ W.shift workspace) |
| 161 | ]))) |