xmonadxfce

Shift/send individual chrome tabs to different workspaces


In my xmonad.hs on xfce4, when eg emacs starts, it goes to my first workspace with a manageHook like so: className =? "emacs" --> doF(W.shift(myWorkspaces !! 1)). That's dandy, and I can similarly send "google-chrome" to a single workspace. But, with chrome I want to differentiate at the "tab" level as opposed to the "app" level. Looking at xprop, I see it returns "google-chrome" for WM_CLASS and no other interesting differentiating properties for any given tab. I'd like to send my google-chrome "hosted" calendar to one workspace, etc perhaps as a function of the title of the tab (or whatever).

Is there a clever way to do this? Perhaps I'm missing a monad? Just kidding.


Solution

  • You can indeed find it by the window title. I've got some code you could look at here:

    https://github.com/chrissound/XMonadLayouts/blob/master/lib/WindowFinder.hs

    So something like the below might work:

    , ((modm, xK_n), submap . M.fromList $ [ -- navigate to program
                    (singleKey xK_b, do
                        win' <- findWindowsInCurrentWorkspaceByTitlePrefix ("chrome something")
                        when (length win' > 0)
                          ((windows $ W.focusWindow $ head win') >> W.shift(myWorkspaces !! 1))
    
                    )