From d2cf3a7e2a9fc770659613a5f8f0ef0c66727bfc Mon Sep 17 00:00:00 2001 From: Christian Harke Date: Sat, 16 Sep 2023 00:00:14 +0200 Subject: [PATCH] Add fullscreen toggle to Xmonad --- home/programs/xmonad/xmonad.hs.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/home/programs/xmonad/xmonad.hs.nix b/home/programs/xmonad/xmonad.hs.nix index b7a8ab27..221e73f4 100644 --- a/home/programs/xmonad/xmonad.hs.nix +++ b/home/programs/xmonad/xmonad.hs.nix @@ -12,10 +12,12 @@ in pkgs.writeText "xmonad.hs" '' import Control.Monad (join, when) import Data.Maybe (maybeToList) + import qualified Data.Map as M import XMonad import XMonad.Actions.CycleWS (Direction1D(Next, Prev), moveTo, shiftTo, toggleWS', WSType(WSIs)) + import XMonad.Actions.NoBorders (toggleBorder) import XMonad.Hooks.EwmhDesktops (ewmh, ewmhFullscreen) import XMonad.Hooks.ManageDocks (avoidStruts, docks, manageDocks) @@ -161,6 +163,17 @@ pkgs.writeText "xmonad.hs" '' ratio = 1/2 -- Default proportion of screen occupied by master pane delta = 3/100 -- Percent of screen to increment by when resizing panes + toggleFull = withFocused (\windowId -> do { + floats <- gets (W.floating . windowset); + if windowId `M.member` floats + then do + withFocused $ toggleBorder + withFocused $ windows . W.sink + else do + withFocused $ toggleBorder + withFocused $ windows . (flip W.float $ W.RationalRect 0 0 1 1) + }) + myKeys :: [(String, X ())] myKeys = [ ("M-S-", spawn "${escapeHaskellString cfg.locker.lockCmd}") @@ -170,6 +183,7 @@ pkgs.writeText "xmonad.hs" '' , ("C-", unGrab *> spawn "${getExe pkgs.bash} ${escapeHaskellString cfg.screenshot.runCmdWindow}") , ("C-S-", unGrab *> spawn "${getExe pkgs.bash} ${escapeHaskellString cfg.screenshot.runCmdSelect}") , ("M-p", spawn "${escapeHaskellString cfg.launcherCmd}") + , ("M-f", toggleFull) -- Cycling workspaces , ("M-", moveTo Next nonNSP)