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"; "dmenu_run" = "${pkgs.dmenu}/bin/dmenu_run";
"polybar" = pkgs.writeShellScript "polybar" "polybar" = pkgs.writeShellScript "polybar"
'' ''
monitors=$(polybar --list-monitors | cut -f 1 -d':') export PATH=${lib.makeBinPath [ pkgs.polybarFull ]}:$PATH
MONITOR=''${monitors[$1]} ${lib.getExe pkgs.polybarFull} -c ${./polybar.ini} top
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" "reload" = pkgs.writeShellScript "xmonad-reload"
'' ''

View file

@ -26,11 +26,14 @@ import XMonad.Hooks.EwmhDesktops
import XMonad.Layout.BinarySpacePartition import XMonad.Layout.BinarySpacePartition
import XMonad.Layout.Tabbed import XMonad.Layout.Tabbed
import XMonad.Layout.NoBorders import XMonad.Layout.NoBorders
import XMonad.Layout.IndependentScreens
import XMonad.Util.WorkspaceCompare import XMonad.Util.WorkspaceCompare
import XMonad.Hooks.DynamicLog import XMonad.Hooks.DynamicLog
import XMonad.Hooks.StatusBar import XMonad.Hooks.StatusBar
import XMonad.Actions.UpdatePointer import XMonad.Actions.UpdatePointer
import XMonad.Actions.FloatKeys import XMonad.Actions.FloatKeys
import XMonad.Actions.Warp
import XMonad.Actions.CopyWindow
import Control.Monad import Control.Monad
@ -42,7 +45,7 @@ myTerminal = "xterm"
myFocusFollowsMouse = True myFocusFollowsMouse = True
myClickJustFocuses = False myClickJustFocuses = False
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9] -- > 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 toggleFloat = withFocused (\windowId -> do
{ floats <- gets (W.floating . windowset); { floats <- gets (W.floating . windowset);
@ -111,6 +114,8 @@ myKeymap c =
-- Deincrement the number of windows in the master area -- Deincrement the number of windows in the master area
, ("M-m", sendMessage (IncMasterN (-1))) , ("M-m", sendMessage (IncMasterN (-1)))
, ("M-d", warpToWindow 0.5 0.5)
-- , ("M-b", spawn ("pkill xmobar && " ++ xmobarCmd)) -- , ("M-b", spawn ("pkill xmobar && " ++ xmobarCmd))
, ("<Print>", spawn "sleep 0.1 ; @screenshot@ select") , ("<Print>", spawn "sleep 0.1 ; @screenshot@ select")
, ("S-<Print>", spawn "@screenshot@ screen && sleep 0.1 && @notify@ -t 5000 \"snap\"") , ("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-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N -- mod-shift-[1..9], Move client to workspace N
-- --
[("M-" ++ m ++ [k], windows $ f i) [("M-" ++ m ++ [k], windows $ onCurrentScreen f i)
| (i, k) <- zip (XMonad.workspaces c) "1234567890" | (i, k) <- zip (workspaces' c) "1234567890"
, (f, m) <- [(W.view, ""), (W.shift, "S-")]] , (f, m) <- [(W.greedyView, ""), (W.shift, "S-")]]
++ ++
-- --
@ -236,7 +241,8 @@ myPP = def
} }
spawnBar :: ScreenId -> IO StatusBarConfig 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. -- Now run xmonad with all the defaults we set up.
@ -290,9 +296,9 @@ defaults = let
-- 'className' and 'resource' are used below. -- 'className' and 'resource' are used below.
manageHook = manageDocks <+> composeAll manageHook = manageDocks <+> composeAll
[ title =? "emacs-completing-read-float" --> doFloat [ 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 -- , hasNetWMState "_NET_WM_STATE_STICKY" --> doF copyToAll
-- , className =? "Gimp" --> doFloat , className =? "xmessage" --> doFloat
-- , resource =? "desktop_window" --> doIgnore -- , resource =? "desktop_window" --> doIgnore
-- , resource =? "kdesktop" --> doIgnore -- , resource =? "kdesktop" --> doIgnore
], ],
@ -301,11 +307,7 @@ defaults = let
updatePointer (0.5, 0.5) (1, 1), updatePointer (0.5, 0.5) (1, 1),
-- XMonad.Layout.PerWorkspace -- XMonad.Layout.PerWorkspace
startupHook = do -- startupHook = void,
spawnOnce "@dunst@ -config .config/dunstrcs"
spawnOnce "@picom@ --config .config/picom.conf --experimental-backends"
spawnOnce "@keynav@"
spawnOnce "@lightLocker@ --lock-on-suspend",
-- Looks -- Looks
focusedBorderColor = "#5c5c5c", focusedBorderColor = "#5c5c5c",