[xmonad] Use atomic window props in window manage hook

Eric Mrak mail at ericmrak.info
Thu Dec 11 17:53:27 UTC 2014


This is what I use for checking for _NET_WM_WINDOW_TYPE_DIALOG atoms:

import Foreign.C.Types (CLong)

checkDialog :: Query Bool
checkDialog = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DIALOG"

checkAtom :: String -> String -> Query Bool
checkAtom name value = ask >>= \w -> liftX $ do
                a <- getAtom name
                val <- getAtom value
                mbr <- getProp w a
                case mbr of
                  Just [r] -> return $ elem (fromIntegral r) [val]
                  _ -> return False

-- | Helper to read a property
getProp :: Window -> Atom -> X (Maybe [CLong])
getProp w a = withDisplay $ \dpy -> io $ getWindowProperty32 dpy a w

You would probably change checkDialog to use checkAtom "_NET_WM_STATE"
"_NET_WM_STATE_ABOVE"
I would credit the original author I stole this from, but I can't seem to
find it again.

Hope this helps and isn't simply reproducing what you've already tried :)

On Thu, Dec 11, 2014 at 11:21 AM, Chris Bell <cwbell at mail.usf.edu> wrote:

> Hi, all
>
> I was wondering, how could I set a window to float based on its atomic
> window properties? I'm running Xmonad raw on top of X on Fedora 20; no DE.
> According to xprop, the only 'special' property of this window is:
>
> _NET_WM_STATE(ATOM) = _NET_WM_STATE_ABOVE, _NET_WM_STATE_STICKY
>
> particularly the STATE_ABOVE property. So far, I haven't found a reliable
> way to extract and check if this property exists is set within a mange
> hook. I've tried pulling the entire property as a stringProperty - and
> later as an atomic using getAtom - and looking for my string with IsInfixOf
> (but I think that was pretty misguided, since it wouldn't compile), and
> I've tried checking against:
>
> ( isInProperty "_NET_WM_STATE" "_NET_WM_STATE_ABOVE" )
>
> and have also tried it with "_NET_WM_STATE(ATOM)". I don't get any compile
> errors, but... it doesn't automatically  float the windows, either. I
> apologize if it's something simple I'm overlooking - I've found the Haskell
> difficulty curve to be more extreme than any other language I've worked
> with. With the possible exception of Matlab.
>
> The window is one of those fancy special new "panel" not-windows that
> Chrome is implementing; it's for the Hangouts extension with 'enable
> panels' turned on in chrome://flags/#enable-panels. They're frustrating,
> because Chrome can actually handle them as dockable internal window,
> docking them at the bottom of the browser. Or it can be handled by the OS
> WM. All of the window properties are identical to a normal Chrome window,
> except the STATE_ABOVE flag, so that's all I can think to use.
>
> Any suggestions are more than welcome.
>
> Regards,
>
> Chris Bell
>
> Ph.D. Candidate, Teaching Assistant, Gentleman, Scholar, Penguin Wrangler
> University of South Florida
> College of Engineering
> Department of Computer Science and Engineering
> NarMOS Research Team, Official Daemon Charmer
>
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org
> http://www.haskell.org/mailman/listinfo/xmonad
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20141211/a2564d08/attachment.html>


More information about the xmonad mailing list