2023-06-02 22:12:39 +02:00
|
|
|
|
-- {{{
|
2022-12-01 16:21:19 +01:00
|
|
|
|
import XMonad
|
|
|
|
|
import XMonad.Hooks.DynamicLog
|
|
|
|
|
import XMonad.Hooks.EwmhDesktops
|
|
|
|
|
import XMonad.Hooks.ManageDocks
|
|
|
|
|
import XMonad.Hooks.ManageHelpers
|
|
|
|
|
import XMonad.Hooks.StatusBar
|
|
|
|
|
import XMonad.Hooks.StatusBar.PP
|
|
|
|
|
import XMonad.Layout.Magnifier
|
|
|
|
|
import qualified XMonad.Layout.Magnifier as Mag (MagnifyMsg (..))
|
|
|
|
|
import XMonad.Layout.NoBorders (hasBorder, smartBorders)
|
|
|
|
|
import XMonad.Layout.PerScreen
|
|
|
|
|
import XMonad.Layout.ResizableTile
|
|
|
|
|
import XMonad.Layout.Spacing
|
|
|
|
|
import XMonad.Layout.ThreeColumns
|
|
|
|
|
import XMonad.Layout.ToggleLayouts
|
|
|
|
|
( ToggleLayout (..),
|
|
|
|
|
toggleLayouts,
|
|
|
|
|
)
|
2023-05-22 18:26:17 +02:00
|
|
|
|
import XMonad.Layout.IndependentScreens
|
2022-12-01 16:21:19 +01:00
|
|
|
|
import XMonad.Layout.WindowNavigation
|
|
|
|
|
import qualified XMonad.StackSet as W
|
|
|
|
|
import XMonad.Util.EZConfig
|
|
|
|
|
import qualified XMonad.Util.Hacks as Hacks
|
|
|
|
|
import XMonad.Util.Loggers
|
|
|
|
|
import XMonad.Util.Paste
|
|
|
|
|
import XMonad.Util.Run
|
|
|
|
|
( spawnExternalProcess,
|
|
|
|
|
spawnPipe,
|
|
|
|
|
)
|
|
|
|
|
import XMonad.Util.Ungrab
|
2023-06-02 22:12:39 +02:00
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
|
|
-- Statusbar {{{
|
2022-09-23 00:46:34 +02:00
|
|
|
|
|
2023-06-02 22:21:03 +02:00
|
|
|
|
pp' :: ScreenId -> PP -> PP
|
|
|
|
|
pp' s pp = (marshallPP s pp) { ppSort = ppSort pp }
|
|
|
|
|
|
|
|
|
|
pp :: PP
|
|
|
|
|
pp =
|
2022-12-01 16:18:44 +01:00
|
|
|
|
def
|
2023-05-04 23:57:30 +02:00
|
|
|
|
{ ppSep = tertiaryColor " ",
|
2022-12-01 16:18:44 +01:00
|
|
|
|
ppCurrent = brackitify,
|
|
|
|
|
ppHidden = secondaryColor,
|
|
|
|
|
ppHiddenNoWindows = tertiaryColor,
|
|
|
|
|
ppUrgent = red . wrap (yellow "!") (yellow "!"),
|
|
|
|
|
ppLayout = \l -> case l of
|
|
|
|
|
"Tall" -> "[]="
|
|
|
|
|
"Magnifier Tall" -> "[]+"
|
|
|
|
|
"Magnifier (off) Tall" -> "[]="
|
|
|
|
|
"Magnifier Mirror Tall" -> "+[]"
|
|
|
|
|
"Magnifier (off) Mirror Tall" -> "=[]"
|
|
|
|
|
"Full" -> "[ ]"
|
|
|
|
|
"ThreeCol" -> "|||"
|
|
|
|
|
_ -> l,
|
|
|
|
|
ppTitle = shorten 80,
|
|
|
|
|
ppTitleSanitize = xmobarStrip,
|
|
|
|
|
ppOrder = \[ws, l, _, wins] -> [ws, l, wins],
|
|
|
|
|
ppExtras = [logTitles formatFocused formatUnfocused]
|
2022-10-25 21:11:18 +02:00
|
|
|
|
}
|
|
|
|
|
where
|
2023-05-04 23:57:30 +02:00
|
|
|
|
brackitify = wrap "〈" "〉"
|
|
|
|
|
formatFocused = secondaryColor . ppWindow
|
2022-10-25 21:11:18 +02:00
|
|
|
|
formatUnfocused = tertiaryColor . ppWindow
|
2022-09-24 01:07:06 +02:00
|
|
|
|
|
2022-10-25 21:11:18 +02:00
|
|
|
|
ppWindow = xmobarRaw . (\w -> if null w then "Untitled" else w) . shorten 16
|
2022-09-24 01:07:06 +02:00
|
|
|
|
|
2022-12-01 16:18:44 +01:00
|
|
|
|
primaryColor = xmobarColor "#000000" ""
|
|
|
|
|
secondaryColor = xmobarColor "#333333" ""
|
|
|
|
|
tertiaryColor = xmobarColor "#555555" ""
|
|
|
|
|
yellow = xmobarColor "#ff0" ""
|
|
|
|
|
red = xmobarColor "#ff5555" ""
|
2022-09-24 01:07:06 +02:00
|
|
|
|
|
2023-06-02 22:12:39 +02:00
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
|
|
-- Workspaces & screens {{{
|
|
|
|
|
|
2022-10-25 21:15:15 +02:00
|
|
|
|
-- Shift to workspace and view workspace
|
|
|
|
|
shiftAndView id = doF (W.view id) <> doF (W.shift id)
|
2022-09-23 00:46:34 +02:00
|
|
|
|
|
2023-05-21 18:27:55 +02:00
|
|
|
|
-- startupHook
|
|
|
|
|
myStartupHook =
|
|
|
|
|
do
|
|
|
|
|
spawn "albert"
|
|
|
|
|
|
2023-06-02 22:12:39 +02:00
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
|
|
-- Hooks {{{
|
|
|
|
|
|
2022-10-25 21:15:15 +02:00
|
|
|
|
-- manageHook
|
2022-12-01 16:21:19 +01:00
|
|
|
|
myManageHook =
|
|
|
|
|
composeAll
|
|
|
|
|
[ className =? "Zathura" --> doShift "pdf",
|
|
|
|
|
className =? "firefox" --> shiftAndView "www",
|
|
|
|
|
className =? "Anki" --> shiftAndView "etc",
|
|
|
|
|
className =? "Obsidian" --> shiftAndView "etc",
|
|
|
|
|
className =? "Launcher" --> doRectFloat (W.RationalRect 0.05 0.4 0.9 0.5),
|
|
|
|
|
className =? "Calculator" --> doCenterFloat,
|
|
|
|
|
className =? "feh" --> doCenterFloat,
|
2023-05-21 18:23:55 +02:00
|
|
|
|
className =? "Matplotlib" --> doCenterFloat,
|
|
|
|
|
className =? "Xournalpp" --> doRectFloat (W.RationalRect 0.5 0.5 0.5 0.5),
|
|
|
|
|
className =? "KeePassXC" --> doRectFloat (W.RationalRect 0.1 0.1 0.8 0.8)
|
2022-12-01 16:21:19 +01:00
|
|
|
|
]
|
2022-09-23 00:46:34 +02:00
|
|
|
|
|
2022-10-25 21:14:38 +02:00
|
|
|
|
-- layoutHook
|
2022-12-01 16:21:19 +01:00
|
|
|
|
myLayoutHook =
|
2023-05-04 23:57:30 +02:00
|
|
|
|
-- smartBorders $
|
|
|
|
|
-- Tiled layouts
|
|
|
|
|
tiled
|
|
|
|
|
-- -- Note: magnifier is off by default
|
|
|
|
|
-- -- (controllable usingarrow keys)
|
|
|
|
|
-- ||| magnifiercz magnificationFactorH tiled
|
|
|
|
|
-- ||| magnifiercz magnificationFactorV (Mirror tiled)
|
2022-12-01 16:21:19 +01:00
|
|
|
|
-- Single window / monocle layout
|
2023-05-04 23:57:30 +02:00
|
|
|
|
-- Column layouts
|
|
|
|
|
-- ||| threeColMid
|
|
|
|
|
-- Monocle layouts
|
2022-12-01 16:21:19 +01:00
|
|
|
|
||| Full
|
2022-09-24 01:07:06 +02:00
|
|
|
|
where
|
|
|
|
|
magnificationFactorV = 1.384
|
|
|
|
|
magnificationFactorH = 1.621
|
2022-12-01 16:21:19 +01:00
|
|
|
|
tiled = Tall nmaster delta ratio
|
2022-09-24 01:07:06 +02:00
|
|
|
|
threeCol = ThreeCol nmaster delta ratio
|
|
|
|
|
threeColMid = ThreeColMid nmaster delta ratio
|
|
|
|
|
nmaster = 1
|
2022-12-01 16:21:19 +01:00
|
|
|
|
ratio = 1 / 2
|
|
|
|
|
delta = 4 / 100
|
2022-09-24 01:07:06 +02:00
|
|
|
|
|
2023-05-22 18:26:17 +02:00
|
|
|
|
myWorkspaces = [ "sh", "www", "dev", "info", "etc" ]
|
|
|
|
|
myWorkspaceKeys = [ "a", "s", "d", "f", "g" ]
|
|
|
|
|
mySharedWorkspaces = [ "shared" ]
|
|
|
|
|
mySharedWorkspaceKeys = [ "1" ]
|
2023-05-15 14:36:12 +02:00
|
|
|
|
|
2023-06-02 22:12:39 +02:00
|
|
|
|
-- }}}
|
|
|
|
|
|
2022-12-01 16:21:19 +01:00
|
|
|
|
myConfig =
|
|
|
|
|
def
|
|
|
|
|
{ terminal = "alacritty",
|
|
|
|
|
-- Use Win key instead of Alt
|
|
|
|
|
modMask = mod4Mask,
|
|
|
|
|
-- , workspaces = ["α", "β", "γ", "δ", "ε", "ζ", "η"]
|
2023-05-22 18:26:17 +02:00
|
|
|
|
workspaces = withScreen 0 myWorkspaces ++ withScreen 1 mySharedWorkspaces,
|
2022-12-01 16:21:19 +01:00
|
|
|
|
-- Styling
|
2023-05-04 23:57:30 +02:00
|
|
|
|
focusedBorderColor = "#000",
|
|
|
|
|
normalBorderColor = "#0000",
|
2023-05-21 18:25:51 +02:00
|
|
|
|
borderWidth = 4,
|
2022-12-01 16:21:19 +01:00
|
|
|
|
-- Hooks
|
2023-05-21 18:27:55 +02:00
|
|
|
|
startupHook = myStartupHook,
|
2022-12-01 16:21:19 +01:00
|
|
|
|
manageHook = myManageHook <+> manageHook def,
|
|
|
|
|
layoutHook = avoidStruts myLayoutHook,
|
|
|
|
|
handleEventHook = handleEventHook def <> Hacks.windowedFullscreenFixEventHook
|
|
|
|
|
}
|
2022-09-24 01:07:06 +02:00
|
|
|
|
`removeKeysP` myRemoveKeysP
|
2023-05-22 18:26:17 +02:00
|
|
|
|
`additionalKeysP` myKeysP
|
2022-09-24 01:07:06 +02:00
|
|
|
|
|
|
|
|
|
-- Keybindings to be added/overridden
|
2022-12-01 16:21:19 +01:00
|
|
|
|
myKeysP =
|
|
|
|
|
[ -- Fit floating windows back to layout
|
|
|
|
|
("M-S-<Space>", withFocused $ windows . W.sink),
|
|
|
|
|
-- Launchers
|
|
|
|
|
("M-S-p", spawn "alacritty --class Launcher,Launcher"),
|
2023-05-21 18:28:44 +02:00
|
|
|
|
("<F8>", spawn "keepassxc"),
|
2022-12-01 16:21:19 +01:00
|
|
|
|
("M-p", spawn "albert toggle"),
|
|
|
|
|
-- Map insert key to paste from clipboard
|
|
|
|
|
("<Insert>", pasteSelection),
|
|
|
|
|
-- Map print screen to take a screenshot with flameshot
|
|
|
|
|
("<Print>", spawn "flameshot gui"),
|
|
|
|
|
-- Map audio keys to control volume
|
|
|
|
|
("<XF86AudioRaiseVolume>", spawn "pactl set-sink-volume @DEFAULT_SINK@ +5%"),
|
|
|
|
|
("<XF86AudioLowerVolume>", spawn "pactl set-sink-volume @DEFAULT_SINK@ -5%"),
|
|
|
|
|
("<XF86AudioMute>", spawn "pactl set-sink-mute @DEFAULT_SINK@ toggle"),
|
|
|
|
|
-- Map brightness keys to control brightness with brightnessctl
|
|
|
|
|
("<XF86MonBrightnessUp>", spawn "brightnessctl set 20+"),
|
|
|
|
|
("<XF86MonBrightnessDown>", spawn "brightnessctl set 20-"),
|
|
|
|
|
-- Map brightness keys + shift to adjust redshift temperature
|
|
|
|
|
("S-<XF86MonBrightnessUp>", spawn "echo $(($(cat /tmp/temperature) + 50)) > /tmp/temperature && redshift -O $(cat /tmp/temperature) -P && notify < /tmp/temperature -h string:x-canonical-private-synchronous:anything"),
|
|
|
|
|
("S-<XF86MonBrightnessDown>", spawn "echo $(($(cat /tmp/temperature) - 50)) > /tmp/temperature && redshift -O $(cat /tmp/temperature) -P && notify < /tmp/temperature -h string:x-canonical-private-synchronous:anything"),
|
|
|
|
|
-- Reset redshift temperature
|
|
|
|
|
("M-S-<XF86MonBrightnessUp>", spawn "echo 3000 > /tmp/temperature && redshift -x"),
|
|
|
|
|
("M-S-<XF86MonBrightnessDown>", spawn "echo 3000 > /tmp/temperature && redshift -x"),
|
|
|
|
|
-- Use power down key to suspend
|
|
|
|
|
("<XF86PowerOff>", spawn "systemctl suspend"),
|
|
|
|
|
-- FIXME: Spawn firefox in fullscreen, but not in kiosk mode
|
|
|
|
|
("M-S-b", spawn "firefox --fullscreen"),
|
|
|
|
|
-- Magnify window using arrow keys
|
|
|
|
|
("M-=", sendMessage MagnifyMore >> sendMessage Mag.ToggleOn),
|
|
|
|
|
("M--", sendMessage MagnifyLess >> sendMessage Mag.ToggleOn),
|
|
|
|
|
-- Reset magnification
|
|
|
|
|
("M-S-=", sendMessage Mag.ToggleOff),
|
|
|
|
|
("<XF86Calculator>", spawn "alacritty --class 'Calculator' -e ipython -i /home/h/.bin/calc.py"),
|
|
|
|
|
-- playerctl ncspot using arrow keys
|
|
|
|
|
("M-<Right>", spawn "playerctl next"),
|
|
|
|
|
("M-<Left>", spawn "playerctl previous"),
|
|
|
|
|
("M-<Up>", spawn "playerctl play"),
|
2023-05-22 18:26:17 +02:00
|
|
|
|
("M-<Down>", spawn "playerctl pause")
|
|
|
|
|
] ++ [
|
|
|
|
|
(m ++ k, windows $ f w) |
|
|
|
|
|
(m, f) <- zip ["M-", "M-S-"]
|
|
|
|
|
[W.greedyView, W.shift],
|
|
|
|
|
(k, w) <- zip myWorkspaceKeys (withScreen 0 myWorkspaces) ++ zip mySharedWorkspaceKeys (withScreen 1 mySharedWorkspaces)
|
2022-09-24 01:07:06 +02:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
-- Keybindings to be removed
|
2022-12-01 16:21:19 +01:00
|
|
|
|
myRemoveKeysP =
|
|
|
|
|
[ -- Remove 1,2,3,4,5 bindings for workspaces
|
|
|
|
|
"M-1",
|
|
|
|
|
"M-2",
|
|
|
|
|
"M-3",
|
|
|
|
|
"M-4",
|
|
|
|
|
"M-5",
|
|
|
|
|
-- Remove shift + 1,2,3,4,5 bindings for workspaces
|
|
|
|
|
"M-S-1",
|
|
|
|
|
"M-S-2",
|
|
|
|
|
"M-S-3",
|
|
|
|
|
"M-S-4",
|
|
|
|
|
"M-S-5"
|
|
|
|
|
]
|
2022-09-24 01:07:06 +02:00
|
|
|
|
|
2023-06-02 22:21:03 +02:00
|
|
|
|
-- main :: IO ()
|
|
|
|
|
main = do xmonad
|
|
|
|
|
$ ewmh
|
|
|
|
|
$ withEasySB
|
|
|
|
|
(sb1 <> sb2)
|
|
|
|
|
defToggleStrutsKey
|
|
|
|
|
myConfig
|
|
|
|
|
where
|
|
|
|
|
sb1 = statusBarProp "xmobar" $ pure (pp' (S 0) pp)
|
|
|
|
|
sb2 = statusBarProp "xmobar" $ pure (pp' (S 1) pp)
|