aboutsummaryrefslogtreecommitdiff
path: root/brightnessctl.c
diff options
context:
space:
mode:
authorGravatar Miciah Masters <miciah.masters@gmail.com>2016-12-24 03:08:17 -0500
committerGravatar Miciah Dashiel Butler Masters <mmasters@redhat.com>2017-01-15 01:59:00 -0500
commitcaf20af422a7fc14c0d6eaa9cc330066b447a968 (patch)
treef1aef0849098f846e26915a8fb6a8e14a380c130 /brightnessctl.c
parent18ece5f9cc147999e57ed1bf139bcbd056185deb (diff)
Set dev_name to default device name
If no device is specified with the --device flag, set dev_name to the id of the first device. Before, if the --device flag is not used to specify the default device, the dev pointer was set to first device found (see commit c9140d1e5070dae2746d3b70c0390075bd5380f6), but the dev_name pointer was left set to NULL. As a result, some error messages did not print the name of the default device: % brightnessctl -s Error saving device data: No such file or directory Could not save data for device '(null)'. Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 % brightnessctl -s -m Error saving device data: No such file or directory Could not save data for device '(null)'. intel_backlight,backlight,1000,20%,4794 % After this commit, all error messages have the correct name: % brightnessctl -s Error saving device data: No such file or directory Could not save data for device 'intel_backlight'. Device 'intel_backlight' of class 'backlight': Current brightness: 1000 (20%) Max brightness: 4794 % brightnessctl -s -m Error saving device data: No such file or directory Could not save data for device 'intel_backlight'. intel_backlight,backlight,1000,20%,4794 %
Diffstat (limited to 'brightnessctl.c')
-rw-r--r--brightnessctl.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/brightnessctl.c b/brightnessctl.c
index 60ca3a4..d6170e9 100644
--- a/brightnessctl.c
+++ b/brightnessctl.c
@@ -151,6 +151,8 @@ int main(int argc, char **argv) {
return list_devices(devs);
}
dev_name = p.device;
+ if (!dev_name)
+ dev_name = devs[0]->id;
if (argc == 0)
p.operation = GET;
else switch (argv[0][0]) {
@@ -242,8 +244,6 @@ int parse_value(struct value *val, char *str) {
struct device *find_device(struct device **devs, char *name) {
struct device *dev;
- if (!name)
- return *devs;
while ((dev = *(devs++)))
if (!strcmp(dev->id, name))
return dev;