diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2022-11-21 22:14:50 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-11-21 22:14:50 -0700 |
| commit | 80057a6ed33f07f3a91a7a1d3552b222804b5d9e (patch) | |
| tree | 249b2cda2074991adead57843d77db9d475bb514 /src/Rahm/Desktop/Keys.hs | |
| parent | 8888a83ef06d16d4bdd3c06bef721fff43f04175 (diff) | |
| download | rde-80057a6ed33f07f3a91a7a1d3552b222804b5d9e.tar.gz rde-80057a6ed33f07f3a91a7a1d3552b222804b5d9e.tar.bz2 rde-80057a6ed33f07f3a91a7a1d3552b222804b5d9e.zip | |
Rudimentary pending buffer shown in Xmobar.
Diffstat (limited to 'src/Rahm/Desktop/Keys.hs')
| -rw-r--r-- | src/Rahm/Desktop/Keys.hs | 114 |
1 files changed, 64 insertions, 50 deletions
diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs index 0ab868f..e55c636 100644 --- a/src/Rahm/Desktop/Keys.hs +++ b/src/Rahm/Desktop/Keys.hs @@ -13,7 +13,7 @@ import Data.List hiding ((!!)) import Data.List.Safe ((!!)) import Data.Map (Map) import qualified Data.Map as Map -import Data.Maybe (fromMaybe, isJust, mapMaybe) +import Data.Maybe (fromMaybe, isJust, mapMaybe, isNothing) import Data.Monoid (Endo (..)) import Data.Proxy import Debug.Trace @@ -46,6 +46,7 @@ import Rahm.Desktop.Swallow import Rahm.Desktop.SwapMaster (swapMaster) import Rahm.Desktop.Theater import Rahm.Desktop.Workspaces +import Rahm.Desktop.XMobarLog.PendingBuffer import System.IO import System.Process import Text.Printf @@ -154,11 +155,13 @@ keymap = runKeys $ do forM_ [xK_apostrophe, xK_w] $ \k -> bind k $ do justMod $ doc "Jumps between marks." $ - runMaybeT_ $ do - l <- readNextLocationSet - case l of - (h : _) -> lift (focusLocation h) - _ -> return () + withPendingBuffer $ do + setPendingBuffer "Jump To " + runMaybeT_ $ do + l <- readNextLocationSet + case l of + (h : _) -> lift (focusLocation h) + _ -> return () bind xK_BackSpace $ do -- The only raw keybinding. Meant to get a terminal to unbrick XMonad if @@ -293,15 +296,19 @@ keymap = runKeys $ do \_: Black hole. Sending a window here closes it.\n\n\t\ \Other keybindings starting with H-g\n\t\t\ \F1: display this help.\n\n\t" - $ runMaybeT_ $ (lift . gotoWorkspaceFn) =<< readNextWorkspace + $ withPendingBuffer $ do + setPendingBuffer "Goto " + runMaybeT_ $ (lift . gotoWorkspaceFn) =<< readNextWorkspace controlMod $ doc "Restore the desktop marked with the next typed character." $ - runMaybeT_ $ do - mapNextString $ \_ str -> lift $ - case str of - [ch] | isAlpha ch -> restoreDesktop [ch] - _ -> return () + withPendingBuffer $ do + setPendingBuffer "Restore " + runMaybeT_ $ do + mapNextString $ \_ str -> lift $ + case str of + [ch] | isAlpha ch -> restoreDesktop [ch] + _ -> return () -- shiftMod $ -- doc "Swap a workspace with another workspace." $ @@ -311,12 +318,14 @@ keymap = runKeys $ do shiftMod $ doc "Restore a theater state" $ - runMaybeT_ $ do - mapNextString $ \_ str -> lift $ - case str of - [ch] | isAlpha ch -> restoreTheater (Just [ch]) - [' '] -> restoreTheater Nothing - _ -> return () + withPendingBuffer $ do + setPendingBuffer "Goto Theater" + runMaybeT_ $ do + mapNextString $ \_ str -> lift $ + case str of + [ch] | isAlpha ch -> restoreTheater (Just [ch]) + [' '] -> restoreTheater Nothing + _ -> return () bind xK_n $ do justMod $ @@ -426,14 +435,17 @@ keymap = runKeys $ do bind xK_m $ do justMod $ doc "Mark the current window with the next typed character." $ do - locs <- fromMaybe [] <$> runMaybeT readNextLocationSet - let wins = mapMaybe locationWindow locs - withBorderColor "#00ffff" wins $ do - runMaybeT_ $ do - mapNextString $ \_ str -> lift $ - case str of - [ch] | isAlpha ch -> markAllLocations str locs - _ -> return () + withPendingBuffer $ do + addStringToPendingBuffer "Mark " + locs <- fromMaybe [] <$> runMaybeT readNextLocationSet + let wins = mapMaybe locationWindow locs + unless (null wins) $ do + withBorderColor "#00ffff" wins $ do + runMaybeT_ $ do + mapNextString $ \_ str -> lift $ + case str of + [ch] | isAlpha ch -> markAllLocations str locs + _ -> return () shiftMod $ doc "Mark the current desktop with the next typed character." $ @@ -487,31 +499,33 @@ keymap = runKeys $ do then "Swap a windowset with another windowset." else "Shift a windowset to a workspace" ) - $ do - locations <- fromMaybe [] <$> runMaybeT readNextLocationSet - let locationWindows = mapMaybe locationWindow locations - - withBorderColor "#00ffff" locationWindows $ do - runMaybeT_ $ do - if doSwap - then do - otherWindows <- + $ withPendingBuffer $ do + setPendingBuffer $ if doSwap then "Swap " else "Shift " + maybeLocs <- runMaybeT readNextLocationSet + + forM_ maybeLocs $ \locations -> do + let locationWindows = mapMaybe locationWindow locations + withBorderColor "#00ffff" locationWindows $ do + runMaybeT_ $ do + if doSwap + then do + otherWindows <- + lift $ + mapMaybe locationWindow . fromMaybe [] + <$> runMaybeT readNextLocationSet lift $ - mapMaybe locationWindow . fromMaybe [] - <$> runMaybeT readNextLocationSet - lift $ - windows $ - W.swapWindows (zip locationWindows otherWindows) - else do - workspace <- readNextWorkspace - mapM_ (lift . moveLocationToWorkspaceFn workspace) locations - - lift $ setAlternateWindows locationWindows - forM_ locations $ \loc -> - case locationWindow loc of - Nothing -> return () - Just win -> do - lift $ setAlternateWorkspace win (locationWorkspace loc) + windows $ + W.swapWindows (zip locationWindows otherWindows) + else do + workspace <- readNextWorkspace + mapM_ (lift . moveLocationToWorkspaceFn workspace) locations + + lift $ setAlternateWindows locationWindows + forM_ locations $ \loc -> + case locationWindow loc of + Nothing -> return () + Just win -> do + lift $ setAlternateWorkspace win (locationWorkspace loc) altMod $ spawnX "sudo -A systemctl suspend && xsecurelock" |