Discussion:
[xmonad] Get width and height of current screen ?
e***@gmail.com
2016-12-08 02:49:15 UTC
Permalink
I know the information is there but I don't have sufficient Haskell
skills to figure it out yet. I've only been using Xmonad for about 6
months.

I've seen the information in the StackSet doc, and I can also see it
in prelude with this:

Graphics.X11.openDisplay [] >>= Graphics.X11.Xinerama.getScreenInfo
[Rectangle {rect_x = 0, rect_y = 0, rect_width = 3440, rect_height = 1440}]

I have yet to successfully look inside the stackSet. I can tell that I'm not getting
something that is very fundamental.

I have this submap that I use mostly to move my scratchpads around.
It works great but I would like to set the width and height according to
the height and width of the current screen.

floatKeymap =
[ ("g", withFocused (keysMoveWindowTo (0,40) (0,0))) -- Top Left
, ("c", withFocused (keysMoveWindowTo (halfWidth, 40) (1%2, 0))) -- Top Center
, ("r", withFocused (keysMoveWindowTo (screenWidth, 40) (1,0))) -- Top Right
, ("h", withFocused (keysMoveWindowTo (0, halfHeight) (0, 1%2))) -- Left Center
, ("t", withFocused (keysMoveWindowTo (halfWidth, halfHeight) (1%2, 1%2))) -- Center
, ("n", withFocused (keysMoveWindowTo (screenWidth, halfHeight) (1, 1%2))) -- Right Center
, ("m", withFocused (keysMoveWindowTo (0, screenHeight) (0,1))) -- Bottom Left
, ("w", withFocused (keysMoveWindowTo (halfWidth, screenHeight) (1%2, 1))) -- Bottom Center
, ("v", withFocused (keysMoveWindowTo (screenWidth, screenHeight) (1,1))) -- BottomRight
] where
screenWidth = 3440
screenHeight = 1440
halfWidth = div screenWidth 2
halfHeight = div screenHeight 2


I would appreciate any pointers that would help me
understand and figure this out.
Brandon Allbery
2016-12-08 02:57:52 UTC
Permalink
Post by e***@gmail.com
I have yet to successfully look inside the stackSet. I can tell that I'm not getting
something that is very fundamental.
Somewhere in a do block in X:

rect <- fmap (W.screenRect . W.screenDetail . current) (gets windowset)

(the type of this is
http://hackage.haskell.org/package/X11-1.6.1.2/docs/Graphics-X11-Xlib-Types.html#t:Rectangle
)

Also, you need to have imported the StackSet stuff properly:

import qualified XMonad.StackSet as W

The StackSet type is heavily parameterized because sjanssen ran the
XMonad.StackSet module through a code verifier which couldn't handle the
X11 types, so substituted basic types for them instead.
http://hackage.haskell.org/package/xmonad-0.12/docs/XMonad-Core.html#t:WindowSet
is the actual type of what we normally refer to as the StackSet.
--
brandon s allbery kf8nh sine nomine associates
***@gmail.com ***@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
e***@gmail.com
2016-12-08 04:19:31 UTC
Permalink
Thank you that makes more sense. I do have

import qualified XMonad.StackSet as W

But everything makes more sense now that I'm looking at XMonad.Core.
I'm also still struggling with monads and all the types.
That might take me bit of time. XMonad may not be the best way
to learn Haskell...
Post by Brandon Allbery
Post by e***@gmail.com
I have yet to successfully look inside the stackSet. I can tell that I'm not getting
something that is very fundamental.
rect <- fmap (W.screenRect . W.screenDetail . current) (gets windowset)
(the type of this is
http://hackage.haskell.org/package/X11-1.6.1.2/docs/Graphics-X11-Xlib-Types.html#t:Rectangle
)
import qualified XMonad.StackSet as W
The StackSet type is heavily parameterized because sjanssen ran the
XMonad.StackSet module through a code verifier which couldn't handle the
X11 types, so substituted basic types for them instead.
http://hackage.haskell.org/package/xmonad-0.12/docs/XMonad-Core.html#t:WindowSet
is the actual type of what we normally refer to as the StackSet.
Brandon Allbery
2016-12-08 04:22:40 UTC
Permalink
Post by e***@gmail.com
XMonad may not be the best way
to learn Haskell...
It's actually a rather poor way to learn Haskell: programs tend to be
sitting very close to the Xlib API, and usually end up looking like a
"translation" of C to Haskell instead of like idiomatic Haskell code.
--
brandon s allbery kf8nh sine nomine associates
***@gmail.com ***@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
Continue reading on narkive:
Loading...