LemonBoy / bar

A featherweight, lemon-scented, bar based on xcb
MIT License
1.62k stars 194 forks source link

Support for dynamic RandR changes #171

Closed DelusionalLogic closed 8 years ago

DelusionalLogic commented 8 years ago

This should allow lemonbar to dynamically detect and handle RandR changes. Fixing #135

When ever a RandR ouput change notification is received we fetch all the randr monitors and resize the bars to fit them. Creating new ones where they are missing, and deleting the excess if there are any.

I've done a bit of testing, turning one of my monitors on and off with it running, starting the bar at different points (with the monitor at a small resolution, large resolution, and off). I've also been switching between these stages while the bar was running, without any issues, and with the new expected behavior.

It ended up being quite a few more changes than i anticipated, but that's mostly because i extracted some functions to make this change easier to digest, and to duplicate less code. There is still some, you might want to look at that.

This change assumes that setting an atom to a value that is already set has no effect on the environment. This has only been tested on bspwm (where it does work), so it might be a good idea to test this multiple places if it's undocumented. It also relies on Map Window not causing issues when called on a mapped window. According to the X11 documentation: "If the window is already mapped, this request has no effect." So that should be fine.

I would say the functionality is there, If you could look at the style that would be great.

LemonBoy commented 8 years ago

The main idea is to avoid the kitchen-sink approach, whenever the screen is changed it's up to the window manager to take care of it and it's up to the user's scripts to just restart the bar. Keep it simple, sam!