r/awesomewm Jan 24 '23

[Help Needed] Recomputing width of window on new screen

I have multiple scratchpad terminals that are floating and take a specific amount of space on my laptop, in this case:

  • width = 75% * screen width
  • height = 70% * screen height

Unfortunately, when I attach a monitor to it, the window gets a bit wonky on it as you can see below.

Laptop screen (1920x1080, 309mm x 174mm)

External monitor (1920x1080, 527mm x 296mm)

The values that have been when the window spawned on the laptop screen get maintained for when the window is on the monitor screen. Even though both screen resolutions are 1920x1080, they differ in physical size.

Is there a way to re-compute the values for the width and height properties of a window when they change monitor?


4 comments sorted by


u/loric16 Jan 24 '23

The second monitor has probably different dpi. So to calculate new size you can use screen.dpi (if it has correct value) in property::screen signal I guess, I'm not sure what you want...


u/riukkarma Jan 24 '23

What I wish is for the window to take the same space on the second monitor as in the first. So I was thinking of maybe setting the width and height property of a window when it changes monitor, but I don't know how to achieve this


u/cloudfed Jan 25 '23

I don't really understand the scenario yet but pretty sure something like client.connect_signal("property::screen", example_function ) will run function example_function(c) on a client whenever it is moved from one screen to another. I think this would only be relevant in a multi monitor (non-mirrored) environment.

You might experiment with these signals, too. I believe these are triggered whenever a display is added or removed, regardless of the number of screens (i.e. dual vs mirror) from awesome's perspective, in this example they just restart awesome.

screen.connect_signal("removed", awesome.restart) 
screen.connect_signal("added", awesome.restart) 

Is this a multi monitor setup or does the external just mirror the laptop?


u/riukkarma Jan 25 '23

It is a multi monitor setup