2023-03-07 21:48:12 +00:00
|
|
|
@document.meta
|
|
|
|
title: Xmonad Config
|
|
|
|
authors: Afonso Franco
|
|
|
|
categories: configs
|
2023-03-08 15:57:02 +00:00
|
|
|
tangle: /home/afonso/.config/xmonad/xmonad.hs
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
* Overrides
|
|
|
|
@code haskell
|
2023-01-29 02:19:56 +00:00
|
|
|
{-# OPTIONS_GHC -Wno-deprecations #-}
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
|
|
|
* Imports
|
|
|
|
@code haskell
|
2023-01-29 02:19:56 +00:00
|
|
|
|
|
|
|
import XMonad
|
2023-02-22 13:18:03 +00:00
|
|
|
|
|
|
|
--Utils
|
2023-01-29 02:19:56 +00:00
|
|
|
import XMonad.Util.EZConfig (additionalKeysP,removeKeysP)
|
|
|
|
import XMonad.Util.Loggers (logLayoutOnScreen, logTitleOnScreen, shortenL, wrapL, xmobarColorL)
|
2023-02-22 13:18:03 +00:00
|
|
|
import XMonad.Util.Run
|
|
|
|
import XMonad.Util.SpawnOnce
|
|
|
|
|
|
|
|
--Hooks
|
|
|
|
import XMonad.Hooks.DynamicLog
|
2023-01-29 02:19:56 +00:00
|
|
|
import XMonad.Hooks.SetWMName
|
|
|
|
import XMonad.Hooks.StatusBar
|
|
|
|
import XMonad.Hooks.EwmhDesktops
|
|
|
|
import XMonad.Hooks.ManageDocks
|
|
|
|
import XMonad.Hooks.ManageHelpers
|
|
|
|
import XMonad.Hooks.WindowSwallowing
|
2023-02-22 13:18:03 +00:00
|
|
|
|
|
|
|
--Actions
|
|
|
|
import XMonad.Actions.SpawnOn
|
|
|
|
import XMonad.Actions.UpdateFocus (focusUnderPointer)
|
|
|
|
|
|
|
|
--Layouts
|
|
|
|
import XMonad.Layout.NoBorders
|
|
|
|
import XMonad.Layout.Spacing
|
|
|
|
|
2023-02-25 20:37:02 +00:00
|
|
|
|
|
|
|
-- MultiMonitorFocusHook
|
|
|
|
import Control.Monad (when)
|
|
|
|
import Data.Foldable (find)
|
|
|
|
import Foreign.C (CInt)
|
|
|
|
import Data.Maybe (fromMaybe)
|
|
|
|
import Data.Monoid (All (All))
|
|
|
|
|
2023-02-22 13:18:03 +00:00
|
|
|
--Miscellaneous
|
2023-01-29 02:19:56 +00:00
|
|
|
import qualified XMonad.StackSet as W
|
|
|
|
import qualified Data.Map as M
|
2023-02-22 13:18:03 +00:00
|
|
|
import System.Exit
|
|
|
|
|
|
|
|
--Color Scheme
|
|
|
|
import Colors.Teal
|
2023-01-29 02:19:56 +00:00
|
|
|
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
|
|
|
* Variables
|
|
|
|
@code haskell
|
|
|
|
|
2023-05-24 12:56:51 +01:00
|
|
|
myTerminal = "kitty"
|
2023-05-20 21:52:46 +01:00
|
|
|
myTerminalTmux = myTerminal ++ " -e tmux a"
|
2023-01-29 02:19:56 +00:00
|
|
|
myTextEditor = "nvim"
|
|
|
|
myWebBrowser = "firefox"
|
2023-02-22 13:18:03 +00:00
|
|
|
myModMask = mod4Mask
|
2023-01-29 02:19:56 +00:00
|
|
|
|
|
|
|
myFocusFollowsMouse :: Bool
|
|
|
|
myFocusFollowsMouse = True
|
|
|
|
|
|
|
|
myClickJustFocuses :: Bool
|
|
|
|
myClickJustFocuses = False
|
|
|
|
|
|
|
|
windowCount :: X (Maybe String)
|
|
|
|
windowCount = gets $ Just . show . length . W.integrate' . W.stack . W.workspace . W.current . windowset
|
|
|
|
|
|
|
|
myNormalBorderColor = "#008080"
|
|
|
|
myFocusedBorderColor = "#01F9C6"
|
|
|
|
|
|
|
|
myBorderWidth = 2
|
|
|
|
|
2023-05-16 01:45:30 +01:00
|
|
|
myWorkspaces = ["main","web","text","code","social","monitoring"]
|
2023-02-22 13:18:03 +00:00
|
|
|
myWorkspaceIndices = zip myWorkspaces [1..]
|
2023-01-29 02:19:56 +00:00
|
|
|
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
2023-01-29 02:19:56 +00:00
|
|
|
|
2023-03-07 21:48:12 +00:00
|
|
|
* Keybinds
|
|
|
|
@code haskell
|
2023-01-29 02:19:56 +00:00
|
|
|
myKeys :: [(String, X ())]
|
|
|
|
myKeys =
|
2023-05-20 21:52:46 +01:00
|
|
|
[ ("M-x" ,spawn myTerminalTmux )
|
2023-03-08 11:52:40 +00:00
|
|
|
, ("M-p", spawn "rofi -show drun -show-icons")
|
2023-03-08 15:57:02 +00:00
|
|
|
, ("M-S-p", spawn "rofi -show p -modi p:rofi-power-menu")
|
2023-01-29 02:19:56 +00:00
|
|
|
, ("M-s", spawn "selected=$(ls ~/scripts/|rofi -dmenu -p \"Run: \") && bash ~/.config/rofi/scripts/$selected")
|
|
|
|
, ("M-b", spawn myWebBrowser)
|
2023-02-22 13:18:03 +00:00
|
|
|
, ("<Print>", spawn "flameshot gui")
|
2023-01-29 02:19:56 +00:00
|
|
|
, ("<XF86AudioMute>", spawn "pamixer set --toggle-mute")
|
|
|
|
, ("<XF86AudioLowerVolume>", spawn "pamixer -d 5")
|
|
|
|
, ("<XF86AudioRaiseVolume>", spawn "pamixer -i 5")
|
2023-02-22 13:18:03 +00:00
|
|
|
, ("<XF86MonBrightnessUp>", spawn "lux -a 10%")
|
|
|
|
, ("<XF86MonBrightnessDown>", spawn "lux -s 10%")
|
|
|
|
, ("M-n", spawn $ myTerminal ++ " -e nmtui")
|
2023-02-13 03:02:55 +00:00
|
|
|
, ("M-q", kill)
|
2023-01-29 02:19:56 +00:00
|
|
|
, ("M-S-<Space>", sendMessage NextLayout)
|
|
|
|
, ("M-<Down>", windows W.focusDown)
|
|
|
|
, ("M-<Up>", windows W.focusUp )
|
|
|
|
, ("M-m", windows W.focusMaster )
|
|
|
|
, ("M-<Return>", windows W.swapMaster)
|
|
|
|
, ("M-h", sendMessage Shrink)
|
|
|
|
, ("M-l", sendMessage Expand)
|
|
|
|
, ("M-t", withFocused $ windows . W.sink)
|
|
|
|
, ("M-S-u", io (exitWith ExitSuccess))
|
|
|
|
, ("M-u", spawn "xmonad --recompile; xmonad --restart")
|
|
|
|
]
|
|
|
|
++
|
|
|
|
[("M-" ++ m ++ (show k), windows $ f i)
|
2023-02-22 13:18:03 +00:00
|
|
|
| (i, k) <- myWorkspaceIndices
|
2023-01-29 02:19:56 +00:00
|
|
|
, (f, m) <- [(W.greedyView, "0"), (W.shift, "S-")]]
|
|
|
|
++
|
|
|
|
[("M-" ++ m ++ key, screenWorkspace sc >>= flip whenJust (windows . f))
|
|
|
|
| (key, sc) <- zip ["w", "e", "r"] [0..]
|
|
|
|
, (f, m) <- [(W.view, "0"), (W.shift, "S-")]]
|
|
|
|
|
|
|
|
myRemoveKeys = ["M-S-<Return>","M-S-p","M-S-c","M-<Space>","M-n","M-S-q"]
|
2023-02-22 13:18:03 +00:00
|
|
|
|
2023-01-29 02:19:56 +00:00
|
|
|
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
|
|
|
|
[ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
|
|
|
|
>> windows W.shiftMaster))
|
|
|
|
, ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
|
|
|
|
, ((modm, button3), (\w -> focus w >> mouseResizeWindow w
|
|
|
|
>> windows W.shiftMaster))]
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
|
|
|
* Layouts
|
|
|
|
@code haskell
|
2023-01-29 02:19:56 +00:00
|
|
|
myLayout = avoidStruts(tiled ||| Mirror tiled ||| Full)
|
|
|
|
where
|
|
|
|
tiled = Tall nmaster delta ratio
|
|
|
|
nmaster = 1
|
|
|
|
ratio = 1/2
|
|
|
|
delta = 3/100
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
|
|
|
* Hooks
|
|
|
|
@code haskell
|
2023-01-29 02:19:56 +00:00
|
|
|
myManageHook = composeAll
|
|
|
|
[ className =? "MPlayer" --> doFloat
|
|
|
|
, className =? "Gimp" --> doFloat
|
|
|
|
, resource =? "desktop_window" --> doIgnore
|
|
|
|
, className =? "QjackCtl" --> doFloat
|
|
|
|
, resource =? "kdesktop" --> doIgnore
|
|
|
|
, className =? "firefox" --> doShift (myWorkspaces !! 1)
|
|
|
|
, className =? "Code" --> doShift (myWorkspaces !! 3)
|
|
|
|
, className =? "discord" --> doShift (myWorkspaces !! 4)
|
|
|
|
, title =? "JetBrains Toolbox" --> doShift (myWorkspaces !! 3)
|
|
|
|
, className =? "main" --> doFloat
|
|
|
|
, className =? "Mailspring" --> doShift (myWorkspaces !! 5)
|
|
|
|
, className =? "Xmessage" --> doFloat
|
|
|
|
, title =? "Steam - News" --> doFloat
|
|
|
|
, title =? "Friends List" --> doFloat
|
|
|
|
, isFullscreen --> doFullFloat]
|
|
|
|
|
2023-03-07 21:48:12 +00:00
|
|
|
|
2023-01-29 02:19:56 +00:00
|
|
|
myEventHook = ewmhDesktopsEventHook
|
2023-02-25 20:37:02 +00:00
|
|
|
|
2023-01-29 02:19:56 +00:00
|
|
|
myStartupHook = do
|
2023-05-20 21:52:46 +01:00
|
|
|
spawnOnce "pasystray"
|
|
|
|
spawnOnce "nitrogen --restore &"
|
|
|
|
spawnOnce "playerctld"
|
|
|
|
spawnOnce "picom &"
|
|
|
|
spawnOnce "optimus-manager-qt"
|
|
|
|
setWMName "LG3D"
|
|
|
|
spawnOnce "nm-applet"
|
|
|
|
spawnOnce "mailspring"
|
|
|
|
spawnOnce("xsetroot -cursor_name left_ptr")
|
|
|
|
spawn ("killall trayer ;sleep 1 && trayer --monitor 0 --edge top --align right --widthtype request --padding 7 --iconspacing 12 --SetDockType true --SetPartialStrut true --expand true --transparent true --alpha 0 --tint 0x2B2E37 --height 26 --distance 5 &")
|
|
|
|
spawnOn "web" myWebBrowser
|
|
|
|
spawnOn "main" myTerminalTmux
|
2023-05-24 12:56:51 +01:00
|
|
|
spawnOn "monitoring" (myTerminal ++ " -e btop")
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
|
|
|
* XMobar Config
|
|
|
|
@code haskell
|
2023-01-29 02:19:56 +00:00
|
|
|
|
|
|
|
myStatusBarSpawner :: Applicative f => ScreenId -> f StatusBarConfig
|
|
|
|
myStatusBarSpawner (S s) = do
|
|
|
|
pure $ statusBarPropTo ("_XMONAD_LOG_" ++ show s)
|
|
|
|
("xmobar -x " ++ show s ++ " ~/.config/xmobar/xmobarrc" ++ show s)
|
|
|
|
(pure $ myXmobarPP (S s))
|
|
|
|
|
|
|
|
|
|
|
|
myXmobarPP :: ScreenId -> PP
|
|
|
|
myXmobarPP s = def
|
|
|
|
{ ppSep = ""
|
|
|
|
, ppWsSep = ""
|
|
|
|
, ppCurrent = xmobarColor cyan "" . const wsIconFull
|
|
|
|
, ppVisible = xmobarColor grey4 "" . const wsIconFull
|
|
|
|
, ppVisibleNoWindows = Just (xmobarColor grey4 "" . const wsIconFull)
|
|
|
|
, ppHidden = xmobarColor grey2 "" . const wsIconHidden
|
|
|
|
, ppHiddenNoWindows = xmobarColor grey2 "" . const wsIconEmpty
|
|
|
|
, ppUrgent = xmobarColor orange "" . const wsIconFull
|
|
|
|
, ppOrder = \(ws : _ : _ : extras) -> ws : extras
|
|
|
|
, ppExtras = [ wrapL " " " " $ layoutColorIsActive s (logLayoutOnScreen s)
|
|
|
|
,titleColorIsActive s (shortenL 81 $ logTitleOnScreen s)
|
|
|
|
]
|
|
|
|
}
|
|
|
|
where
|
|
|
|
wsIconFull = " <fn=2>\xf111</fn> "
|
|
|
|
wsIconHidden = " <fn=2>\xf111</fn> "
|
|
|
|
wsIconEmpty = " <fn=2>\xf10c</fn> "
|
|
|
|
titleColorIsActive n l = do
|
|
|
|
c <- withWindowSet $ return . W.screen . W.current
|
|
|
|
if n == c then xmobarColorL cyan "" l else xmobarColorL grey3 "" l
|
|
|
|
layoutColorIsActive n l = do
|
|
|
|
c <- withWindowSet $ return . W.screen . W.current
|
|
|
|
if n == c then wrapL "<icon=/home/afonso/.config/xmobar/xpm/" "_selected.xpm/>" l else wrapL "<icon=/home/afonso/.config/xmobar/xpm/" ".xpm/>" l
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
|
|
|
* Config Variables binding
|
|
|
|
@code haskell
|
2023-01-29 02:19:56 +00:00
|
|
|
|
|
|
|
myConfig = def
|
|
|
|
{
|
|
|
|
terminal = myTerminal,
|
|
|
|
focusFollowsMouse = myFocusFollowsMouse,
|
|
|
|
clickJustFocuses = myClickJustFocuses,
|
|
|
|
borderWidth = myBorderWidth,
|
|
|
|
modMask = myModMask,
|
|
|
|
workspaces = myWorkspaces,
|
|
|
|
normalBorderColor = myNormalBorderColor,
|
|
|
|
focusedBorderColor = myFocusedBorderColor,
|
|
|
|
-- keys = myKeys,
|
2023-02-13 03:02:55 +00:00
|
|
|
layoutHook = smartBorders . spacingWithEdge 10 $ myLayout,
|
2023-01-29 02:19:56 +00:00
|
|
|
manageHook = manageSpawn <+> myManageHook <+> manageHook def,
|
2023-02-25 20:56:50 +00:00
|
|
|
handleEventHook = myEventHook <+> fullscreenEventHook <+> swallowEventHook (className=?"Alacritty") (return True),
|
2023-02-22 13:18:03 +00:00
|
|
|
startupHook = myStartupHook
|
|
|
|
}
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|
|
|
|
* Main
|
|
|
|
@code haskell
|
2023-01-29 02:19:56 +00:00
|
|
|
|
|
|
|
main :: IO ()
|
2023-02-22 13:18:03 +00:00
|
|
|
main = xmonad . ewmh . ewmhFullscreen . dynamicSBs myStatusBarSpawner . docks $ additionalKeysP (removeKeysP myConfig myRemoveKeys) myKeys
|
2023-03-07 21:48:12 +00:00
|
|
|
@end
|