-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
actkbd module: introduce services.actkbd.brightnessControl option #58609
Conversation
Hey, sorry for the late response :o
And it does work as expected :) To make the script more robust I would also recommend to add something like the following (especially
Without
With
#!/usr/bin/env bash
set -o errexit
set -o nounset
bl_dev=`echo /sys/class/backlight/*`
current=$(< $bl_dev/brightness)
max=$(< $bl_dev/max_brightness)
level=$(($max * $2 / 100))
next_level=$(($current $1 $level))
if [ $next_level -gt $max ]; then
next_level=$max
elif [ $next_level -lt 1 ]; then
next_level=1
fi
#echo $next_level > $bl_dev/brightness
echo "bl_dev: $bl_dev"
echo "current: $current"
echo "max: $max"
echo "level: $level"
echo "next_level: $next_level" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good otherwise :)
(I did not test the actkbd
part though.)
@primeos Thank you much! I've applied your recommendations. |
cc @oxij (as the author of the |
- Commit messages should use "nixos/<module name>: <action>" format.
- 4cd3e6c needs
```diff
- (mkRenamedOptionModule [ "sound" "enableMediaKeys" ] [ "sound" "mediaKeys" "enable" ])
+ (mkRenamedOptionModule [ "sound" "enableMediaKeys" ] [ "services" "actkbd" "volumeControl" "enable" ])
```
to work properly else very old configurations will break.
- 4cd3e6c also changes the semantics of the renamed options, enabling `sound.mediaKeys.enable` enabled `services.actkbd.enable` before, now it does not. To make this way of doing things work you would have to make `services.actkbd.enabled` depend on `volumeControl.enable`, as ugly as it sounds. In which case I would also suggest making `sound.mediaKeys` an alias to `services.actkbd.volumeControl` instead of `mkRenamedOptionModule`, since it makes sense to keep that option there for documentation purposes at the very least.
But, personally, I'm 👎 on that patch in the first place. I think keeping these things outside of `actkbd` makes more sense since you could do the same thing using different backends. E.g. PulseAudio could have its own media keys setup with `actkbd` using `pauvcontrol` or whatever. I planned `actkbd` module as a generic modular thing, not as a place to assemble all possible implementations of all possible things, which this patch drives towards.
- `brightness.sh` needs some more hacking, e.g. on my laptop `ls /sys/class/backlight` gives several results (it gives both acpi backlight and intel backlight controls), I think that script will do something bad in such a situation. I would consider using some lightweight tool for that instead. E.g. I use `pkgs.light`.
Which brings me to `programs.light` option. I would just add the new options to that module instead and keep `actkbd` as module as it is.
|
@oxij Thank you!
Makes sense. I will make a new PR with changes to |
Motivation for this change
As discussed in #57602
@primeos Please give it a try
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)