dots/.xmonad/xmonad.hs

180 lines
6.6 KiB
Haskell
Raw Normal View History

2022-09-23 00:46:34 +02:00
import XMonad
2022-10-25 21:09:32 +02:00
2022-09-23 00:46:34 +02:00
import XMonad.Hooks.DynamicLog
2022-10-25 21:09:32 +02:00
import XMonad.Hooks.EwmhDesktops
2022-09-23 00:46:34 +02:00
import XMonad.Hooks.ManageDocks
2022-10-25 21:09:32 +02:00
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP
2022-09-24 01:07:06 +02:00
import XMonad.Layout.Magnifier
2022-10-25 21:09:32 +02:00
import qualified XMonad.Layout.Magnifier as Mag (MagnifyMsg (..))
import XMonad.Layout.NoBorders (hasBorder, smartBorders)
import XMonad.Layout.PerScreen
import XMonad.Layout.ResizableTile
2022-09-23 00:46:34 +02:00
import XMonad.Layout.Spacing
2022-09-24 01:07:06 +02:00
import XMonad.Layout.ThreeColumns
2022-10-25 21:09:32 +02:00
import XMonad.Layout.ToggleLayouts (ToggleLayout (..),
toggleLayouts)
import XMonad.Layout.WindowNavigation
import qualified XMonad.StackSet as W
2022-09-24 01:07:06 +02:00
2022-09-23 00:46:34 +02:00
import XMonad.Util.EZConfig
2022-10-25 21:09:32 +02:00
import qualified XMonad.Util.Hacks as Hacks
2022-09-24 01:07:06 +02:00
import XMonad.Util.Loggers
2022-09-23 00:46:34 +02:00
import XMonad.Util.Paste
2022-10-25 21:09:32 +02:00
import XMonad.Util.Run (spawnExternalProcess,
spawnPipe)
2022-09-24 01:07:06 +02:00
import XMonad.Util.Ungrab
2022-09-23 00:46:34 +02:00
2022-10-25 21:11:18 +02:00
-- Statusbar
myXmobarPP :: PP
2022-12-01 16:18:44 +01:00
myXmobarPP =
def
{ ppSep = tertiaryColor " | ",
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
brackitify = wrap "[" "]"
2022-12-01 16:18:44 +01:00
formatFocused = secondaryColor . brackitify . 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
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
2022-10-25 21:15:15 +02:00
-- manageHook
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
, className =? "albert" --> hasBorder False
, className =? "Xournalpp" --> doRectFloat (W.RationalRect 0.5 0.5 0.5 0.5)
]
2022-09-23 00:46:34 +02:00
2022-10-25 21:14:38 +02:00
-- layoutHook
myLayoutHook= smartBorders $
-- Column layouts
threeCol |||
2022-09-24 16:17:14 +02:00
threeColMid |||
2022-10-25 21:14:38 +02:00
-- Tiled layouts
-- Note: magnifier is off by default
-- (controllable usingarrow keys)
2022-09-24 16:17:14 +02:00
magnifiercz magnificationFactorH tiled |||
magnifiercz magnificationFactorV (Mirror tiled) |||
2022-10-25 21:14:38 +02:00
-- Single window / monocle layout
2022-09-24 16:17:14 +02:00
Full
2022-09-24 01:07:06 +02:00
where
magnificationFactorV = 1.384
magnificationFactorH = 1.621
tiled = Tall nmaster delta ratio
threeCol = ThreeCol nmaster delta ratio
threeColMid = ThreeColMid nmaster delta ratio
nmaster = 1
ratio = 1/2
delta = 4/100
myConfig = def
{
terminal = "alacritty"
-- Use Win key instead of Alt
, modMask = mod4Mask
2022-09-24 11:15:13 +02:00
, workspaces = ["α", "β", "γ", "δ", "ε", "ζ", "η"]
2022-09-24 01:07:06 +02:00
-- Styling
, focusedBorderColor = "#888"
, normalBorderColor = "#000"
, borderWidth = 2
-- Hooks
2022-09-24 16:18:24 +02:00
, manageHook = myManageHook <+> manageHook def
2022-10-25 21:13:04 +02:00
, layoutHook = avoidStruts myLayoutHook
, handleEventHook = handleEventHook def <> Hacks.windowedFullscreenFixEventHook
2022-09-24 01:07:06 +02:00
} `additionalKeysP` myKeysP
`removeKeysP` myRemoveKeysP
-- Keybindings to be added/overridden
myKeysP = [
-- Fit floating windows back to layout
("M-S-<Space>", withFocused $ windows . W.sink)
2022-10-25 21:16:21 +02:00
-- Launchers
, ("M-p", spawn "albert toggle")
2022-09-24 01:07:06 +02:00
-- 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
2022-09-24 16:18:01 +02:00
, ("M-=", sendMessage MagnifyMore >> sendMessage Mag.ToggleOn)
, ("M--", sendMessage MagnifyLess >> sendMessage Mag.ToggleOn)
-- Reset magnification
, ("M-S-=", sendMessage Mag.ToggleOff)
2022-10-25 21:14:38 +02:00
-- Layouts
, ("M-t", sendMessage $ JumpToLayout "Magnifier Tall")
, ("M-c", sendMessage $ JumpToLayout "ThreeCol")
2022-09-24 16:18:46 +02:00
, ("M-f", sendMessage $ JumpToLayout "Full")
2022-09-24 01:07:06 +02:00
]
-- Keybindings to be removed
2022-10-25 21:17:06 +02:00
myRemoveKeysP = [ ]
2022-09-24 01:07:06 +02:00
main :: IO ()
main = do xmonad $ docks $ ewmh $ withEasySB (statusBarProp "xmobar" (pure myXmobarPP)) defToggleStrutsKey myConfig