[XMonad] Rewrite getClass using the applicative style

This commit is contained in:
Ivan Malison 2016-11-25 15:09:07 -08:00
parent 57b6f72b84
commit 31d039b0b2
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -216,17 +216,14 @@ myWindowBringerConfig =
, windowTitler = myDecorateName
}
classIfMatches window entry = do
result <- runQuery (fst entry) window
return $ if result then Just $ snd entry else Nothing
classIfMatches window entry =
ifL (Just $ snd entry) Nothing <$> runQuery (fst entry) window
getClass w = do
virtualClass <- findM (classIfMatches w) virtualClasses
case virtualClass of
Nothing -> do
classHint <- withDisplay $ \d -> io $ getClassHint d w
return $ resClass classHint
Just name -> return name
getClassRaw w = fmap resClass $ withDisplay $ io . flip getClassHint w
getVirtualClass = flip findM virtualClasses . classIfMatches
getClass w = fromMaybe <$> getClassRaw w <*> getVirtualClass w
myDecorateName ws w = do
name <- show <$> getName w