Fredrik Svantesson 6 jaren geleden
bovenliggende
commit
1be06a4fb9
1 gewijzigde bestanden met toevoegingen van 12 en 2 verwijderingen
  1. 12
    2
      src/light.c

+ 12
- 2
src/light.c Bestand weergeven

@@ -236,6 +236,7 @@ static bool _light_parse_arguments(light_context_t *ctx, int argc, char** argv)
236 236
     char ctrl_name[NAME_MAX];
237 237
     bool need_value = false;
238 238
     bool need_target = true; // default cmd is get brightness
239
+    bool specified_target = false;
239 240
     snprintf(ctrl_name, sizeof(ctrl_name), "%s", "sysfs/backlight/auto");
240 241
     
241 242
     while((curr_arg = getopt(argc, argv, "HhVGSLMNPAUOIv:s:r")) != -1)
@@ -263,6 +264,7 @@ static bool _light_parse_arguments(light_context_t *ctx, int argc, char** argv)
263 264
                 break;
264 265
             case 's':
265 266
                 snprintf(ctrl_name, sizeof(ctrl_name), "%s", optarg);
267
+                specified_target = true;
266 268
                 break;
267 269
             case 'r':
268 270
                 ctx->run_params.raw_mode = true;
@@ -332,8 +334,16 @@ static bool _light_parse_arguments(light_context_t *ctx, int argc, char** argv)
332 334
         light_device_target_t *curr_target = light_find_device_target(ctx, ctrl_name);
333 335
         if(curr_target == NULL)
334 336
         {
335
-            fprintf(stderr, "couldn't find a device target at the path \"%s\". Use -L to find one.\n\n", ctrl_name);
336
-            return false;
337
+            if(specified_target)
338
+            {
339
+                fprintf(stderr, "We couldn't find the specified device target at the path \"%s\". Use -L to find one.\n\n", ctrl_name);
340
+                return false;
341
+            }
342
+            else 
343
+            {
344
+                fprintf(stderr, "No backlight controller was found, so we could not decide an automatic target. The current command will have no effect. Please use -L to find a target and then specify it with -s.\n\n");
345
+                curr_target = light_find_device_target(ctx, "util/test/dryrun");
346
+            }
337 347
         }
338 348
         
339 349
         ctx->run_params.device_target = curr_target;