diff --git a/home-manager/modules/xmonad/app/Main.hs b/home-manager/modules/xmonad/app/Main.hs index 682b402..1a81c69 100644 --- a/home-manager/modules/xmonad/app/Main.hs +++ b/home-manager/modules/xmonad/app/Main.hs @@ -50,6 +50,8 @@ import qualified XMonad.StackSet as W import qualified Data.Map as M import XMonad.Actions.Navigation2D import XMonad.Layout.Cross (simpleCross) +import Data.IORef +import GHC.IO.Unsafe (unsafePerformIO) myTerminal = "xterm" @@ -108,6 +110,21 @@ getWindowTitle w d = liftIO $ getTextProperty d w wM_NAME >>= (peekCString . tp_ modm :: KeyMask 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. -- @@ -159,10 +176,10 @@ myKeymap c = , ("M-t", windowGo L False >> centerMouse) , ("M-r", getCurrentLayout >>= \case - "Tabbed Simplest" -> windows W.focusUp + "Tabbed Simplest" -> windows (`skipFloating` W.focusUp) _ -> windowGo U False >> centerMouse) , ("M-n", getCurrentLayout >>= \case - "Tabbed Simplest" -> windows W.focusDown + "Tabbed Simplest" -> windows (`skipFloating` W.focusDown) _ -> windowGo D False >> centerMouse) , ("M-s", windowGo R False >> centerMouse) @@ -205,6 +222,34 @@ myKeymap c = , ("M-", (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 -- @@ -213,8 +258,20 @@ myKeymap 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-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)) | (key, sc) <- zip ".o," [0..] @@ -312,6 +369,10 @@ hasNetWMState state = do atom <- liftX $ getAtom state return $ elem atom wmstate +ewwWindows :: IORef [Window] +{-# NOINLINE ewwWindows #-} +ewwWindows = unsafePerformIO $ newIORef [] + -- A structure containing your configuration settings, overriding -- fields in the default config. Any you don't override, will -- use the defaults defined in xmonad/XMonad/Config.hs @@ -342,15 +403,24 @@ 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_STICKY" --> doF copyToAll + , hasNetWMState "_NET_WM_STATE_ABOVE" --> doFloat + , 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 -- , resource =? "desktop_window" --> doIgnore -- , resource =? "kdesktop" --> doIgnore ], - logHook = - updatePointer (0.5, 0.5) (1, 1), + logHook = do + updatePointer (0.5, 0.5) (1, 1) + set <- liftIO $ readIORef ewwWindows + liftIO $ print set + pure (), -- XMonad.Layout.PerWorkspace -- startupHook = void, diff --git a/home-manager/modules/xmonad/default.nix b/home-manager/modules/xmonad/default.nix index 6802734..5f3d4f5 100644 --- a/home-manager/modules/xmonad/default.nix +++ b/home-manager/modules/xmonad/default.nix @@ -1,5 +1,9 @@ -{ pkgs, lib, inputs', ... }: { + pkgs, + lib, + inputs', + ... +}: { home.file.".xmonad/build".executable = true; home.file.".xmonad/build".text = '' #!/usr/bin/env bash @@ -10,45 +14,44 @@ cp "$(stack path --local-install-root)/bin/xmonad-exe" "$1" ''; - home.file.".xmonad/buildenv".source = - pkgs.buildEnv { - name = "xmonad-buildenv"; - ignoreCollisions = true; - paths = inputs'.self.devShells.${pkgs.stdenv.system}.default.nativeBuildInputs; - }; + home.file.".xmonad/buildenv".source = pkgs.buildEnv { + name = "xmonad-buildenv"; + ignoreCollisions = true; + paths = inputs'.self.devShells.${pkgs.stdenv.system}.default.nativeBuildInputs; + }; - home.file.".xmonad/runenv".source = - let - polybar-mm = - pkgs.writeShellScriptBin "polybar-mm" - (builtins.readFile ./scripts/polybar-mm.sh); - reload = - pkgs.writeShellScriptBin "xmonad-reload" - (builtins.readFile ./scripts/polybar-mm.sh); - toggle-touchpad = - pkgs.writeShellScriptBin "toggle-touchpad" - (builtins.readFile ./scripts/toggle-touchpad.sh); - auxmenu = - pkgs.writeShellScriptBin "auxmenu" - (builtins.readFile ./scripts/auxmenu.sh); - emacs-vterm = - pkgs.writeShellScriptBin "emacs-vterm" - (builtins.readFile ./scripts/emacs-vterm.sh); - in - pkgs.buildEnv { - name = "xmonad-runenv"; - paths = with pkgs; [ - brightnessctl - playerctl - dmenu - polybar-mm - polybarFull - reload - toggle-touchpad - auxmenu - emacs-vterm - libnotify - x11_ssh_askpass - ]; - }; + home.file.".xmonad/runenv".source = let + polybar-mm = + pkgs.writeShellScriptBin "polybar-mm" + (builtins.readFile ./scripts/polybar-mm.sh); + reload = + pkgs.writeShellScriptBin "xmonad-reload" + (builtins.readFile ./scripts/polybar-mm.sh); + toggle-touchpad = + pkgs.writeShellScriptBin "toggle-touchpad" + (builtins.readFile ./scripts/toggle-touchpad.sh); + auxmenu = + pkgs.writeShellScriptBin "auxmenu" + (builtins.readFile ./scripts/auxmenu.sh); + emacs-vterm = + pkgs.writeShellScriptBin "emacs-vterm" + (builtins.readFile ./scripts/emacs-vterm.sh); + in + pkgs.buildEnv { + name = "xmonad-runenv"; + paths = with pkgs; [ + brightnessctl + playerctl + dmenu + polybar-mm + polybarFull + reload + toggle-touchpad + auxmenu + wirelesstools + emacs-vterm + libnotify + x11_ssh_askpass + ]; + }; }