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 --- README.md | 2 +- brightnessctl.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7b81757..fc51389 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Options: -s, --save save previous state in a temporary file. -r, --restore restore previous saved state. -h, --help print this help. - -d, --device=DEVICE specify device name. + -d, --device=DEVICE specify device name (can be a wildcard). -c, --class=CLASS specify device class. -V, --version print version and exit. 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