lightweight X11 utility to dim the screen and/or keyboard backlight when idle
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

use doubles for step increments

+14 -4
+14 -4
xdimmer.c
··· 389 389 { 390 390 double tbacklight = 0; 391 391 double tkbdbacklight = 0; 392 - int step_inc = 0, kbd_step_inc = 0, j; 392 + double step_inc = 0, kbd_step_inc = 0; 393 + int j; 393 394 394 395 if (dimscreen) { 395 396 tbacklight = backlight_op(OP_GET, 0); ··· 411 412 if (debug) { 412 413 if (dimscreen) 413 414 printf("stepping from %0.2f to %0.2f in increments " 414 - "of %d (%d step%s)\n", 415 + "of %f (%d step%s)\n", 415 416 tbacklight, new_backlight, step_inc, steps, 416 417 (steps == 1 ? "" : "s")); 417 418 if (dimkbd) 418 419 printf("stepping keyboard from %0.2f to %0.2f in " 419 - "increments of %d (%d step%s)\n", 420 + "increments of %f (%d step%s)\n", 420 421 tkbdbacklight, new_kbd_backlight, kbd_step_inc, 421 422 steps, (steps == 1 ? "" : "s")); 422 423 } ··· 465 466 #ifdef __OpenBSD__ 466 467 struct wsdisplay_param param; 467 468 469 + if (debug) 470 + printf("%s (wscons): %f\n", __func__, new_backlight); 471 + 468 472 param.param = WSDISPLAYIO_PARAM_BRIGHTNESS; 469 473 if (ioctl(wsconsdfd, WSDISPLAYIO_GETPARAM, &param) < 0) 470 474 err(1, "WSDISPLAYIO_GETPARAM failed"); ··· 486 490 (double)(param.max - param.min)) * 100; 487 491 #endif 488 492 } else { 493 + if (debug) 494 + printf("%s (xrandr): %f\n", __func__, new_backlight); 495 + 489 496 XRRScreenResources *screen_res = XRRGetScreenResources(dpy, 490 497 DefaultRootWindow(dpy)); 491 498 if (!screen_res) ··· 562 569 err(1, "WSKBDIO_GETBACKLIGHT failed"); 563 570 564 571 if (op == OP_SET) { 572 + if (debug) 573 + printf("%s: %f\n", __func__, new_backlight); 574 + 565 575 param.curval = (double)(param.max - param.min) * 566 576 (new_backlight / 100.0); 567 577 ··· 655 665 return; 656 666 } 657 667 658 - if (abs(lux - als) < 10) { 668 + if (abs((int)lux - (int)als) < 10) { 659 669 als = lux; 660 670 return; 661 671 }