Add more stuff to xmonad

Signed-off-by: magic_rb <magic_rb@redalder.org>
This commit is contained in:
magic_rb 2023-11-18 13:43:05 +01:00
parent c36dcd4442
commit be6024d662
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E
2 changed files with 120 additions and 47 deletions

View file

@ -50,6 +50,8 @@ import qualified XMonad.StackSet as W
import qualified Data.Map as M import qualified Data.Map as M
import XMonad.Actions.Navigation2D import XMonad.Actions.Navigation2D
import XMonad.Layout.Cross (simpleCross) import XMonad.Layout.Cross (simpleCross)
import Data.IORef
import GHC.IO.Unsafe (unsafePerformIO)
myTerminal = "xterm" myTerminal = "xterm"
@ -108,6 +110,21 @@ getWindowTitle w d = liftIO $ getTextProperty d w wM_NAME >>= (peekCString . tp_
modm :: KeyMask modm :: KeyMask
modm = mod4Mask modm = mod4Mask
skipFloating :: Ord a => W.StackSet i l a s sd -> (W.StackSet i l a s sd -> W.StackSet i l a s sd) -> W.StackSet i l a s sd
skipFloating stacks f
| isNothing curr = stacks -- short circuit if there is no currently focused window
| otherwise = skipFloatingR stacks curr f
where curr = W.peek stacks
skipFloatingR :: Ord a => W.StackSet i l a s sd -> (Maybe a) -> (W.StackSet i l a s sd -> W.StackSet i l a s sd) -> W.StackSet i l a s sd
skipFloatingR stacks startWindow f
| isNothing nextWindow = stacks -- next window is nothing return current stack set
| nextWindow == startWindow = newStacks -- if next window is the starting window then return the new stack set
| M.notMember (fromJust nextWindow) (W.floating stacks) = newStacks -- if next window is not a floating window return the new stack set
| otherwise = skipFloatingR newStacks startWindow f -- the next window is a floating window so keep recursing (looking)
where newStacks = f stacks
nextWindow = W.peek newStacks
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here. -- Key bindings. Add, modify or remove key bindings here.
-- --
@ -159,10 +176,10 @@ myKeymap c =
, ("M-t", windowGo L False >> centerMouse) , ("M-t", windowGo L False >> centerMouse)
, ("M-r", getCurrentLayout >>= \case , ("M-r", getCurrentLayout >>= \case
"Tabbed Simplest" -> windows W.focusUp "Tabbed Simplest" -> windows (`skipFloating` W.focusUp)
_ -> windowGo U False >> centerMouse) _ -> windowGo U False >> centerMouse)
, ("M-n", getCurrentLayout >>= \case , ("M-n", getCurrentLayout >>= \case
"Tabbed Simplest" -> windows W.focusDown "Tabbed Simplest" -> windows (`skipFloating` W.focusDown)
_ -> windowGo D False >> centerMouse) _ -> windowGo D False >> centerMouse)
, ("M-s", windowGo R False >> centerMouse) , ("M-s", windowGo R False >> centerMouse)
@ -205,6 +222,34 @@ myKeymap c =
, ("M-<F9>", (workspacesGrouped >>= \ws -> (liftIO . print $ ws))) , ("M-<F9>", (workspacesGrouped >>= \ws -> (liftIO . print $ ws)))
] ]
++ ++
--
--
--
--
-- mod-[1..9], Switch to workspace N
-- mod-[1..9], Switch to workspace N
-- mod-[1..9], Switch to workspace N
-- mod-[1..9], Switch to workspace N
--
--
--
--
--
--
-- mod-[1..9], Switch to workspace N
-- mod-[1..9], Switch to workspace N
--
--
--
--
-- mod-[1..9], Switch to workspace N
-- mod-[1..9], Switch to workspace N
--
--
-- --
-- mod-[1..9], Switch to workspace N -- mod-[1..9], Switch to workspace N
-- --
@ -213,8 +258,20 @@ myKeymap c =
, (f, m) <- [(W.greedyView, ""), (W.shift, "S-"), (copy, "S-C-")]] , (f, m) <- [(W.greedyView, ""), (W.shift, "S-"), (copy, "S-C-")]]
++ ++
-- --
--
--
--
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3 -- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3 -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
--
--
--
-- --
[("M-"++m++[key], screenWorkspace sc >>= flip whenJust (windows . f)) [("M-"++m++[key], screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip ".o," [0..] | (key, sc) <- zip ".o," [0..]
@ -312,6 +369,10 @@ hasNetWMState state = do
atom <- liftX $ getAtom state atom <- liftX $ getAtom state
return $ elem atom wmstate return $ elem atom wmstate
ewwWindows :: IORef [Window]
{-# NOINLINE ewwWindows #-}
ewwWindows = unsafePerformIO $ newIORef []
-- A structure containing your configuration settings, overriding -- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will -- fields in the default config. Any you don't override, will
-- use the defaults defined in xmonad/XMonad/Config.hs -- use the defaults defined in xmonad/XMonad/Config.hs
@ -342,15 +403,24 @@ 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 =? "Eww" --> (do
liftIO $ print "eww"
window <- ask
oldSet <- liftIO $ readIORef ewwWindows
liftIO $ writeIORef ewwWindows (window : oldSet)
doF id)
, className =? "xmessage" --> doFloat , className =? "xmessage" --> doFloat
-- , resource =? "desktop_window" --> doIgnore -- , resource =? "desktop_window" --> doIgnore
-- , resource =? "kdesktop" --> doIgnore -- , resource =? "kdesktop" --> doIgnore
], ],
logHook = logHook = do
updatePointer (0.5, 0.5) (1, 1), updatePointer (0.5, 0.5) (1, 1)
set <- liftIO $ readIORef ewwWindows
liftIO $ print set
pure (),
-- XMonad.Layout.PerWorkspace -- XMonad.Layout.PerWorkspace
-- startupHook = void, -- startupHook = void,

View file

@ -1,5 +1,9 @@
{ pkgs, lib, inputs', ... }:
{ {
pkgs,
lib,
inputs',
...
}: {
home.file.".xmonad/build".executable = true; home.file.".xmonad/build".executable = true;
home.file.".xmonad/build".text = '' home.file.".xmonad/build".text = ''
#!/usr/bin/env bash #!/usr/bin/env bash
@ -10,15 +14,13 @@
cp "$(stack path --local-install-root)/bin/xmonad-exe" "$1" cp "$(stack path --local-install-root)/bin/xmonad-exe" "$1"
''; '';
home.file.".xmonad/buildenv".source = home.file.".xmonad/buildenv".source = pkgs.buildEnv {
pkgs.buildEnv {
name = "xmonad-buildenv"; name = "xmonad-buildenv";
ignoreCollisions = true; ignoreCollisions = true;
paths = inputs'.self.devShells.${pkgs.stdenv.system}.default.nativeBuildInputs; paths = inputs'.self.devShells.${pkgs.stdenv.system}.default.nativeBuildInputs;
}; };
home.file.".xmonad/runenv".source = home.file.".xmonad/runenv".source = let
let
polybar-mm = polybar-mm =
pkgs.writeShellScriptBin "polybar-mm" pkgs.writeShellScriptBin "polybar-mm"
(builtins.readFile ./scripts/polybar-mm.sh); (builtins.readFile ./scripts/polybar-mm.sh);
@ -46,6 +48,7 @@
reload reload
toggle-touchpad toggle-touchpad
auxmenu auxmenu
wirelesstools
emacs-vterm emacs-vterm
libnotify libnotify
x11_ssh_askpass x11_ssh_askpass