Permalink
Browse files

add new option 'fulldim' to force backlight to 1 when idle, regardles…

…s of the minbacklight value.
  • Loading branch information...
poliva committed May 14, 2012
1 parent ccd6782 commit 029f70e6dff5d4edf0d16171fadae30a1b17f11b
Showing with 42 additions and 14 deletions.
  1. +3 −1 README
  2. +3 −1 README.md
  3. +15 −3 configfile.c
  4. +2 −1 lightum.1
  5. +16 −7 lightum.c
  6. +1 −0 lightum.h
  7. +2 −1 lightum.pod
View
4 README
@@ -30,10 +30,12 @@ Usage: lightum [OPTION]...
-N 1..6 : minimum backlight value in auto mode (default=1)
-p num : number of milliseconds between light sensor polls (default=300)
-i num : power off keyboard light on session idle seconds (0 to disable)
- -I num : power off screen backlight on session idle seconds (0 to disable)
+ -I num : turn down screen backlight on session idle seconds (0 to disable)
-w num : 1 manage brightness, 2 manage backlight, 3 both (default:3)
-x : manual mode (will honor the brightness value set with Fn keys)
+ -l : fully dim the screen backlight when session is idle
-u : do not ignore brightness changes happening outside lightum
+ -U : ignore session information from ConsoleKit
-s : power off keyboard light when screen saver is active
-f : run in foreground (do not daemonize)
-v : verbose mode, useful for debugging with -f and -d
View
@@ -39,10 +39,12 @@ config file, but the configuration values can be overwritten via the command lin
-N 1..6 : minimum backlight value in auto mode (default=1)
-p num : number of milliseconds between light sensor polls (default=300)
-i num : power off keyboard light on session idle seconds (0 to disable)
- -I num : power off screen backlight on session idle seconds (0 to disable)
+ -I num : turn down screen backlight on session idle seconds (0 to disable)
-w num : 1 manage brightness, 2 manage backlight, 3 both (default:3)
-x : manual mode (will honor the brightness value set with Fn keys)
+ -l : fully dim the screen backlight when session is idle
-u : do not ignore brightness changes happening outside lightum
+ -U : ignore session information from ConsoleKit
-s : power off keyboard light when screen saver is active
-f : run in foreground (do not daemonize)
-v : verbose mode, useful for debugging with -f and -d
View
@@ -31,6 +31,7 @@ static const conf_data default_config = {
/* screenidle */ 30,
/* workmode */ 3,
/* ignoresession */ 0,
+ /* fulldim */ 0,
};
int file_exists(char* file) {
@@ -109,12 +110,16 @@ int create_config_file(char* file) {
fprintf(fd, "# 1 = turn off keyboard brightness when screensaver is active\n");
fprintf(fd, "# 0 = do not monitor screensaver status\n");
fprintf(fd, "queryscreensaver=%d\n\n", default_config.queryscreensaver);
- fprintf(fd, "# maximum screen backlight value (between 4 and 15)\n");
+ fprintf(fd, "# maximum screen backlight value (between 7 and 15)\n");
fprintf(fd, "maxbacklight=%d\n\n", default_config.maxbacklight);
- fprintf(fd, "# minimum screen backlight value (between 1 and 3)\n");
+ fprintf(fd, "# minimum screen backlight value (between 1 and 6)\n");
fprintf(fd, "minbacklight=%d\n\n", default_config.minbacklight);
- fprintf(fd, "# turn off screen backlight if computer unused for X seconds (0 to disable)\n");
+ fprintf(fd, "# turn down screen backlight if computer unused for X seconds (0 to disable)\n");
fprintf(fd, "screenidle=%d\n\n", default_config.screenidle);
+ fprintf(fd, "# fully dim the backlight when screenidle seconds reached (default 0)\n");
+ fprintf(fd, "# 1 = when idle, backlight will be set to 1\n");
+ fprintf(fd, "# 0 = when idle, backlight will be set to minbacklight\n");
+ fprintf(fd, "fulldim=%d\n\n", default_config.fulldim);
fclose(fd);
return TRUE;
@@ -228,6 +233,13 @@ conf_data config_parse() {
config.ignoresession = atoi(temp);
}
+ if ((strncmp ("fulldim=", input, 8)) == 0) {
+ strncpy (temp, input + 8,MAXLEN-1);
+ len=strlen(temp);
+ temp[len+1]='\0';
+ config.fulldim = atoi(temp);
+ }
+
}
free(file);
View
@@ -168,9 +168,10 @@ Usage: lightum [\s-1OPTION\s0]...
\fB\-N\fR \fI1..6\fR : minimum backlight value in auto mode (default=1)
\fB\-p\fR \fInum\fR : number of milliseconds between light sensor polls (default=300)
\fB\-i\fR \fInum\fR : power off keyboard light on session idle seconds (0 to disable)
- \fB\-I\fR \fInum\fR : power off screen backlight on session idle seconds (0 to disable)
+ \fB\-I\fR \fInum\fR : turn down screen backlight on session idle seconds (0 to disable)
\fB\-w\fR \fInum\fR : 1 manage brightness, 2 manage backlight, 3 both (default:3)
\fB\-x\fR : manual mode (will honor the brightness value set with Fn keys)
+ \fB\-l\fR : fully dim the screen backlight when session is idle
\fB\-u\fR : do not ignore brightness changes happening outside lightum
\fB\-s\fR : power off keyboard light when screen saver is active
\fB\-f\fR : run in foreground (do not daemonize)
View
@@ -41,9 +41,10 @@ void usage(const char *error) {
fprintf(stderr, " -N 1..6 : minimum backlight value in auto mode (default=1)\n");
fprintf(stderr, " -p num : number of milliseconds between light sensor polls (default=300)\n");
fprintf(stderr, " -i num : power off keyboard light on session idle seconds (0 to disable)\n");
- fprintf(stderr, " -I num : power off screen backlight on session idle seconds (0 to disable)\n");
+ fprintf(stderr, " -I num : turn down screen backlight on session idle seconds (0 to disable)\n");
fprintf(stderr, " -w num : 1 manage brightness, 2 manage backlight, 3 both (default:3)\n");
fprintf(stderr, " -x : manual mode (will honor the brightness value set with Fn keys)\n");
+ fprintf(stderr, " -l : fully dim the screen backlight when session is idle\n");
fprintf(stderr, " -u : do not ignore brightness changes happening outside lightum\n");
fprintf(stderr, " -U : ignore session information from ConsoleKit\n");
fprintf(stderr, " -s : power off keyboard light when screen saver is active\n");
@@ -100,7 +101,7 @@ int main(int argc, char *argv[]) {
conf = config_parse();
// overwrite config file with command line arguments
- while ((c = getopt(argc, argv, "hxuUsvfm:n:M:N:p:I:i:d:w:?")) != EOF) {
+ while ((c = getopt(argc, argv, "hxuUlsvfm:n:M:N:p:I:i:d:w:?")) != EOF) {
switch(c) {
case 'h':
usage("");
@@ -114,6 +115,9 @@ int main(int argc, char *argv[]) {
case 'U':
conf.ignoresession=1;
break;
+ case 'l':
+ conf.fulldim=1;
+ break;
case 's':
conf.queryscreensaver=1;
break;
@@ -167,14 +171,17 @@ int main(int argc, char *argv[]) {
if (verbose) printf("\tminbacklight: %d\n",conf.minbacklight);
if (verbose) printf("\tpolltime: %d\n",conf.polltime);
if (verbose) printf("\tidleoff: %d\n",conf.idleoff);
- if (verbose) printf("\tscreenidle: %d\n\n",conf.screenidle);
+ if (verbose) printf("\tscreenidle: %d\n",conf.screenidle);
+ if (verbose) printf("\tfulldim: %d\n\n",conf.fulldim);
// make sure all config values are correct
check_config_values(conf);
if (debug < 0 || debug > 3) usage("ERROR: Wrong value in config variable 'debug'\n");
// if debug enabled, force verbose mode too
if (debug > 0) verbose=1;
+ // if verbose enabled, force foreground mode too
+ if (verbose) foreground=1;
if (conf.manualmode) printf("lightum v%s running in manual mode ", VERSION);
else printf("lightum v%s running in auto mode ", VERSION);
@@ -339,7 +346,8 @@ int main(int argc, char *argv[]) {
backlight_restoreflag=1;
if (debug == 2 || debug == 3) printf("backlight_restoreflag(%d) ", backlight_restore);
}
- backlight=conf.minbacklight;
+ if (conf.fulldim) backlight=1;
+ else backlight=conf.minbacklight;
} else {
backlight=backlight_restore;
backlight_restoreflag=0;
@@ -358,7 +366,8 @@ int main(int argc, char *argv[]) {
if (conf.workmode == 2 || conf.workmode == 3) {
if ((conf.screenidle != 0) && (idletime > conf.screenidle)) {
- backlight=conf.minbacklight;
+ if (conf.fulldim) backlight=1;
+ else backlight=conf.minbacklight;
}
}
@@ -389,7 +398,7 @@ int main(int argc, char *argv[]) {
/* make sure maxbrightness is never <4 */
if (brightness_restore < 4) conf.maxbrightness=4;
else conf.maxbrightness=brightness_restore;
- if (verbose) printf("-> Detected user brightness change, setting maxbrightness to %d\n",brightness_restore);
+ if (verbose) printf("-> Detected user brightness change, setting maxbrightness to %d\n",conf.maxbrightness);
brightness_prev=brightness_restore;
} else {
if (verbose) printf("-> Ignoring user brightness change, wants to set maxbrightness to %d\n",brightness_restore);
@@ -428,7 +437,7 @@ int main(int argc, char *argv[]) {
/* make sure maxbacklight is never <7 */
if (backlight_restore < 7) conf.maxbacklight=7;
else conf.maxbacklight=backlight_restore;
- if (verbose) printf("-> Detected user backlight change, setting maxbacklight to %d\n",backlight_restore);
+ if (verbose) printf("-> Detected user backlight change, setting maxbacklight to %d\n",conf.maxbacklight);
backlight_prev=backlight_restore;
} else {
if (verbose) printf("-> Ignoring user backlight change, wants to set maxbacklight to %d\n",backlight_restore);
View
@@ -27,6 +27,7 @@ typedef struct {
int screenidle;
int workmode;
int ignoresession;
+ int fulldim;
} conf_data;
/* configfile.c */
View
@@ -39,9 +39,10 @@ Usage: lightum [OPTION]...
B<-N> I<1..6> : minimum backlight value in auto mode (default=1)
B<-p> I<num> : number of milliseconds between light sensor polls (default=300)
B<-i> I<num> : power off keyboard light on session idle seconds (0 to disable)
- B<-I> I<num> : power off screen backlight on session idle seconds (0 to disable)
+ B<-I> I<num> : turn down screen backlight on session idle seconds (0 to disable)
B<-w> I<num> : 1 manage brightness, 2 manage backlight, 3 both (default:3)
B<-x> : manual mode (will honor the brightness value set with Fn keys)
+ B<-l> : fully dim the screen backlight when session is idle
B<-u> : do not ignore brightness changes happening outside lightum
B<-s> : power off keyboard light when screen saver is active
B<-f> : run in foreground (do not daemonize)

0 comments on commit 029f70e

Please sign in to comment.