aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar hcpl <hcpl.prog@gmail.com>2016-07-01 00:02:48 +0300
committerGravatar Hummer12007 <hilobakho@gmail.com>2017-07-28 14:06:16 +0300
commita096c25149dd1bdf1c8a1c761a82890495498662 (patch)
tree28b5b01710d87021cd7f37d8c54c2ee42cad4397
parent86232f80d4ba3290db2bdc0e90c979efd584cae0 (diff)
Add "info" operation and make it default
There should be an option to get a sole "current brightness" value.
-rw-r--r--brightnessctl.c14
1 files changed, 10 insertions, 4 deletions
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\