Skyler Grey | b43ac6b | 2022-10-31 00:48:34 +0000 | [diff] [blame] | 1 | -- spell-checker:words xmonad |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 2 | {-# OPTIONS_GHC -Wno-deferred-out-of-scope-variables #-} |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 3 | import XMonad |
Skyler Grey | b43ac6b | 2022-10-31 00:48:34 +0000 | [diff] [blame] | 4 | |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 5 | import System.Exit |
| 6 | import XMonad.Util.EZConfig |
Skyler Grey | b43ac6b | 2022-10-31 00:48:34 +0000 | [diff] [blame] | 7 | |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 8 | import XMonad.Config.Desktop |
| 9 | import XMonad.Hooks.EwmhDesktops |
| 10 | import XMonad.Hooks.ManageDocks |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 11 | |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 12 | import qualified DBus.Client as D |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 13 | import XMonad.Hooks.DynamicLog |
| 14 | import XMonadLog |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 15 | |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 16 | import Blaze.ByteString.Builder (toByteString) |
| 17 | import Foreign.C |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 18 | import Graphics.X11.ExtraTypes (xF86XK_AudioLowerVolume, |
| 19 | xF86XK_AudioMute, |
| 20 | xF86XK_AudioRaiseVolume, |
| 21 | xF86XK_MonBrightnessDown, |
| 22 | xF86XK_MonBrightnessUp, |
| 23 | xF86XK_Xfer) |
| 24 | import qualified XMonad as W |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 25 | import XMonad.Hooks.DynamicProperty (dynamicPropertyChange) |
| 26 | import XMonad.Hooks.ManageHelpers (doFullFloat, doLower, |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 27 | doRectFloat, isInProperty) |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 28 | import XMonad.Hooks.UrgencyHook |
| 29 | import XMonad.Layout.Drawer (propertyToQuery) |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 30 | import XMonad.Layout.Gaps |
| 31 | import XMonad.Layout.Spacing |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 32 | import qualified XMonad.StackSet as W |
| 33 | import XMonad.Util.Hacks |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 34 | import XMonad.Util.PureX (curScreen, curScreenId) |
| 35 | import XMonad.Util.Run (safeSpawn, safeSpawnProg) |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 36 | |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 37 | volumeChangeCmd = "${{./vol_change.py}}" |
| 38 | |
| 39 | terminal = "/usr/bin/env SHLVL=0 kitty" -- Kitty, my beloved <3 |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 40 | launcher = "pkill rofi; rofi -show combi" |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 41 | networkManager = "wpa_cli select_network $(wpa_cli list_networks | tail -n +3 | awk '!seen[$2]++' | rofi -dmenu -window-title 'Select Network' | awk '{print $1;}')" |
| 42 | |
| 43 | screenshot = "mkdir -p ~/Screenshots && maim | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | xclip -select clipboard -t image/png" |
| 44 | selectScreenshot = "mkdir -p ~/Screenshots && maim -s | tee ~/Screenshots/\"$(date --rfc-3339=seconds)\".png | xclip -select clipboard -t image/png" |
| 45 | |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 46 | modifierKey = mod4Mask -- Use Super as our mod key |
| 47 | |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 48 | 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] | 49 | compositor = "pkill picom; picom" |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 50 | background = "pkill show; show ~/.xmonad/wallpaper.glsl > /dev/null" |
Skyler Grey | 9db914a | 2023-02-19 23:50:59 +0000 | [diff] [blame] | 51 | colorSelection = "xcolor | xclip -sel clip" |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 52 | keybindings = "setxkbmap -option caps:none && xmodmap ~/.Xmodmap" |
Skyler Grey | 34021e3 | 2022-11-04 09:28:03 +0000 | [diff] [blame] | 53 | |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 54 | shift = shiftMask |
| 55 | |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 56 | -- spell-checker:words xobsock |
| 57 | xobsock = "$XDG_RUNTIME_DIR/xob.sock" |
| 58 | |
Skyler Grey | 34021e3 | 2022-11-04 09:28:03 +0000 | [diff] [blame] | 59 | startupHook = do |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 60 | spawn Main.statusBar |
| 61 | spawn Main.compositor |
| 62 | spawn background |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 63 | spawn keybindings |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 64 | spawn "pgrep keepass || run_keepass" |
| 65 | spawn $ "pkill xob; rm -f " ++ xobsock ++ " && mkfifo " ++ xobsock ++ " && tail -f " ++ xobsock ++ " | xob" |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 66 | |
Skyler Grey | 34021e3 | 2022-11-04 09:28:03 +0000 | [diff] [blame] | 67 | |
Skyler Grey | b43ac6b | 2022-10-31 00:48:34 +0000 | [diff] [blame] | 68 | main :: IO () |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 69 | main = XMonadLog.xmonadLog >>= main' |
| 70 | |
| 71 | main' :: D.Client -> IO () |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 72 | main' dbus = xmonad |
| 73 | $ javaHack |
| 74 | $ ewmh . setEwmhActivateHook doAskUrgent |
| 75 | $ docks |
| 76 | $ def |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 77 | { modMask = modifierKey -- Use Super as our mod key |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 78 | , borderWidth = 0 |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 79 | , XMonad.terminal = Main.terminal |
Skyler Grey | 51a0c61 | 2022-11-05 09:59:04 +0000 | [diff] [blame] | 80 | , XMonad.startupHook = Main.startupHook |
| 81 | , XMonad.logHook = dynamicLogWithPP (polybarHook dbus) |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 82 | , XMonad.layoutHook = avoidStruts |
| 83 | $ smartSpacing 5 |
| 84 | $ gaps [(U, 5), (D, 5), (L, 5), (R, 5)] |
| 85 | $ layoutHook def |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 86 | , XMonad.manageHook = composeAll |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 87 | [ isInProperty "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DESKTOP" |
| 88 | --> doIgnore <+> doLower <+> doLower |
Skyler Grey | f2c55ae | 2022-11-05 17:48:02 +0000 | [diff] [blame] | 89 | ] <+> manageHook def |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 90 | , 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 Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 100 | } `additionalKeys` |
| 101 | [ ((modifierKey, xK_d), spawn launcher) |
| 102 | , ((modifierKey, xK_n), spawn networkManager) |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 103 | , ((modifierKey .|. Main.shift, xK_q), kill) |
Skyler Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 104 | , ((modifierKey, xK_q), spawn "xmonad --restart") |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 105 | , ((modifierKey .|. Main.shift, xK_c), io exitSuccess) |
| 106 | , ((modifierKey .|. Main.shift, xK_s), spawn selectScreenshot) |
Skyler Grey | 9db914a | 2023-02-19 23:50:59 +0000 | [diff] [blame] | 107 | , ((modifierKey .|. Main.shift, xK_h), spawn colorSelection) |
Skyler Grey | 0808276 | 2023-01-26 00:35:19 +0000 | [diff] [blame] | 108 | , ((0, xK_Print), spawn screenshot) |
Skyler Grey | 3a9a2b1 | 2023-02-13 08:04:05 +0000 | [diff] [blame] | 109 | , ((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 Grey | e2ec0de | 2022-11-02 08:07:25 +0000 | [diff] [blame] | 120 | ] |