From a096c25149dd1bdf1c8a1c761a82890495498662 Mon Sep 17 00:00:00 2001 From: hcpl Date: Fri, 1 Jul 2016 00:02:48 +0300 Subject: Add "info" operation and make it default There should be an option to get a sole "current brightness" value. --- brightnessctl.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'brightnessctl.c') diff --git a/brightnessctl.c b/brightnessctl.c index 4b46d6e..0e16b0e 100644 --- a/brightnessctl.c +++ b/brightnessctl.c @@ -59,7 +59,7 @@ struct value { unsigned int sign : 1; }; -enum operation { GET, MAX, SET }; +enum operation { INFO, GET, MAX, SET }; struct params { char *class; @@ -155,15 +155,17 @@ int main(int argc, char **argv) { if (!dev_name) dev_name = devs[0]->id; if (argc == 0) - p.operation = GET; + p.operation = INFO; else switch (argv[0][0]) { case 'm': p.operation = MAX; break; case 's': p.operation = SET; break; - default: case 'g': p.operation = GET; break; + default: + case 'i': + p.operation = INFO; break; } argc--; argv++; @@ -195,8 +197,11 @@ int main(int argc, char **argv) { int apply_operation(struct device *dev, unsigned int operation, struct value *val) { switch (operation) { - case GET: + case INFO: return print_device(dev); + case GET: + fprintf(stdout, "%u\n", dev->curr_brightness); + return 0; case MAX: fprintf(stdout, "%u\n", dev->max_brightness); return 0; @@ -545,6 +550,7 @@ Options:\n\ -c, --class=CLASS\t\tspecify device class.\n\ \n\ Operations:\n\ + i, info\t\t\tget device info.\n\ g, get\t\t\tget current brightness of the device.\n\ m, max\t\t\tget maximum brightness of the device.\n\ s, set VALUE\t\t\tset brightness of the device.\n\ -- cgit v1.2.3