From 587b4a4e204cdfa86e4630ec87991e415f031d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Tue, 18 Nov 2025 19:48:04 +0800 Subject: [PATCH 01/10] vanadium/xmonad: check if current before move --- .../vanadium/home/xmonad/xmonad.hs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index 39e5fa80..701e8fcb 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -151,24 +151,24 @@ myManageHook = myEventHandleHook :: Event -> X All myEventHandleHook = -- TODO: is there a way to always open certain sites in new windows in firefox? + -- TODO: stop full screen when move happens onTitleChange $ composeAll - [ isSpotify --> doShiftAndViewIfMoved multimediaWS - , isYouTube --> doShiftAndViewIfMoved multimediaWS - , isDiscord --> doShiftAndViewIfMoved chatWS - , isWhatsApp --> doShiftAndViewIfMoved chatWS - , isElement --> doShiftAndViewIfMoved chatWS + [ isSpotify --> doShiftAndViewIfCurrent multimediaWS + , isYouTube --> doShiftAndViewIfCurrent multimediaWS + , isDiscord --> doShiftAndViewIfCurrent chatWS + , isWhatsApp --> doShiftAndViewIfCurrent chatWS + , isElement --> doShiftAndViewIfCurrent chatWS ] --- If the title changes in the background, we don't want to greedy view that workspace. +-- | If the title changes in the background, we don't want to greedy view that workspace. -- Imagine Spotify playing in the background, a track change would focus that workspace. --- We prevent this by checking if the window is already there. -doShiftAndViewIfMoved :: WorkspaceId -> Query (Endo WindowSet) -doShiftAndViewIfMoved n = doF . shiftAndViewIfMoved n =<< ask - -shiftAndViewIfMoved :: WorkspaceId -> Window -> WindowSet -> WindowSet -shiftAndViewIfMoved n w s = case W.findTag w s of - Just from | n `W.tagMember` s && n /= from -> W.greedyView n $ W.shiftWin n w s - _ -> s +-- We prevent this by checking if the window is in the current workspace +doShiftAndViewIfCurrent :: WorkspaceId -> Query (Endo WindowSet) +doShiftAndViewIfCurrent n = doF . go =<< ask + where go :: Window -> WindowSet -> WindowSet + go w s = case W.findTag w s of + Just from | from == W.currentTag s -> W.greedyView n $ W.shiftWin n w s + _ -> s myStartupHook :: X () myStartupHook = do From 9b1399e0e607b3f33e27816626b33124766e8763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Tue, 18 Nov 2025 20:18:16 +0800 Subject: [PATCH 02/10] vanadium/xmonad: rewrite dynamic hooks for composability --- .../vanadium/home/xmonad/xmonad.hs | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index 701e8fcb..a9b6cd0e 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -148,27 +148,35 @@ myManageHook = ] <> namedScratchpadManageHook myScratchpads +-- TODO: is there a way to always open certain sites in new windows in firefox? +-- TODO: stop full screen when move happens myEventHandleHook :: Event -> X All myEventHandleHook = - -- TODO: is there a way to always open certain sites in new windows in firefox? - -- TODO: stop full screen when move happens - onTitleChange $ composeAll - [ isSpotify --> doShiftAndViewIfCurrent multimediaWS - , isYouTube --> doShiftAndViewIfCurrent multimediaWS - , isDiscord --> doShiftAndViewIfCurrent chatWS - , isWhatsApp --> doShiftAndViewIfCurrent chatWS - , isElement --> doShiftAndViewIfCurrent chatWS + -- If the title changes in the background, we don't want to greedy view that workspace. + -- Imagine Spotify playing in the background, a track change would focus that workspace. + -- We prevent this by checking if the window is in the current workspace + onTitleChange + $ (windowIsInCurrentWorkspace -->) + $ composeAll + [ isSpotify --> doShiftAndGreedyView multimediaWS + , isYouTube --> doShiftAndGreedyView multimediaWS + , isDiscord --> doShiftAndGreedyView chatWS + , isWhatsApp --> doShiftAndGreedyView chatWS + , isElement --> doShiftAndGreedyView chatWS ] --- | If the title changes in the background, we don't want to greedy view that workspace. --- Imagine Spotify playing in the background, a track change would focus that workspace. --- We prevent this by checking if the window is in the current workspace -doShiftAndViewIfCurrent :: WorkspaceId -> Query (Endo WindowSet) -doShiftAndViewIfCurrent n = doF . go =<< ask +doShiftAndGreedyView :: WorkspaceId -> Query (Endo WindowSet) +doShiftAndGreedyView n = doF . go =<< ask where go :: Window -> WindowSet -> WindowSet - go w s = case W.findTag w s of - Just from | from == W.currentTag s -> W.greedyView n $ W.shiftWin n w s - _ -> s + go w s = W.greedyView n $ W.shiftWin n w s + +hasProp :: (Window -> WindowSet -> Bool) -> Query Bool +hasProp f = f <$> ask <*> (liftX $ gets windowset) + +windowIsInCurrentWorkspace :: Query Bool +windowIsInCurrentWorkspace = hasProp $ \w s -> case W.findTag w s of + Just from | from == W.currentTag s -> True + _ -> False myStartupHook :: X () myStartupHook = do From 33aa3065c3eb56bdb6596aa595c153cbe92f7312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 19 Nov 2025 00:05:38 +0800 Subject: [PATCH 03/10] vanadium/xmonad: don't lose focus when hovering over float --- nix/configurations/vanadium/home/xmonad/xmonad.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index a9b6cd0e..56fd2712 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -13,6 +13,7 @@ import XMonad.Hooks.ManageHelpers import XMonad.Hooks.OnPropertyChange import XMonad.Hooks.RefocusLast import XMonad.Hooks.StatusBar +import XMonad.Layout.FocusTracking import XMonad.Layout.NoBorders import XMonad.Layout.Reflect import XMonad.Layout.Reflect.Message @@ -69,7 +70,7 @@ myLayout = $ ResizableTall 1 (1/10) (3/7) [] mag = magnifyxy 1.05 1.3 (NoMaster 3) False in avoidStruts . smartBorders $ - mag tallr ||| Full + mag tallr ||| focusTracking Full isSioyek :: Query Bool isSioyek = className =? "sioyek" From 3e603eb1e0e8bc5a014f5591c7bdb6da74d80c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 19 Nov 2025 17:22:00 +0800 Subject: [PATCH 04/10] vanadium/xmonad: make more money --- nix/configurations/vanadium/home/xmonad/xmonad.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index 56fd2712..d9859cd7 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -39,10 +39,10 @@ main = xmonad -- Fix all java things that don't scale with XMonad -- https://wiki.archlinux.org/title/java#Gray_window,_applications_not_resizing_with_WM,_menus_immediately_closing - . javaHack - . withSB xmobarConfig . docks - . setEwmhActivateHook myActivateHook - . ewmhFullscreen . ewmh + $ javaHack + $ withSB xmobarConfig . docks + $ setEwmhActivateHook myActivateHook + $ ewmhFullscreen . ewmh $ def { modMask = superMask , borderWidth = 5 @@ -69,8 +69,9 @@ myLayout = $ RTFixDescription $ ResizableTall 1 (1/10) (3/7) [] mag = magnifyxy 1.05 1.3 (NoMaster 3) False - in avoidStruts . smartBorders $ - mag tallr ||| focusTracking Full + in avoidStruts + $ smartBorders + $ mag tallr ||| focusTracking Full isSioyek :: Query Bool isSioyek = className =? "sioyek" From e7c50da45fd5e6b455b0ef5cd779bea7ce54ba4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 19 Nov 2025 20:37:50 +0800 Subject: [PATCH 05/10] vanadium/xmonad: I like ratio --- nix/configurations/vanadium/home/xmonad/xmonad.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index d9859cd7..b56b81a9 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -29,6 +29,7 @@ import XMonad.Util.SpawnOnce import XMonad.Layout.Magnifier import Data.Char.Greek +import Data.Ratio import Data.Semigroup import qualified Data.Map.Strict as M import System.Posix @@ -325,10 +326,10 @@ chatWS :: WorkspaceId chatWS = myWorkspaces !! 3 centeredFloat, smallFloat, fullFloat, buttomRightFloat :: W.RationalRect -centeredFloat = W.RationalRect (1/9) (1/9) (7/9) (7/9) -smallFloat = W.RationalRect (3/5) (3/5) (2/7) (2/7) +centeredFloat = W.RationalRect (1%9) (1%9) (7%9) (7%9) +smallFloat = W.RationalRect (3%5) (3%5) (2%7) (2%7) fullFloat = W.RationalRect 0 0 1 1 -buttomRightFloat = W.RationalRect (1/2) (1/2) (1/2) (1/2) +buttomRightFloat = W.RationalRect (1%2) (1%2) (1%2) (1%2) xmobarConfig :: StatusBarConfig xmobarConfig = statusBarProp "xmobar -x 0" (pure myPrettyPrinter) From 58e39ea0a640fed64179e7acf4a7fd053f06eb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 19 Nov 2025 20:47:55 +0800 Subject: [PATCH 06/10] vanadium/xmobar: remove a few clocks --- nix/configurations/vanadium/home/xmobar/xmobar.hs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/nix/configurations/vanadium/home/xmobar/xmobar.hs b/nix/configurations/vanadium/home/xmobar/xmobar.hs index 29a159fc..2d5d5fa8 100644 --- a/nix/configurations/vanadium/home/xmobar/xmobar.hs +++ b/nix/configurations/vanadium/home/xmobar/xmobar.hs @@ -62,10 +62,8 @@ config = , commands = [ Run $ DateZone "%a %d %H:%M:%S" "" "" "hereClock" (1 &second) - , Run $ DateZone "%H:%M" "" "America/Aruba" "arubaClock" (10 &second) , Run $ DateZone "%H:%M" "" "Europe/Dublin" "dublinClock" (10 &second) - , Run $ DateZone "%H:%M" "" "America/New_York" "newYorkClock" (10 &second) - , Run $ DateZone "%H:%M" "" "Europe/Paris" "cetClock" (10 &second) + , Run $ DateZone "%H:%M" "" "Europe/Paris" "parisClock" (10 &second) , Run $ DateZone "%H:%M" "" "Asia/Taipei" "tstClock" (10 &second) , Run $ Com @@ -125,10 +123,8 @@ config = <> alignSep config <> intercalate "|" [ (unwords . map greyFg) - [ "[AUA: %arubaClock%]" - , "[DUB: %dublinClock%]" - , "[JFK: %newYorkClock%]" - , "[CDG: %cetClock%]" + [ "[DUB: %dublinClock%]" + , "[CDG: %parisClock%]" , "[TPE: %tstClock%]" ] <> " " From 112439418c2918663079e16fe8f92c2fc9bc2609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 19 Nov 2025 21:09:14 +0800 Subject: [PATCH 07/10] vanadium/xmobar: fix some events --- nix/configurations/vanadium/home/xmobar/xmobar.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nix/configurations/vanadium/home/xmobar/xmobar.hs b/nix/configurations/vanadium/home/xmobar/xmobar.hs index 2d5d5fa8..a4958817 100644 --- a/nix/configurations/vanadium/home/xmobar/xmobar.hs +++ b/nix/configurations/vanadium/home/xmobar/xmobar.hs @@ -74,8 +74,7 @@ config = , "--target", "2025-09-16=snip snip" , "--target", "2025-10-13=no teef" , "--target", "2025-10-31=dragon book" - , "--target", "2025-11-21=scalpel" - , "--target", "2025-11-21=baguette" + , "--target", "2025-11-19=scalpel" , "--target", "2025-11-29=à deux" , "--target", "2025-12-16=dragon book" , "--target", "2025-12-30=seule" From d3489e573079138ff2bfb297772ef58c6f789d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 19 Nov 2025 21:38:44 +0800 Subject: [PATCH 08/10] vanadium: use asFlake attribute --- nix/configurations/vanadium.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/configurations/vanadium.nix b/nix/configurations/vanadium.nix index 725c460f..80919604 100644 --- a/nix/configurations/vanadium.nix +++ b/nix/configurations/vanadium.nix @@ -125,7 +125,7 @@ in (sources.agenix + "/modules/age.nix") - (import sources.url-eater).nixosModules.default + sources.url-eater.asFlake.nixosModules.default (sources.nixos-hardware + "/framework/13-inch/7040-amd") @@ -190,7 +190,7 @@ in # Extern modules # (sources.agenix + "/modules/age-home.nix") - (import sources.wired-notify).homeManagerModules.default + sources.wired-notify.asFlake.homeManagerModules.default ]; } From 60bfd4f5c9124cd6f2da6c7101d18f695e2b5889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Thu, 20 Nov 2025 09:16:43 +0800 Subject: [PATCH 09/10] vanadium/xmonad: show current window count in pp --- .../vanadium/home/xmonad/leanamonad.cabal | 1 - .../Layout/ResizableTile/FixDescription.hs | 23 ---------------- .../vanadium/home/xmonad/xmonad.hs | 26 +++++++++++-------- 3 files changed, 15 insertions(+), 35 deletions(-) delete mode 100644 nix/configurations/vanadium/home/xmonad/lib/XMonad/Layout/ResizableTile/FixDescription.hs diff --git a/nix/configurations/vanadium/home/xmonad/leanamonad.cabal b/nix/configurations/vanadium/home/xmonad/leanamonad.cabal index 250a2d53..bfe56163 100644 --- a/nix/configurations/vanadium/home/xmonad/leanamonad.cabal +++ b/nix/configurations/vanadium/home/xmonad/leanamonad.cabal @@ -25,7 +25,6 @@ library hs-source-dirs: lib exposed-modules: XMonad.Layout.Reflect.Message - XMonad.Layout.ResizableTile.FixDescription Data.Char.Greek executable leanamonad diff --git a/nix/configurations/vanadium/home/xmonad/lib/XMonad/Layout/ResizableTile/FixDescription.hs b/nix/configurations/vanadium/home/xmonad/lib/XMonad/Layout/ResizableTile/FixDescription.hs deleted file mode 100644 index 19153c17..00000000 --- a/nix/configurations/vanadium/home/xmonad/lib/XMonad/Layout/ResizableTile/FixDescription.hs +++ /dev/null @@ -1,23 +0,0 @@ -{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} - -module XMonad.Layout.ResizableTile.FixDescription - ( RTFixDescription(..) - ) where - -import XMonad -import qualified XMonad.StackSet as W -import XMonad.Layout.ResizableTile - -newtype RTFixDescription a = RTFixDescription { unwrapRT :: ResizableTall a } - deriving (Read, Show) - -instance LayoutClass RTFixDescription a where - runLayout (W.Workspace t l s) = - let ws' = W.Workspace t (unwrapRT l) s - in (fmap . fmap . fmap) RTFixDescription . runLayout ws' - - handleMessage (RTFixDescription l) = - (fmap . fmap) RTFixDescription . handleMessage l - - description (RTFixDescription l) = - description l <> " " <> show (_nmaster l) diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index b56b81a9..76fe99af 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -19,7 +19,6 @@ import XMonad.Layout.Reflect import XMonad.Layout.Reflect.Message import XMonad.Layout.Renamed import XMonad.Layout.ResizableTile -import XMonad.Layout.ResizableTile.FixDescription import XMonad.Layout.Spacing import qualified XMonad.StackSet as W import XMonad.Util.EZConfig @@ -64,10 +63,9 @@ main = `additionalKeys` keybinds myLayout = - let tallr = renamed [ KeepWordsRight 2 ] {- keep "ResizableTall n" -} + let tallr = renamed [ Replace "Tall" ] $ smartSpacingWithEdge 5 $ reflectMsg . reflectHoriz - $ RTFixDescription $ ResizableTall 1 (1/10) (3/7) [] mag = magnifyxy 1.05 1.3 (NoMaster 3) False in avoidStruts @@ -332,15 +330,21 @@ fullFloat = W.RationalRect 0 0 1 1 buttomRightFloat = W.RationalRect (1%2) (1%2) (1%2) (1%2) xmobarConfig :: StatusBarConfig -xmobarConfig = statusBarProp "xmobar -x 0" (pure myPrettyPrinter) +xmobarConfig = statusBarProp "xmobar -x 0" myPrettyPrinter where - myPrettyPrinter = - filterOutWsPP [scratchpadWorkspaceTag] - $ def - { ppCurrent = xmobarColor "#000000" "#ffffff" . wrap " " " " . fmap toUpper - , ppHiddenNoWindows = xmobarColor "#9c9c9c" "" . const "⋅" - , ppSep = " | " - } + windowCount :: X Int + windowCount = gets $ length . W.integrate' . W.stack . W.workspace . W.current . windowset + + myPrettyPrinter :: X PP + myPrettyPrinter = do + wCount <- windowCount + pure + $ filterOutWsPP [scratchpadWorkspaceTag] + $ def + { ppCurrent = xmobarColor "#000000" "#ffffff" . wrap " " " " . ( <> ":" <> show wCount) + , ppHiddenNoWindows = xmobarColor "#9c9c9c" "" . const "⋅" + , ppSep = " | " + } myScratchpads :: [NamedScratchpad] myScratchpads = From b8f78260b3743f7636f082021959d60015944fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Thu, 20 Nov 2025 10:36:39 +0800 Subject: [PATCH 10/10] vanadium/xmonad: show current window count in pp --- .../vanadium/home/xmonad/xmonad.hs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index 76fe99af..8a0e721c 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -27,6 +27,7 @@ import XMonad.Util.NamedScratchpad import XMonad.Util.SpawnOnce import XMonad.Layout.Magnifier +import Data.Function import Data.Char.Greek import Data.Ratio import Data.Semigroup @@ -332,17 +333,31 @@ buttomRightFloat = W.RationalRect (1%2) (1%2) (1%2) (1%2) xmobarConfig :: StatusBarConfig xmobarConfig = statusBarProp "xmobar -x 0" myPrettyPrinter where - windowCount :: X Int - windowCount = gets $ length . W.integrate' . W.stack . W.workspace . W.current . windowset + mkPpCurrent :: X (String -> String) + mkPpCurrent = do + windowCount <- gets $ length . W.integrate' . W.stack . W.workspace . W.current . windowset + pure $ \wid -> + wid <> (if windowCount > 1 then ":" <> show windowCount else mempty) + & xmobarColor "#000000" "#ffffff" . wrap " " " " + + mkPpHidden :: X (String -> String) + mkPpHidden = do + m <- gets $ M.fromList . map (\x -> (W.tag x, length . W.integrate' . W.stack $ x)) . W.hidden . windowset + pure $ \wid -> + let windowCount = m M.! wid + in wid <> (if windowCount > 1 then ":" <> show windowCount else mempty) + & xmobarColor "#ffffff" "" myPrettyPrinter :: X PP myPrettyPrinter = do - wCount <- windowCount + myPpCurrent <- mkPpCurrent + myPpHidden <- mkPpHidden pure $ filterOutWsPP [scratchpadWorkspaceTag] $ def - { ppCurrent = xmobarColor "#000000" "#ffffff" . wrap " " " " . ( <> ":" <> show wCount) + { ppCurrent = myPpCurrent , ppHiddenNoWindows = xmobarColor "#9c9c9c" "" . const "⋅" + , ppHidden = myPpHidden , ppSep = " | " }