简体   繁体   中英

Get active window title in X11 Haskell library

I am trying to extract the title of the currently active window using X11 library.

I was trying to inspire myself with the xdotool code but I got stuck after getWindowProperty32 returned Foreign.C.Types.CLong that I couldn't handle in any way.

I know I could just create a new process with xdotool and read its output, but this is not the thing I am going to achieve. How can I do it via direct X server communication in Haskell?

This is possible using getInputFocus and fetchName .

The code would look something like

getActiveWindowTitle :: Display -> IO (Maybe String)
getActiveWindowTitle display = do
  (window, _) = getInputFocus display
  fetchName display window

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM