Set dev->matches to true when the --device option isn't being used
Fixes #107
With current implementation, if --device isn't used, then dev_name is initialized to the first device found, causing only it to be targeted for any operations. With this tweak it's possible to use the class targeting to access multiple devices.
Behavior before:
$ ./brightnessctl -c backlight
Device 'card1-eDP-2-backlight' of class 'backlight':
Current brightness: 200 (50%)
Max brightness: 400
Fixed behavior:
$ ./brightnessctl -c backlight
Device 'card1-eDP-2-backlight' of class 'backlight':
Current brightness: 200 (50%)
Max brightness: 400
Device 'intel_backlight' of class 'backlight':
Current brightness: 200 (50%)
Max brightness: 400
Device 'asus_screenpad' of class 'backlight':
Current brightness: 35 (15%)
Max brightness: 235
Hi @mfenniak might I suggest the following implementation instead:
diff --git a/brightnessctl.c b/brightnessctl.c
index 1917212b27d5..aac1c534f533 100644
--- a/brightnessctl.c
+++ b/brightnessctl.c
@@ -222,7 +222,7 @@ int main(int argc, char **argv) {
}
dev_name = p.device;
if (!dev_name)
- dev_name = devs[0]->id;
+ dev_name = "*";
if (argc == 0)
p.operation = INFO;
else switch (argv[0][0]) {
FYI the intended behavior of brightnessctl with no args is to show the brightness of the current device.
@mfenniak thanks for the suggestion. this should fix your usecase
@Hummer12007 Awesome, thank you!