Make per screen workspaces in xmonad

Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
Magic_RB 2023-06-12 14:29:48 +02:00
parent dd559bfcf0
commit bd9c1faee1
2 changed files with 19 additions and 14 deletions

View file

@ -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"
''

View file

@ -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))
, ("<Print>", spawn "sleep 0.1 ; @screenshot@ select")
, ("S-<Print>", 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",