From bd9c1faee15d4715644d0e8b07d55a6b18bb37d9 Mon Sep 17 00:00:00 2001 From: Magic_RB Date: Mon, 12 Jun 2023 14:29:48 +0200 Subject: [PATCH] Make per screen workspaces in xmonad Signed-off-by: Magic_RB --- home-manager/modules/xmonad/default.nix | 7 +++++-- home-manager/modules/xmonad/xmonad.hs | 26 +++++++++++++------------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/home-manager/modules/xmonad/default.nix b/home-manager/modules/xmonad/default.nix index b0e9984..ba4586a 100644 --- a/home-manager/modules/xmonad/default.nix +++ b/home-manager/modules/xmonad/default.nix @@ -9,8 +9,11 @@ "dmenu_run" = "${pkgs.dmenu}/bin/dmenu_run"; "polybar" = pkgs.writeShellScript "polybar" '' - monitors=$(polybar --list-monitors | cut -f 1 -d':') - MONITOR=''${monitors[$1]} ${lib.getExe pkgs.polybarFull} -c ${./polybar.ini} top + export PATH=${lib.makeBinPath [ pkgs.polybarFull ]}:$PATH + + monitors=$(polybar --list-monitors | cut -f 1 -d':' | tr '\n' ' ') + monitors=($monitors) + MONITOR=''${monitors[$1]} polybar -c ${./polybar.ini} top ''; "reload" = pkgs.writeShellScript "xmonad-reload" '' diff --git a/home-manager/modules/xmonad/xmonad.hs b/home-manager/modules/xmonad/xmonad.hs index 430ac3a..2db5419 100644 --- a/home-manager/modules/xmonad/xmonad.hs +++ b/home-manager/modules/xmonad/xmonad.hs @@ -26,11 +26,14 @@ import XMonad.Hooks.EwmhDesktops import XMonad.Layout.BinarySpacePartition import XMonad.Layout.Tabbed import XMonad.Layout.NoBorders +import XMonad.Layout.IndependentScreens import XMonad.Util.WorkspaceCompare import XMonad.Hooks.DynamicLog import XMonad.Hooks.StatusBar import XMonad.Actions.UpdatePointer import XMonad.Actions.FloatKeys +import XMonad.Actions.Warp +import XMonad.Actions.CopyWindow import Control.Monad @@ -42,7 +45,7 @@ myTerminal = "xterm" myFocusFollowsMouse = True myClickJustFocuses = False -- > workspaces = ["web", "irc", "code" ] ++ map show [4..9] -myWorkspaces = map show ([1..9] ++ [0]) +myWorkspaces = withScreens 2 $ map show ([1..9] ++ [0]) toggleFloat = withFocused (\windowId -> do { floats <- gets (W.floating . windowset); @@ -111,6 +114,8 @@ myKeymap c = -- Deincrement the number of windows in the master area , ("M-m", sendMessage (IncMasterN (-1))) + , ("M-d", warpToWindow 0.5 0.5) + -- , ("M-b", spawn ("pkill xmobar && " ++ xmobarCmd)) , ("", spawn "sleep 0.1 ; @screenshot@ select") , ("S-", spawn "@screenshot@ screen && sleep 0.1 && @notify@ -t 5000 \"snap\"") @@ -161,9 +166,9 @@ myKeymap c = -- mod-[1..9], Switch to workspace N -- mod-shift-[1..9], Move client to workspace N -- - [("M-" ++ m ++ [k], windows $ f i) - | (i, k) <- zip (XMonad.workspaces c) "1234567890" - , (f, m) <- [(W.view, ""), (W.shift, "S-")]] + [("M-" ++ m ++ [k], windows $ onCurrentScreen f i) + | (i, k) <- zip (workspaces' c) "1234567890" + , (f, m) <- [(W.greedyView, ""), (W.shift, "S-")]] ++ -- @@ -236,7 +241,8 @@ myPP = def } spawnBar :: ScreenId -> IO StatusBarConfig -spawnBar screen = pure $ statusBarPropTo "_XMONAD_LOG" ("@polybar@ " <> (show (fromIntegral screen :: Int))) (pure myPP) +spawnBar screen = pure $ statusBarPropTo ("_XMONAD_LOG_" <> screenString ) ("@polybar@ " <> screenString) (pure myPP) + where screenString = show (fromIntegral screen :: Int) ------------------------------------------------------------------------ -- Now run xmonad with all the defaults we set up. @@ -290,9 +296,9 @@ defaults = let -- 'className' and 'resource' are used below. manageHook = manageDocks <+> composeAll [ title =? "emacs-completing-read-float" --> doFloat - , hasNetWMState "_NET_WM_STATE_ABOVE" --> doFloat + -- , hasNetWMState "_NET_WM_STATE_ABOVE" --> doFloat -- , hasNetWMState "_NET_WM_STATE_STICKY" --> doF copyToAll - -- , className =? "Gimp" --> doFloat + , className =? "xmessage" --> doFloat -- , resource =? "desktop_window" --> doIgnore -- , resource =? "kdesktop" --> doIgnore ], @@ -301,11 +307,7 @@ defaults = let updatePointer (0.5, 0.5) (1, 1), -- XMonad.Layout.PerWorkspace - startupHook = do - spawnOnce "@dunst@ -config .config/dunstrcs" - spawnOnce "@picom@ --config .config/picom.conf --experimental-backends" - spawnOnce "@keynav@" - spawnOnce "@lightLocker@ --lock-on-suspend", + -- startupHook = void, -- Looks focusedBorderColor = "#5c5c5c",