gdritter repos dotfiles / 7413882
ormolu Getty Ritter 3 years ago
1 changed file(s) with 84 addition(s) and 74 deletion(s). Collapse all Expand all
1 {-# LANGUAGE ExistentialQuantification #-}
2 {-# LANGUAGE FlexibleContexts #-}
13 {-# LANGUAGE RankNTypes #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE ExistentialQuantification #-}
44 {-# LANGUAGE RecordWildCards #-}
55
6 import Control.Monad (when, void)
7 import Data.Default (def)
6 import Control.Monad (void, when)
7 import Data.Default (def)
88 import qualified Data.Map as M
9 import qualified Graphics.X11.ExtraTypes.XF86 as X11
910 import qualified System.Directory as Sys
1011 import qualified System.Environment as Sys
1112 import qualified System.Exit as Sys
1213 import qualified System.IO as Sys
1314 import qualified System.Process as Sys
14 import qualified Graphics.X11.ExtraTypes.XF86 as X11
15
16 import XMonad ((|||), (<+>))
15 import XMonad ((<+>), (|||))
1716 import qualified XMonad as XM
1817 import qualified XMonad.Hooks.DynamicLog as Log
1918 import qualified XMonad.Hooks.ManageDocks as XM
2625 -- | A 'ColorScheme' represents a handful of salient colors used in
2726 -- the configuration.
2827 data ColorScheme = ColorScheme
29 { normalC :: String
30 , focusedC :: String
31 , blackC :: String
32 , grayC :: String
33 , whiteC :: String
34 } deriving (Eq, Show, Read)
28 { normalC :: String,
29 focusedC :: String,
30 blackC :: String,
31 grayC :: String,
32 whiteC :: String
33 }
34 deriving (Eq, Show, Read)
3535
3636 -- | Here's a reasonable default color scheme with some blues!
3737 blueScheme :: ColorScheme
38 blueScheme = ColorScheme
39 { normalC = "#336699"
40 , focusedC = "#9ebedf"
41 , blackC = "#ffffff"
42 , grayC = "#999999"
43 , whiteC = "#000000"
44 }
38 blueScheme =
39 ColorScheme
40 { normalC = "#336699",
41 focusedC = "#9ebedf",
42 blackC = "#ffffff",
43 grayC = "#999999",
44 whiteC = "#000000"
45 }
4546
4647 keys :: XM.XConfig XM.Layout -> M.Map (XM.ButtonMask, XM.KeySym) (XM.X ())
47 keys (XM.XConfig {XM.modMask = mdMask}) = M.fromList
48 [ ((mdMask, XM.xK_p), XM.spawn "dmenu_run")
49 , ((mdMask, XM.xK_o), XM.spawn "dmesktop")
50 , ((mdMask, XM.xK_period), XM.spawn "ibus engine xkb:us::eng")
51 , ((mdMask, XM.xK_u), XM.spawn "amixer -q sset Master 3%+")
52 , ((mdMask, XM.xK_d), XM.spawn "amixer -q sset Master 3%-")
53 , ((mdMask, XM.xK_m), XM.spawn "amixer -q sset Master 0%")
54 , ((mdMask, XM.xK_c), xCopy)
55 , ((mdMask, XM.xK_v), Paste.pasteSelection)
56 , ((mdMask, 0x1008ff13), XM.spawn "amixer -q set Master 3%+")
57 , ((mdMask, 0x1008ff12), XM.spawn "amixer set Master toggle")
58 , ((mdMask, 0x1008ff11), XM.spawn "amixer -q set Master 3%-")
59 , ((mdMask, 0x1008ff14), XM.spawn "mpc toggle")
60 , ((mdMask, 0x1008ff15), XM.spawn "mpc stop")
61 , ((mdMask, 0x1008ff16), XM.spawn "mpc prev")
62 , ((mdMask, 0x1008ff17), XM.spawn "mpc next")
63 ]
48 keys (XM.XConfig {XM.modMask = mdMask}) =
49 M.fromList
50 [ ((mdMask, XM.xK_p), XM.spawn "dmenu_run"),
51 ((mdMask, XM.xK_o), XM.spawn "dmesktop"),
52 ((mdMask, XM.xK_period), XM.spawn "ibus engine xkb:us::eng"),
53 ((mdMask, XM.xK_u), XM.spawn "amixer -q sset Master 3%+"),
54 ((mdMask, XM.xK_d), XM.spawn "amixer -q sset Master 3%-"),
55 ((mdMask, XM.xK_m), XM.spawn "amixer -q sset Master 0%"),
56 ((mdMask, XM.xK_c), xCopy),
57 ((mdMask, XM.xK_v), Paste.pasteSelection),
58 ((mdMask, 0x1008ff13), XM.spawn "amixer -q set Master 3%+"),
59 ((mdMask, 0x1008ff12), XM.spawn "amixer set Master toggle"),
60 ((mdMask, 0x1008ff11), XM.spawn "amixer -q set Master 3%-"),
61 ((mdMask, 0x1008ff14), XM.spawn "mpc toggle"),
62 ((mdMask, 0x1008ff15), XM.spawn "mpc stop"),
63 ((mdMask, 0x1008ff16), XM.spawn "mpc prev"),
64 ((mdMask, 0x1008ff17), XM.spawn "mpc next")
65 ]
6466
6567 xCopy :: XM.X ()
6668 xCopy = XM.withFocused $ \w -> do
6971 then (Paste.sendKey XM.noModMask X11.xF86XK_Copy)
7072 else (Paste.sendKey XM.controlMask XM.xK_c)
7173
72
7374 recompile :: IO ()
7475 recompile = do
7576 putStrLn "recompiling with new-build"
76 let cmd = (Sys.proc "cabal" ["new-build"]) { Sys.cwd = Just "/home/gdritter/.xmonad" }
77 (code,stdout,stderr) <-
78 Sys.readCreateProcessWithExitCode cmd ""
77 let cmd = (Sys.proc "cabal" ["new-build"]) {Sys.cwd = Just "/home/gdritter/.xmonad"}
78 (code, stdout, stderr) <-
79 Sys.readCreateProcessWithExitCode cmd ""
7980 putStr stdout
8081 putStr stderr
8182 putStrLn "Done!"
8687 -- This just wraps an existential around the configuration so that
8788 -- we don't have to write it at the top-level!
8889 data XMConfig
89 = forall l. ( XM.LayoutClass l XM.Window
90 , Read (l XM.Window)
91 ) => XMConfig (XM.XConfig l)
90 = forall l.
91 ( XM.LayoutClass l XM.Window,
92 Read (l XM.Window)
93 ) =>
94 XMConfig (XM.XConfig l)
9295
9396 -- This builds a config after being given a handle to the xmobar process
9497 -- as well as a color scheme to use.
9598 config :: Sys.Handle -> ColorScheme -> XMConfig
96 config xmproc ColorScheme { .. } = XMConfig conf
97 where conf = def
98 { XM.modMask = XM.mod4Mask
99 , XM.terminal = "alacritty -e tmux"
100 , XM.keys = keys <+> XM.keys def
101 , XM.handleEventHook =
102 XM.docksEventHook <+> XM.handleEventHook def
103 , XM.startupHook =
104 XM.setWMName "LG3D" <+> XM.docksStartupHook <+> XM.startupHook def
105 , XM.layoutHook =
106 XM.avoidStruts tiled |||
107 XM.avoidStruts (XM.Mirror tiled) |||
108 XM.noBorders (XM.smartBorders XM.Full) |||
109 XM.avoidStruts tabbed
110 , XM.manageHook =
111 XM.manageDocks <+> XM.manageHook def
112 , XM.normalBorderColor = normalC
113 , XM.focusedBorderColor = focusedC
114 , XM.logHook = Log.dynamicLogWithPP $ def
115 { Log.ppOutput = Sys.hPutStrLn xmproc
116 }
99 config xmproc ColorScheme {..} = XMConfig conf
100 where
101 conf =
102 def
103 { XM.modMask = XM.mod4Mask,
104 XM.terminal = "alacritty -e tmux",
105 XM.keys = keys <+> XM.keys def,
106 XM.handleEventHook =
107 XM.docksEventHook <+> XM.handleEventHook def,
108 XM.startupHook =
109 XM.setWMName "LG3D" <+> XM.docksStartupHook <+> XM.startupHook def,
110 XM.layoutHook =
111 XM.avoidStruts tiled
112 ||| XM.avoidStruts (XM.Mirror tiled)
113 ||| XM.noBorders (XM.smartBorders XM.Full)
114 ||| XM.avoidStruts tabbed,
115 XM.manageHook =
116 XM.manageDocks <+> XM.manageHook def,
117 XM.normalBorderColor = normalC,
118 XM.focusedBorderColor = focusedC,
119 XM.logHook =
120 Log.dynamicLogWithPP $
121 def
122 { Log.ppOutput = Sys.hPutStrLn xmproc
123 }
124 }
125 tiled = XM.Tall 1 (3 / 100) (3 / 5)
126 tabbed =
127 Tab.tabbedAlways
128 Tab.shrinkText
129 def
130 { Tab.activeColor = focusedC,
131 Tab.inactiveColor = normalC,
132 Tab.activeBorderColor = blackC,
133 Tab.inactiveBorderColor = blackC,
134 Tab.activeTextColor = whiteC,
135 Tab.inactiveTextColor = whiteC
117136 }
118 tiled = XM.Tall 1 (3/100) (3/5)
119 tabbed = Tab.tabbedAlways Tab.shrinkText def
120 { Tab.activeColor = focusedC
121 , Tab.inactiveColor = normalC
122 , Tab.activeBorderColor = blackC
123 , Tab.inactiveBorderColor = blackC
124 , Tab.activeTextColor = whiteC
125 , Tab.inactiveTextColor = whiteC
126 }
127137
128138 main :: IO ()
129139 main = do