Hummer12007 / brightnessctl

A program to read and control device brightness
Other
900 stars 48 forks source link

`--pretend` does not work for `--restore` and `--save` #114

Open JohnMertz opened 2 days ago

JohnMertz commented 2 days ago

First, let me be clear that I'm using the Fedora 40 package, which seems to be built from master rather than the latest official GitHub release. So, this problem could be because of my package maintainer. I will certainly redirect my question if it is deemed inappropriate. That said, the is sort of a Feature Request at the bottom if the behaviour I describe is not the intended behaviour.

So, I may be misunderstanding this feature, but here is what I expect to happen:

brightnessctl -d 'intel_backlight' s 50%
brightnessctl -d 'intel_backlight' -s
brightnessctl -d 'intel_backlight' s 40%
brightnessctl --pretend -d 'intel_backlight' -r

This should set the brightness to 50%, save that state, set it to 40%, then just print the saved state of 50% without actually changing it back to 50%.

Everything works up until the last command when it does, in fact, set the brightness to 50%. The same thing happens with -p instead of --pretend. Both forms of the argument do work to prevent s, but also do not work with --save (where I would expect it to provide the device info, but not actually overwrite the state, so the next --restore would use the previously saved state when --pretend was not used).

To be clear, I don't actually care too much that these don't work as I expect. What I'm trying to achieve with the commands above is to have a method to determine the state that is currently saved. I had assumed that using --restore in conjunction with --pretend would tell me what state it intended to restore to, without actually committing that change, which would be equivalent.

If, instead there was just a --show-saved option were I could read this directly, this would be more useful. Also, my actual desire was to script a toggle_min feature. ie:

if saved_state_exists:
    if saved_state == current_state:
        set the brightness to 1
    elif saved_state == brightness 1:
        save current_state to saved_state
        set the brightness to 1
    else:
        restore saved_state
else:
    save current_state to saved_state
    set the brightness to 1

I can work around this by just making manually tracking a saved brightness to a file, but it would be nice to use brightnessctls built-in tools.