Search code examples
xmonad

How to paint a arbitrary window with Xmonad?


{-# OPTIONS -Wno-unused-imports #-}
{-# OPTIONS -Wno-type-defaults #-}
module MyDraw where

import XMonad.Util.XUtils
import XMonad
import XMonad.Config.Prime
import XMonad.Util.Font

doStuff :: X ()
doStuff = do
  let myRec = Rectangle 100 100 300 300
  w <- createNewWindow  myRec Nothing "blue" True
  fs <- initXMF "xft:Droid Sans Mono for Powerline.otf: Droid Sans Mono for Powerline:style=Regular:size=32"
  paintAndWrite w fs (fromIntegral 120) (fromIntegral 120) (fromIntegral 10)
    "green" "blue" "black"  "white" [AlignCenter, AlignCenter] ["Testing", "123"]

I'm trying to paint an arbitrary window using Xmonad, I'm using the above code, though it doesn't seem to do anything? How can I debug this further?

I'm invoking the above code with a keybinding. I'm fairly certain it's running as I have some print code running successfully after it. In other words:

            doStuff
            liftIO $ logToTmpFile "done"

Solution

  • I needed to showWindow w:

    doStuff :: X ()
    doStuff = do
      let myRec = Rectangle 100 100 300 300
      w <- createNewWindow  myRec Nothing "blue" True
      showWindow w
      fs <- initXMF "xft:Droid Sans Mono for Powerline.otf: Droid Sans Mono for Powerline:style=Regular:size=32"
      paintAndWrite w fs (fromIntegral 120) (fromIntegral 120) (fromIntegral 10)
        "green" "blue" "black"  "white" [AlignCenter, AlignCenter] ["Testing", "123"]