diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2026-03-01 15:50:03 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2026-03-01 15:50:03 -0700 |
| commit | 9839efd016f43c892e935c7d4063e30c23b81e1f (patch) | |
| tree | 0431ff646b7a273f6a40e04ebe40931faafdcbd1 /src | |
| parent | 2bcd8842dab3a8e62b5ad7cba6cbfbe3fc648f0d (diff) | |
| download | rde-9839efd016f43c892e935c7d4063e30c23b81e1f.tar.gz rde-9839efd016f43c892e935c7d4063e30c23b81e1f.tar.bz2 rde-9839efd016f43c892e935c7d4063e30c23b81e1f.zip | |
[feat] change <M-a> behaivor. Add {} motions.
<M-a> now iterates through the screens as they're ordered. (top-bottom,
left-right).
} - new workspace motion to go through visibly ordered workspaces
{ - reverse of }
Diffstat (limited to 'src')
| -rw-r--r-- | src/Rahm/Desktop/Keys.hs | 18 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Keys/Wml.hs | 16 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Workspaces.hs | 37 |
3 files changed, 61 insertions, 10 deletions
diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs index 4a2a426..77c3ca3 100644 --- a/src/Rahm/Desktop/Keys.hs +++ b/src/Rahm/Desktop/Keys.hs @@ -1,5 +1,6 @@ module Rahm.Desktop.Keys (applyKeys) where +import Control.Applicative import Control.Monad ( filterM, forM_, @@ -59,6 +60,7 @@ import Rahm.Desktop.Common setBorderWidth, ) import Rahm.Desktop.DMenu (runDMenu) +import Rahm.Desktop.Dragging (windowsUnderCursor) import qualified Rahm.Desktop.Dragging as D import Rahm.Desktop.History ( historyBack, @@ -66,9 +68,9 @@ import Rahm.Desktop.History jumpToLastLocation, ) import Rahm.Desktop.Keys.Dsl2 -import Rahm.Desktop.Keys.Local import Rahm.Desktop.Keys.Grab (KeySymOrKeyCode (..)) import Rahm.Desktop.Keys.KeyFeed (execKeyFeed, liftXToFeed, pushKey, runKeyFeed, runKeyFeedX) +import Rahm.Desktop.Keys.Local import Rahm.Desktop.Keys.Wml import Rahm.Desktop.Layout (nLayouts) import Rahm.Desktop.Layout.ConsistentMosaic @@ -150,8 +152,6 @@ import XMonad.Layout.Spacing import XMonad.Util.Run (hPutStrLn, safeSpawn, spawnPipe) import XMonad.Util.WindowProperties import Prelude hiding ((!!)) -import Rahm.Desktop.Dragging (windowsUnderCursor) -import Control.Applicative type KeyMap l = XConfig l -> Map (KeyMask, KeySym) (X ()) @@ -166,11 +166,11 @@ safeSpawnX = safeSpawn selectedWindowsColor = BorderColor "#00ffff" "#00ffff" decreaseVolume = do - wins <- (<|>[0]) <$> windowsUnderCursor + wins <- (<|> [0]) <$> windowsUnderCursor spawnX $ printf "set-app-volume.sh %d --down" (head wins) increaseVolume = do - wins <- (<|>[0]) <$> windowsUnderCursor + wins <- (<|> [0]) <$> windowsUnderCursor spawnX $ printf "set-app-volume.sh %d --up" (head wins) playPause = spawnX "media-control play" @@ -428,16 +428,16 @@ bindings = do bind xK_a $ do justMod $ - doc "Cycle focus forward through the screens. (Synonymous with f,.)" $ do + doc "Cycle focus to the next workspace in ordered list. (Synonymous with }.)" $ do runMaybeT_ $ do - ws' <- workspaceForStringT ",." + ws' <- workspaceForStringT "}." ws <- MaybeT . return $ workspaceName ws' lift $ windows $ W.view ws shiftMod $ - doc "Cycle focus backward through the screens. (Synonymous with f;.)" $ do + doc "Cycle focus to the previous workspace in ordered list. (Synonymous with {.)" $ do runMaybeT_ $ do - ws' <- workspaceForStringT ";." + ws' <- workspaceForStringT "{." ws <- MaybeT . return $ workspaceName ws' lift $ windows $ W.view ws diff --git a/src/Rahm/Desktop/Keys/Wml.hs b/src/Rahm/Desktop/Keys/Wml.hs index 00c8139..e64c6e0 100644 --- a/src/Rahm/Desktop/Keys/Wml.hs +++ b/src/Rahm/Desktop/Keys/Wml.hs @@ -12,6 +12,8 @@ -- &z!~@,,^ // The window tagged with z and The last window on the screen third from the top (in reading order) -- @@s // All the windows that share a workspace with the window tagged s -- \%@s // All windows except those on workspace 's' +-- }. // The next workspace in ordered list (top-to-bottom, left-to-right) +-- {x // The previous workspace in ordered list (x cannot be hidden workspace *) module Rahm.Desktop.Keys.Wml ( readWorkspaceMacro, readWindowsetMacro, @@ -45,7 +47,7 @@ module Rahm.Desktop.Keys.Wml ) where -import Control.Monad (forM_, join, void, when) +import Control.Monad (forM_, join, void, when, (<=<)) -- getMostRecentLocationInHistory, -- pastHistory, @@ -556,6 +558,18 @@ readNextWorkspace = ws <- readNextWorkspaceName hoistMaybeT $ justWorkspace <$> getWorkspaceToTheLeft ws + -- Next workspace in ordered list (top-to-bottom, left-to-right) + (_, _, "}") -> do + ws <- readNextWorkspaceName + lift1 (return . justWorkspace <=< getNextWorkspaceInOrder) ws + -- Previous workspace in ordered list (top-to-bottom, left-to-right) + (_, _, "{") -> do + ws <- readNextWorkspaceName + -- If workspace is hidden (tagged with "*"), return Nothing + if ws == "*" + then feedFail + else lift1 (return . justWorkspace <=< getPrevWorkspaceInOrder) ws + -- The workspace with the searched for window. (_, _, "/") -> justWorkspace diff --git a/src/Rahm/Desktop/Workspaces.hs b/src/Rahm/Desktop/Workspaces.hs index 50a04d2..96e4d99 100644 --- a/src/Rahm/Desktop/Workspaces.hs +++ b/src/Rahm/Desktop/Workspaces.hs @@ -18,6 +18,8 @@ module Rahm.Desktop.Workspaces getWorkspaceToTheLeft, getWorkspaceAbove, getWorkspaceBelow, + getNextWorkspaceInOrder, + getPrevWorkspaceInOrder, WorkspaceState (..), ) where @@ -142,6 +144,41 @@ adjacentWorkspace (Selector selector) from = let tags = sort $ W.tag . snd <$> getPopulatedWorkspaces ss in return $ fromMaybe from $ selector (== from) tags +getNextWorkspaceInOrder :: WorkspaceId -> X WorkspaceId +getNextWorkspaceInOrder from = + withWindowSet $ \ss -> + let screens = getOrderedScreens ss + tags = map (W.tag . W.workspace . snd) screens + tagsWithHidden = map (W.tag . snd) $ getPopulatedWorkspaces ss + orderedTags = filter (\t -> t `elem` tagsWithHidden) tags + getIndex [] _ = Nothing + getIndex (x : xs) target = + if x == target + then + if null xs + then Just $ head orderedTags -- wrap around + else Just $ head xs + else getIndex xs target + in return $ fromMaybe from $ getIndex orderedTags from + +getPrevWorkspaceInOrder :: WorkspaceId -> X WorkspaceId +getPrevWorkspaceInOrder from = + withWindowSet $ \ss -> + let screens = getOrderedScreens ss + tags = map (W.tag . W.workspace . snd) screens + tagsWithHidden = map (W.tag . snd) $ getPopulatedWorkspaces ss + orderedTags = filter (\t -> t `elem` tagsWithHidden) tags + reverseTags = reverse orderedTags + getIndex [] _ = Nothing + getIndex (x : xs) target = + if x == target + then + if null xs + then Just $ head reverseTags -- wrap around + else Just $ head xs + else getIndex xs target + in return $ fromMaybe from $ getIndex reverseTags from + viewAdjacent :: Selector -> X () viewAdjacent sel = gotoWorkspace =<< (adjacentWorkspaceNotVisible sel =<< getCurrentWorkspace) |