I want to automatically assign windows of Intellij Idea projects to specific workspaces in xmonad. I tried the following in my xmonad.hs:

myManageHook = composeAll . concat $
                  [  [ fmap (c `isInfixOf`) title  --> doShift "5:lp" | c <- myLP]
                   , [ fmap (c `isInfixOf`) title  --> doShift "2:amq-svc" | c <- myAmq]
                   , [ fmap (c `isInfixOf`) title  --> doShift "3:testfwks" | c <- myTest]
                   ]
                  
                   where myLP = ["lp-intellij"]
                         myAmq = ["msg-svc-intellij"]
                         myTest = ["testframeworks"]

However, it seems when a Intellij window is started at first the title is just "Intellij" and does not contain the projects name, so xmonad does not shift the window to the workspace. Is it possible to execute this hook when a title of a window changes, so that the projects are assigned automatically to its workspace?