brightnessctl icon indicating copy to clipboard operation
brightnessctl copied to clipboard

Set dev->matches to true when the --device option isn't being used

Open mfenniak opened this issue 1 year ago • 1 comments

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

mfenniak avatar Aug 22 '24 07:08 mfenniak

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]) {

xdbob avatar Sep 07 '24 12:09 xdbob

FYI the intended behavior of brightnessctl with no args is to show the brightness of the current device.

Hummer12007 avatar Dec 12 '24 15:12 Hummer12007

@mfenniak thanks for the suggestion. this should fix your usecase

Hummer12007 avatar Dec 15 '24 16:12 Hummer12007

@Hummer12007 Awesome, thank you!

mfenniak avatar Dec 15 '24 18:12 mfenniak