diff options
| author | Josh Rahm <rahm@google.com> | 2023-12-13 12:40:15 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2023-12-13 12:40:15 -0700 |
| commit | 2604f0608d176d89a4e307c90a5f904b8d06921a (patch) | |
| tree | eb9c734597c2338c86d0ca7f4d4a05dab43e62f2 /src/Rahm/Desktop/Common.hs | |
| parent | 4cdab9f06cd0ecf5ad7d5ee15dd83c4dc4eb396a (diff) | |
| download | rde-2604f0608d176d89a4e307c90a5f904b8d06921a.tar.gz rde-2604f0608d176d89a4e307c90a5f904b8d06921a.tar.bz2 rde-2604f0608d176d89a4e307c90a5f904b8d06921a.zip | |
Add multi-select Rofi support and allow multiselect for windows.
Diffstat (limited to 'src/Rahm/Desktop/Common.hs')
| -rw-r--r-- | src/Rahm/Desktop/Common.hs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Rahm/Desktop/Common.hs b/src/Rahm/Desktop/Common.hs index c10dd64..44587d3 100644 --- a/src/Rahm/Desktop/Common.hs +++ b/src/Rahm/Desktop/Common.hs @@ -31,13 +31,14 @@ import Control.Monad.Trans.Identity (IdentityT (..)) import Control.Monad.Trans.Maybe (MaybeT (..)) import Data.Char (toLower) import Data.Either (either) -import Data.List (concatMap, head, isInfixOf, map, (++)) +import Data.List (concatMap, isInfixOf, map, (++)) +import Data.List.Safe (head, tail) import Data.List.Split (splitOn) import qualified Data.Map as Map (fromListWith) import Data.Maybe (Maybe (..), maybe) import Data.Void (Void (..), absurd) import Data.Word (Word32) -import Rahm.Desktop.DMenu (runDMenuPromptWithMap) +import Rahm.Desktop.DMenu (runDMenuPromptWithMap, runDMenuPromptWithMapMulti) import Rahm.Desktop.Logger import qualified Rahm.Desktop.StackSet as S ( Screen (Screen, workspace), @@ -79,6 +80,7 @@ import qualified XMonad.Hooks.ManageHelpers as X import XMonad.Prompt (XPrompt (commandToComplete, showXPrompt)) import qualified XMonad.Util.Run as X import XMonad.Util.XUtils (pixelToString, stringToPixel) +import Prelude hiding (head, tail) -- A location is a workspace and maybe a window with that workspace. data Location = Location @@ -126,15 +128,18 @@ getString = runQuery $ do then t else printf "%s - %s" t a -askWindowId :: X (Maybe [Window]) +askWindowId :: X [Window] askWindowId = do windowTitlesToWinId <- withWindowSet $ \ss -> Map.fromListWith (++) <$> mapM (\wid -> (,) <$> getString wid <*> return [wid]) (S.allWindows ss) - runDMenuPromptWithMap "Window" (Just "#f542f5") windowTitlesToWinId + concat <$> runDMenuPromptWithMapMulti "Window" (Just "#f542f5") windowTitlesToWinId windowJump :: X () -windowJump = mapM_ (focus . head) =<< askWindowId +windowJump = mapM_ focus . headM =<< askWindowId + where + headM :: [a] -> Maybe a + headM = head withBorderWidth :: Int -> [Window] -> X a -> X a withBorderWidth width ws fn = do |