From 8a90aa7db7e63182f35a8acdf06c3e78ed6d5dde Mon Sep 17 00:00:00 2001 From: Mykyta Holubakha Date: Fri, 19 Jan 2018 20:35:49 +0200 Subject: Allow to specify device name as a wildcard --- brightnessctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'brightnessctl.c') diff --git a/brightnessctl.c b/brightnessctl.c index 71321c4..4cfaf29 100644 --- a/brightnessctl.c +++ b/brightnessctl.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -193,7 +194,7 @@ int main(int argc, char **argv) { } if (p.save) if (save_device_data(dev)) - fprintf(stderr, "Could not save data for device '%s'.\n", dev_name); + fprintf(stderr, "Could not save data for device '%s'.\n", dev->id); if (p.restore) { if (restore_device_data(dev)) write_device(dev); @@ -266,7 +267,7 @@ int parse_value(struct value *val, char *str) { struct device *find_device(struct device **devs, char *name) { struct device *dev; while ((dev = *(devs++))) - if (!strcmp(dev->id, name)) + if (!fnmatch(name, dev->id, 0)) return dev; return NULL; } @@ -552,7 +553,7 @@ Options:\n\ -s, --save\t\t\tsave previous state in a temporary file.\n\ -r, --restore\t\t\trestore previous saved state.\n\ -h, --help\t\t\tprint this help.\n\ - -d, --device=DEVICE\t\tspecify device name.\n\ + -d, --device=DEVICE\t\tspecify device name (can be a wildcard).\n\ -c, --class=CLASS\t\tspecify device class.\n\ -V, --version\t\t\tprint version and exit.\n\ \n\ -- cgit v1.2.3