Browse Source

Create a flag category only for backlight/kbd

Now we can save, restore, get [max] brightness etc. for both screen
and keyboard controllers
Abdullah ibn Nadjo 7 years ago
parent
commit
cd70ff5e01
2 changed files with 95 additions and 111 deletions
  1. 19
    34
      include/light.h
  2. 76
    77
      src/light.c

+ 19
- 34
include/light.h View File

12
 #define LIGHT_YEAR 2014
12
 #define LIGHT_YEAR 2014
13
 #define LIGHT_AUTHOR "Fredrik Haikarainen"
13
 #define LIGHT_AUTHOR "Fredrik Haikarainen"
14
 
14
 
15
-#define ASSERT_OPSET() \
16
-  if(opSet)\
15
+#define ASSERT_SET(t,v) \
16
+  if(v)\
17
   {\
17
   {\
18
-    printf("Operation arguments can not be used in conjunction.\n");\
18
+    printf(t" arguments can not be used in conjunction.\n");\
19
     return FALSE;\
19
     return FALSE;\
20
   }\
20
   }\
21
-  opSet = TRUE;
21
+  v = TRUE;
22
 
22
 
23
-#define ASSERT_TARGETSET() \
24
-  if(targetSet)\
25
-  {\
26
-    printf("Target arguments can not be used in conjunction.\n");\
27
-    return FALSE;\
28
-  }\
29
-  targetSet = TRUE;
30
-
31
-#define ASSERT_CTRLSET()\
32
-  if(ctrlSet)\
33
-  {\
34
-    printf("Controller arguments can not be used in conjunction.\n");\
35
-    return FALSE;\
36
-  }\
37
-  ctrlSet = TRUE;
23
+#define ASSERT_OPSET() ASSERT_SET("Operation", opSet)
24
+#define ASSERT_TARGETSET() ASSERT_SET("Target", targetSet)
25
+#define ASSERT_FIELDSET() ASSERT_SET("Field", fieldSet)
26
+#define ASSERT_CTRLSET() ASSERT_SET("Controller", ctrlSet)
27
+#define ASSERT_VALSET() ASSERT_SET("Value", valSet)
38
 
28
 
39
-#define ASSERT_VALSET()\
40
-  if(valSet)\
41
-  {\
42
-    printf("Value arguments can not be used in conjunction.\n");\
43
-    return FALSE;\
44
-  }\
45
-  valSet = TRUE;
46
-
47
-
48
-typedef enum LIGHT_TARGET {
29
+typedef enum LIGHT_FIELD {
49
   LIGHT_BRIGHTNESS = 0,
30
   LIGHT_BRIGHTNESS = 0,
50
   LIGHT_MAX_BRIGHTNESS,
31
   LIGHT_MAX_BRIGHTNESS,
51
   LIGHT_MIN_CAP,
32
   LIGHT_MIN_CAP,
52
-  LIGHT_SAVERESTORE,
53
-  LIGHT_KEYBOARD,
54
-  LIGHT_KEYBOARD_MAX_BRIGHTNESS
33
+  LIGHT_SAVERESTORE
34
+} LIGHT_FIELD;
35
+
36
+typedef enum LIGHT_TARGET {
37
+  LIGHT_BACKLIGHT = 0,
38
+  LIGHT_KEYBOARD
55
 } LIGHT_TARGET;
39
 } LIGHT_TARGET;
56
 
40
 
57
 typedef enum LIGHT_CTRL_MODE {
41
 typedef enum LIGHT_CTRL_MODE {
88
   unsigned long   specifiedValueRaw; /* The specified value in raw mode */
72
   unsigned long   specifiedValueRaw; /* The specified value in raw mode */
89
   double          specifiedValuePercent; /* The specified value in percent */
73
   double          specifiedValuePercent; /* The specified value in percent */
90
 
74
 
91
-  LIGHT_TARGET    target;
75
+  LIGHT_TARGET   target;
76
+  LIGHT_FIELD    field;
92
 
77
 
93
   /* Cache data */
78
   /* Cache data */
94
   LIGHT_BOOL      hasCachedMaxBrightness;
79
   LIGHT_BOOL      hasCachedMaxBrightness;
132
 
117
 
133
 /* WARNING: `buffer` HAS to be freed by the user if not null once returned!
118
 /* WARNING: `buffer` HAS to be freed by the user if not null once returned!
134
  * Size is always 256 */
119
  * Size is always 256 */
135
-LIGHT_BOOL light_genPath(char const *controller, LIGHT_TARGET type, char **buffer);
120
+LIGHT_BOOL light_genPath(char const *controller, LIGHT_TARGET target, LIGHT_FIELD type, char **buffer);
136
 
121
 
137
 LIGHT_BOOL light_getBrightness(char const *controller, unsigned long *v);
122
 LIGHT_BOOL light_getBrightness(char const *controller, unsigned long *v);
138
 
123
 

+ 76
- 77
src/light.c View File

16
   light_Configuration.valueMode              = LIGHT_PERCENT;
16
   light_Configuration.valueMode              = LIGHT_PERCENT;
17
   light_Configuration.specifiedValueRaw      = 0;
17
   light_Configuration.specifiedValueRaw      = 0;
18
   light_Configuration.specifiedValuePercent  = 0.0;
18
   light_Configuration.specifiedValuePercent  = 0.0;
19
-  light_Configuration.target                 = LIGHT_BRIGHTNESS;
19
+  light_Configuration.target                 = LIGHT_BACKLIGHT;
20
+  light_Configuration.field                  = LIGHT_BRIGHTNESS;
20
   light_Configuration.hasCachedMaxBrightness = FALSE;
21
   light_Configuration.hasCachedMaxBrightness = FALSE;
21
   light_Configuration.cachedMaxBrightness    = 0;
22
   light_Configuration.cachedMaxBrightness    = 0;
22
   light_verbosity                            = 0;
23
   light_verbosity                            = 0;
29
 
30
 
30
   LIGHT_BOOL opSet = FALSE;
31
   LIGHT_BOOL opSet = FALSE;
31
   LIGHT_BOOL targetSet = FALSE;
32
   LIGHT_BOOL targetSet = FALSE;
33
+  LIGHT_BOOL fieldSet = FALSE;
32
   LIGHT_BOOL ctrlSet = FALSE;
34
   LIGHT_BOOL ctrlSet = FALSE;
33
   LIGHT_BOOL valSet = FALSE;
35
   LIGHT_BOOL valSet = FALSE;
34
 
36
 
35
   unsigned long specLen = 0;
37
   unsigned long specLen = 0;
36
 
38
 
37
-  while((currFlag = getopt(argc, argv, "HhVGSAULIObmckas:prv:")) != -1)
39
+  while((currFlag = getopt(argc, argv, "HhVGSAULIObmclkas:prv:")) != -1)
38
   {
40
   {
39
     switch(currFlag)
41
     switch(currFlag)
40
     {
42
     {
78
         break;
80
         break;
79
 
81
 
80
       /* -- Targets -- */
82
       /* -- Targets -- */
81
-      case 'b':
83
+      case 'l':
82
         ASSERT_TARGETSET();
84
         ASSERT_TARGETSET();
83
-        light_Configuration.target = LIGHT_BRIGHTNESS;
85
+        light_Configuration.target = LIGHT_BACKLIGHT;
84
         break;
86
         break;
85
-      case 'm':
87
+      case 'k':
86
         ASSERT_TARGETSET();
88
         ASSERT_TARGETSET();
87
-        light_Configuration.target = LIGHT_MAX_BRIGHTNESS;
89
+        light_Configuration.target = LIGHT_KEYBOARD;
90
+        break;
91
+
92
+      /* -- Fields -- */
93
+      case 'b':
94
+        ASSERT_FIELDSET();
95
+        light_Configuration.field = LIGHT_BRIGHTNESS;
96
+        break;
97
+      case 'm':
98
+        ASSERT_FIELDSET();
99
+        light_Configuration.field = LIGHT_MAX_BRIGHTNESS;
88
         break;
100
         break;
89
       case 'c':
101
       case 'c':
90
-        ASSERT_TARGETSET();
91
-        light_Configuration.target = LIGHT_MIN_CAP;
102
+        ASSERT_FIELDSET();
103
+        light_Configuration.field = LIGHT_MIN_CAP;
92
         break;
104
         break;
93
-      case 'k':
94
-	      ASSERT_TARGETSET();
95
-	      light_Configuration.target = LIGHT_KEYBOARD;
96
 
105
 
97
       /* -- Controller selection -- */
106
       /* -- Controller selection -- */
98
       case 'a':
107
       case 'a':
210
   printf("  -O:\t\tSave brightness\n\n");
219
   printf("  -O:\t\tSave brightness\n\n");
211
 
220
 
212
   printf("Targets (can not be used in conjunction):\n");
221
   printf("Targets (can not be used in conjunction):\n");
222
+  printf("  -l:\t\tAct on screen backlight (default)\n");
223
+  printf("  -k:\t\tAct on keyboard backlight\n\n");
224
+
225
+  printf("Fields (can not be used in conjunction):\n");
213
   printf("  -b:\t\tBrightness (default)\n  \t\tUsed with [GSAU]\n\n");
226
   printf("  -b:\t\tBrightness (default)\n  \t\tUsed with [GSAU]\n\n");
214
   printf("  -m:\t\tMaximum brightness\n  \t\tUsed with [G]\n\n");
227
   printf("  -m:\t\tMaximum brightness\n  \t\tUsed with [G]\n\n");
215
   printf("  -c:\t\tMinimum cap\n  \t\tUsed with [GS]\n");
228
   printf("  -c:\t\tMinimum cap\n  \t\tUsed with [GS]\n");
216
-  printf("  -k:\t\tSet keyboard brightness instead of display brightness \n \t\tUsed with [GSAU]");
217
   printf("  \t\tG returns null if no minimum cap is set.\n\n");
229
   printf("  \t\tG returns null if no minimum cap is set.\n\n");
218
 
230
 
219
   printf("Controller selection (can not be used in conjunction):\n");
231
   printf("Controller selection (can not be used in conjunction):\n");
250
   }
262
   }
251
 
263
 
252
   if(mode == LIGHT_SAVE ||
264
   if(mode == LIGHT_SAVE ||
253
-     (mode == LIGHT_SET && light_Configuration.target == LIGHT_MIN_CAP))
265
+     (mode == LIGHT_SET && light_Configuration.field == LIGHT_MIN_CAP))
254
   {
266
   {
255
     /* Make sure we have a valid /etc/light directory, as well as mincap and save */
267
     /* Make sure we have a valid /etc/light directory, as well as mincap and save */
256
-    char const * const dirs[3] = {"/etc/light", "/etc/light/mincap", "/etc/light/save"};
268
+    char const * const dirs[5] = {"/etc/light", "/etc/light/mincap", "/etc/light/save", "/etc/light/mincap/kbd", "/etc/light/save/kbd"};
257
     char const * const *dir = dirs;
269
     char const * const *dir = dirs;
258
     char const * const direrr = "'%s' does not exist and could not be created, make sure this application is run as root.";
270
     char const * const direrr = "'%s' does not exist and could not be created, make sure this application is run as root.";
259
 
271
 
260
-    while (dir < dirs + 3)
272
+    while (dir < dirs + 5)
261
     {
273
     {
262
       mkdirVal = mkdir(*dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
274
       mkdirVal = mkdir(*dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
263
       if(mkdirVal != 0 && errno != EEXIST)
275
       if(mkdirVal != 0 && errno != EEXIST)
326
   }
338
   }
327
 
339
 
328
   /* No need to go further if targetting mincap */
340
   /* No need to go further if targetting mincap */
329
-  if(light_Configuration.target == LIGHT_MIN_CAP)
341
+  if(light_Configuration.field == LIGHT_MIN_CAP)
330
   {
342
   {
331
     return TRUE;
343
     return TRUE;
332
   }
344
   }
386
   /* Handle get operations */
398
   /* Handle get operations */
387
   if(light_Configuration.operationMode == LIGHT_GET)
399
   if(light_Configuration.operationMode == LIGHT_GET)
388
   {
400
   {
389
-    switch(light_Configuration.target){
401
+    switch(light_Configuration.field){
390
       case LIGHT_BRIGHTNESS:
402
       case LIGHT_BRIGHTNESS:
391
         (valueMode == LIGHT_RAW) ? printf("%lu\n", rawCurr) : printf("%.2f\n", percentCurr);
403
         (valueMode == LIGHT_RAW) ? printf("%lu\n", rawCurr) : printf("%.2f\n", percentCurr);
392
         break;
404
         break;
427
      light_Configuration.operationMode == LIGHT_ADD ||
439
      light_Configuration.operationMode == LIGHT_ADD ||
428
      light_Configuration.operationMode == LIGHT_SUB)
440
      light_Configuration.operationMode == LIGHT_SUB)
429
   {
441
   {
430
-    if(light_Configuration.target == LIGHT_MIN_CAP)
442
+    if(light_Configuration.field == LIGHT_MIN_CAP)
431
     {
443
     {
432
       /* Handle minimum cap files */
444
       /* Handle minimum cap files */
433
       writeVal = valueMode == LIGHT_RAW ?
445
       writeVal = valueMode == LIGHT_RAW ?
449
       /* All good? Return true. */
461
       /* All good? Return true. */
450
       return TRUE;
462
       return TRUE;
451
 
463
 
452
-    }else if(light_Configuration.target == LIGHT_BRIGHTNESS || light_Configuration.target == LIGHT_KEYBOARD){
464
+    }else if(light_Configuration.field == LIGHT_BRIGHTNESS){
453
       /* Handle brightness writing */
465
       /* Handle brightness writing */
454
 
466
 
455
       switch(light_Configuration.operationMode)
467
       switch(light_Configuration.operationMode)
489
       return TRUE;
501
       return TRUE;
490
 
502
 
491
     }else{
503
     }else{
492
-      /* If we didn't provide a valid target for write operations, fail. */
504
+      /* If we didn't provide a valid field for write operations, fail. */
493
       fprintf(stderr, "set/add/subtract operations are only available for brightness and minimum cap files.\n");
505
       fprintf(stderr, "set/add/subtract operations are only available for brightness and minimum cap files.\n");
494
       return FALSE;
506
       return FALSE;
495
     }
507
     }
515
     return TRUE;
527
     return TRUE;
516
   }
528
   }
517
 
529
 
518
-  fprintf(stderr, "Controller: %s\nValueRaw: %lu\nValuePercent: %.2f\nOpMode: %u\nValMode: %u\nTarget: %u\n\n", light_Configuration.specifiedController, light_Configuration.specifiedValueRaw, light_Configuration.specifiedValuePercent, light_Configuration.operationMode, light_Configuration.valueMode, light_Configuration.target);
530
+  fprintf(stderr, "Controller: %s\nValueRaw: %lu\nValuePercent: %.2f\nOpMode: %u\nValMode: %u\nField: %u\n\n", light_Configuration.specifiedController, light_Configuration.specifiedValueRaw, light_Configuration.specifiedValuePercent, light_Configuration.operationMode, valueMode, light_Configuration.field);
519
 
531
 
520
   fprintf(stderr, "You did not specify a valid combination of commandline arguments. Have some help: \n");
532
   fprintf(stderr, "You did not specify a valid combination of commandline arguments. Have some help: \n");
521
   light_printHelp();
533
   light_printHelp();
527
 
539
 
528
 }
540
 }
529
 
541
 
530
-LIGHT_BOOL light_genPath(char const *controller, LIGHT_TARGET type, char **buffer)
542
+LIGHT_BOOL light_genPath(char const *controller, LIGHT_TARGET target, LIGHT_FIELD type, char **buffer)
531
 {
543
 {
532
   char* returner = malloc(256);
544
   char* returner = malloc(256);
533
   int spfVal = -1;
545
   int spfVal = -1;
540
   }
552
   }
541
 
553
 
542
   memset(returner, '\0', 256);
554
   memset(returner, '\0', 256);
543
-
544
-  switch(type)
545
-  {
546
-    case LIGHT_BRIGHTNESS:
547
-      spfVal = sprintf(returner, "/sys/class/backlight/%s/brightness", controller);
548
-      break;
549
-    case LIGHT_MAX_BRIGHTNESS:
550
-      spfVal = sprintf(returner, "/sys/class/backlight/%s/max_brightness", controller);
551
-      break;
552
-    case LIGHT_MIN_CAP:
553
-      spfVal = sprintf(returner, "/etc/light/mincap/%s", controller);
554
-      break;
555
-    case LIGHT_SAVERESTORE:
556
-      spfVal = sprintf(returner, "/etc/light/save/%s", controller);
557
-      break;
558
-    case LIGHT_KEYBOARD:
559
-      spfVal = sprintf(returner, "/sys/class/leds/%s/brightness", controller);
560
-      break;
561
-    case LIGHT_KEYBOARD_MAX_BRIGHTNESS:
562
-      spfVal = sprintf(returner, "/sys/class/leds/%s/max_brightness", controller);
563
-      break;
555
+  if(target == LIGHT_BACKLIGHT)
556
+  {
557
+    switch(type)
558
+    {
559
+      case LIGHT_BRIGHTNESS:
560
+        spfVal = sprintf(returner, "/sys/class/backlight/%s/brightness", controller);
561
+        break;
562
+      case LIGHT_MAX_BRIGHTNESS:
563
+        spfVal = sprintf(returner, "/sys/class/backlight/%s/max_brightness", controller);
564
+        break;
565
+      case LIGHT_MIN_CAP:
566
+        spfVal = sprintf(returner, "/etc/light/mincap/%s", controller);
567
+        break;
568
+      case LIGHT_SAVERESTORE:
569
+        spfVal = sprintf(returner, "/etc/light/save/%s", controller);
570
+        break;
571
+    }
572
+  }else{
573
+    switch(type)
574
+    {
575
+      case LIGHT_BRIGHTNESS:
576
+        spfVal = sprintf(returner, "/sys/class/leds/%s/brightness", controller);
577
+        break;
578
+      case LIGHT_MAX_BRIGHTNESS:
579
+        spfVal = sprintf(returner, "/sys/class/leds/%s/max_brightness", controller);
580
+        break;
581
+      case LIGHT_MIN_CAP:
582
+        spfVal = sprintf(returner, "/etc/light/mincap/kbd/%s", controller);
583
+        break;
584
+      case LIGHT_SAVERESTORE:
585
+        spfVal = sprintf(returner, "/etc/light/save/kbd/%s", controller);
586
+        break;
587
+    }
564
   }
588
   }
565
-
566
   if(spfVal < 0)
589
   if(spfVal < 0)
567
   {
590
   {
568
     LIGHT_ERR("sprintf failed");
591
     LIGHT_ERR("sprintf failed");
572
   }
595
   }
573
 
596
 
574
   *buffer = returner;
597
   *buffer = returner;
575
-
576
   return TRUE;
598
   return TRUE;
577
 }
599
 }
578
 
600
 
579
 LIGHT_BOOL light_getBrightnessPath(char const *controller, char **path)
601
 LIGHT_BOOL light_getBrightnessPath(char const *controller, char **path)
580
 {
602
 {
581
-  LIGHT_TARGET target;
582
-
583
-  if(light_Configuration.target == LIGHT_MIN_CAP)
584
-  {
585
-    target = LIGHT_BRIGHTNESS;
586
-  }
587
-  else
588
-  {
589
-    target = light_Configuration.target;
590
-  }
591
-
592
-  if(!light_genPath(controller, target, path))
603
+  if(!light_genPath(controller, light_Configuration.target, LIGHT_BRIGHTNESS, path))
593
   {
604
   {
594
     LIGHT_ERR("could not generate path to brightness file");
605
     LIGHT_ERR("could not generate path to brightness file");
595
     return FALSE;
606
     return FALSE;
615
     LIGHT_ERR("could not read value from brightness file");
626
     LIGHT_ERR("could not read value from brightness file");
616
     return FALSE;
627
     return FALSE;
617
   }
628
   }
618
-
619
   return TRUE;
629
   return TRUE;
620
 }
630
 }
621
 
631
 
622
 LIGHT_BOOL light_getMaxBrightnessPath(char const *controller, char **path)
632
 LIGHT_BOOL light_getMaxBrightnessPath(char const *controller, char **path)
623
 {
633
 {
624
-  LIGHT_TARGET target;
625
-
626
-  if(light_Configuration.target == LIGHT_KEYBOARD)
627
-  {
628
-    target = LIGHT_KEYBOARD_MAX_BRIGHTNESS;
629
-  }
630
-  else
631
-  {
632
-    target = LIGHT_MAX_BRIGHTNESS;
633
-  }
634
-
635
-  if(!light_genPath(controller, target, path))
634
+  if(!light_genPath(controller, light_Configuration.target, LIGHT_MAX_BRIGHTNESS, path))
636
   {
635
   {
637
     LIGHT_ERR("could not generate path to maximum brightness file");
636
     LIGHT_ERR("could not generate path to maximum brightness file");
638
     return FALSE;
637
     return FALSE;
672
   char *brightnessPath = NULL;
671
   char *brightnessPath = NULL;
673
   LIGHT_BOOL writeVal = FALSE;
672
   LIGHT_BOOL writeVal = FALSE;
674
 
673
 
675
-  if(!light_genPath(controller, light_Configuration.target, &brightnessPath))
674
+  if(!light_genPath(controller, light_Configuration.target, light_Configuration.field, &brightnessPath))
676
   {
675
   {
677
     LIGHT_ERR("could not generate path to brightness file");
676
     LIGHT_ERR("could not generate path to brightness file");
678
     return FALSE;
677
     return FALSE;
697
   /* On auto mode, we need to check if we can read the max brightness value
696
   /* On auto mode, we need to check if we can read the max brightness value
698
      of the controller for later computation */
697
      of the controller for later computation */
699
   if(light_Configuration.controllerMode == LIGHT_AUTO ||
698
   if(light_Configuration.controllerMode == LIGHT_AUTO ||
700
-     light_Configuration.target == LIGHT_MAX_BRIGHTNESS)
699
+     light_Configuration.field == LIGHT_MAX_BRIGHTNESS)
701
   {
700
   {
702
     if(!light_getMaxBrightnessPath(controller, &brightnessPath))
701
     if(!light_getMaxBrightnessPath(controller, &brightnessPath))
703
     {
702
     {
718
   }
717
   }
719
 
718
 
720
   if(light_Configuration.operationMode != LIGHT_GET &&
719
   if(light_Configuration.operationMode != LIGHT_GET &&
721
-     light_Configuration.target != LIGHT_MIN_CAP &&
720
+     light_Configuration.field != LIGHT_MIN_CAP &&
722
      !light_isWritable(brightnessPath))
721
      !light_isWritable(brightnessPath))
723
   {
722
   {
724
     LIGHT_WARN("could not open controller brightness file for writing, so controller is not accessible");
723
     LIGHT_WARN("could not open controller brightness file for writing, so controller is not accessible");
840
 {
839
 {
841
  char * mincapPath = NULL;
840
  char * mincapPath = NULL;
842
 
841
 
843
- if(!light_genPath(controller, LIGHT_MIN_CAP, &mincapPath))
842
+ if(!light_genPath(controller, light_Configuration.target, LIGHT_MIN_CAP, &mincapPath))
844
  {
843
  {
845
     LIGHT_ERR("could not generate path to minimum cap file");
844
     LIGHT_ERR("could not generate path to minimum cap file");
846
     return FALSE;
845
     return FALSE;
870
 LIGHT_BOOL light_setMinCap(char const * controller, unsigned long v)
869
 LIGHT_BOOL light_setMinCap(char const * controller, unsigned long v)
871
 {
870
 {
872
   char * mincapPath = NULL;
871
   char * mincapPath = NULL;
873
-  if(!light_genPath(controller, LIGHT_MIN_CAP, &mincapPath))
872
+  if(!light_genPath(controller, light_Configuration.target, LIGHT_MIN_CAP, &mincapPath))
874
   {
873
   {
875
     LIGHT_ERR("could not generate path to minimum cap file");
874
     LIGHT_ERR("could not generate path to minimum cap file");
876
     return FALSE;
875
     return FALSE;
913
 
912
 
914
 LIGHT_BOOL light_saveBrightness(char const *controller, unsigned long v){
913
 LIGHT_BOOL light_saveBrightness(char const *controller, unsigned long v){
915
   char *savePath = NULL;
914
   char *savePath = NULL;
916
-  if(!light_genPath(controller, LIGHT_SAVERESTORE, &savePath))
915
+  if(!light_genPath(controller, light_Configuration.target, LIGHT_SAVERESTORE, &savePath))
917
   {
916
   {
918
     LIGHT_ERR("could not generate path to save/restore file");
917
     LIGHT_ERR("could not generate path to save/restore file");
919
     return FALSE;
918
     return FALSE;
935
   char *restorePath = NULL;
934
   char *restorePath = NULL;
936
   unsigned long v = 0;
935
   unsigned long v = 0;
937
 
936
 
938
-  if(!light_genPath(controller, LIGHT_SAVERESTORE, &restorePath))
937
+  if(!light_genPath(controller, light_Configuration.target, LIGHT_SAVERESTORE, &restorePath))
939
   {
938
   {
940
     LIGHT_ERR("could not generate path to save/restore file");
939
     LIGHT_ERR("could not generate path to save/restore file");
941
     return FALSE;
940
     return FALSE;