aboutsummaryrefslogtreecommitdiff
path: root/config/xmonad
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-02-24 17:07:33 +0100
committerCharles Cabergs <me@cacharle.xyz>2021-02-24 17:07:33 +0100
commit468a789dbc4b1928c035d8590895efc533520a27 (patch)
tree74cb056c37eaa50cd50491a7665608488ed4feb1 /config/xmonad
parentf9883d2c3b3699d91e98feeffd7eece546f7c57e (diff)
downloaddotfiles-468a789dbc4b1928c035d8590895efc533520a27.tar.gz
dotfiles-468a789dbc4b1928c035d8590895efc533520a27.tar.bz2
dotfiles-468a789dbc4b1928c035d8590895efc533520a27.zip
Updated file tree to match XDG base directory specification
Diffstat (limited to 'config/xmonad')
-rw-r--r--config/xmonad/xmonad.hs76
1 files changed, 76 insertions, 0 deletions
diff --git a/config/xmonad/xmonad.hs b/config/xmonad/xmonad.hs
new file mode 100644
index 0000000..b61bcea
--- /dev/null
+++ b/config/xmonad/xmonad.hs
@@ -0,0 +1,76 @@
+import Control.Monad
+import Data.List
+import System.Exit
+
+
+import XMonad
+import XMonad.Config.Desktop
+
+-- Utilities
+import XMonad.Util.EZConfig (additionalKeysP, additionalKeys)
+import XMonad.Util.SpawnOnce
+import XMonad.Util.Dmenu
+
+-- Layouts
+import XMonad.Layout.NoBorders
+import XMonad.Layout.Spacing
+import XMonad.Layout.Grid
+
+-- Hooks
+import XMonad.Hooks.InsertPosition
+
+-- xmonad :: XConfig -> IO ()
+-- https://hackage.haskell.org/package/xmonad-0.15/docs/XMonad-Core.html#t:XConfig
+main = xmonad $ desktopConfig
+ { normalBorderColor = "#1c1c1c"
+ , focusedBorderColor = "#8a8a8a"
+ , terminal = "st"
+ , layoutHook = myLayouts
+ , manageHook = myManageHook
+ , modMask = mod4Mask -- mod key to super
+ , borderWidth = 2
+ , focusFollowsMouse = False -- don't change window based on mouse position (need to click)
+ , workspaces = ["code", "compile", "web"] ++ map show [4..9]
+ } `additionalKeysP` myKeys
+
+
+myLayouts = mySpacing 4 $ tiledVerticalBigMaster -- bigger master for code and smaller slave for compiling
+ ||| Mirror tiledHorizontalEven -- 50/50 horizontal split
+ ||| noBorders Full -- disable borders for fullscreen layout
+ ||| Grid
+ where tiledVerticalBigMaster = Tall 1 (3 / 100) (3 / 5)
+ tiledHorizontalEven = Tall 1 (3 / 100) (1 / 2)
+ mySpacing x = spacingRaw True (Border x x x x) False (Border x x x x) True
+
+myManageHook = insertPosition End Newer -- insert new window at the end of the current layout
+
+myKeys = [ ("<XF86AudioLowerVolume>", spawn "pulseaudio-ctl down")
+ , ("<XF86AudioRaiseVolume>", spawn "pulseaudio-ctl up")
+ , ("<XF86AudioMute>", spawn "pulseaudio-ctl mute")
+ , ("M-<F11>", spawn "pulseaudio-ctl down")
+ , ("M-<F12>", spawn "pulseaudio-ctl up")
+
+ , ("<XF86MonBrightnessUp>", spawn "~/bin/backlight-ctl up")
+ , ("<XF86MonBrightnessDown>", spawn "~/bin/backlight-ctl down")
+ , ("<XF86ScreenSaver>", spawn "slock")
+ , ("<XF86TouchpadToggle>", spawn "~/bin/touchpad-toggle")
+
+ , ("M-o", spawn "~/bin/project-open")
+ , ("M-m", spawn "st -e mocp")
+ , ("M-S-d", spawn "notify-send -i x-office-calendar \"$(date +\"%H:%M %A %d/%m/%Y %B\")\"")
+ , ("M-S-b", spawn "notify-send \"battery: $(cat /sys/class/power_supply/BAT0/capacity)\"")
+ , ("M-q", spawn "notify-send 'Restarting xmonad'" >> spawn restartCmd)
+ , ("M-S-q", confirm "Are you sure you want to shutdown?" $ io (exitWith ExitSuccess))
+ ]
+
+confirm :: String -> X () -> X ()
+confirm prompt f = do
+ result <- menuArgs "dmenu" ["-p", prompt] ["yes", "no"]
+ when (result == "yes") f
+
+restartCmd :: String
+restartCmd = intercalate "; " [ "if type xmonad"
+ , "then xmonad --recompile && xmonad --restart"
+ , "else xmessage xmonad not in \\$PATH: \"$PATH\""
+ , "fi"
+ ]