Finding the number of X11 screens from Haskell

浪子不回头ぞ 提交于 2019-12-01 07:42:35

问题


I'd like to know how many X screens the current machine has, to make my .xmonad a little more general; I have a netbook as well as a desktop with two monitors, and I use several single monitored machines too.

To this end, I'd like to be able to find out how many X screens the current machine has. (I think screens is the correct words, I mean physical monitors).

The reason being is that I want multiple instances of xmobar, one per monitor. I've hard coded it to be on two at the moment.


回答1:


If you use the X11 package:

 import Graphics.X11.Xinerama (getScreenInfo)

that will dynamically return a list of Rectangles, telling you how many screens, and their dimensions.




回答2:


For the curious, I ended up using

 screenCount :: X Int  
 screenCount = withDisplay (io.fmap length.getScreenInfo)

I also found out that the XMonad module has a function

 screenCount :: Display -> Foreign.C.Types.CInt


来源:https://stackoverflow.com/questions/5607326/finding-the-number-of-x11-screens-from-haskell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!