开发者

Finding the number of X11 screens from Haskell

开发者 https://www.devze.com 2023-02-23 01:20 出处:网络
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 si开发者_如何学Python

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 si开发者_如何学Pythonngle 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.


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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号