taffybar / taffybar

A gtk based status bar for tiling window managers such as XMonad
BSD 3-Clause "New" or "Revised" License
691 stars 134 forks source link

Backlight/Brightness widget #321

Open colonelpanic8 opened 6 years ago

colonelpanic8 commented 6 years ago

Add a backlight widget to monitor screen lighting

LeifW commented 6 years ago

See comment on https://github.com/taffybar/taffybar/pull/289#issuecomment-389284054

colonelpanic8 commented 6 years ago

@LeifW Hows the progress on this?

LeifW commented 6 years ago

I pushed what I have so far to https://github.com/taffybar/taffybar/pull/347

Design question: There I just return the first thing matched by "backlight" subsystem on udev. Could there be multiple? Multiple monitors? None?

Also, I called it "Brightness", but either name is fine with me.

colonelpanic8 commented 6 years ago

I pushed what I have so far to #347

Design question: There I just return the first thing matched by "backlight" subsystem on udev. Could there be multiple? Multiple monitors? None?

There definitely CAN be multiple monitors. And this is somethign we should try to handle. But I'm happy to punt on it and file an issue for now if you think dealing with it will involve a substantial amount of work.

Also, I called it "Brightness", but either name is fine with me.

Yeah Brightness is better

LeifW commented 6 years ago

I don't think it would be that much to support multiple items in the "backlight" class - that "udev enumeration" returns a sort of list - see https://pyudev.readthedocs.io/en/latest/guide.html#enumerating-devices I imagine you'd want them to have names in that case so you can disambiguate. I was going to plug in an external monitor and see if I get another device of type "backlight". Perhaps a [(Name, Chan Double)] sort of output?

LeifW commented 6 years ago

I don't believe support for multiple "backlight" devices will really be necessary. It seems to refer just to the laptop's internally managed display. Having multiple is something of a rarity, and apparently just refers to multiple drivers for the same screen: https://askubuntu.com/questions/94716/2-folders-in-sys-class-backlight I plugged my laptop into an external display with a USB-C -> HDMI adapter, and it has no effect on the devices reported under /sys/class/backlight, or udev events, or anything like that. The external monitor already has its own brightness control buttons, and on-screen display for feedback on current brightness setting. I did modify the "scan for backlight devices" to return a list. We could log a warning if multiple are detected (also there could be none on some systems - e.g. not a laptop, or missing driver). Otherwise I think we're fine with just picking the first. We could wait until someone with multiple "backlight" devices reports an issue, and then go from there? I don't really know what would happen - would both the intel_backlight and acpi_video0 drivers report the same "brightness change" event? Are both their values on the same scale (i.e. do they both have the same maximum_brightness?)

colonelpanic8 commented 6 years ago

@LeifW Yeah I'm not too worried about multiple devices for a v1 anyway. Just put some TODO or XXX comments in and punt on it for now?