;;; brightness.jl --- Brightness control for Vaio LCD ;;; Copyright (C) 2003 by Walter C. Pelissero ;;; Author: Walter C. Pelissero ;;; Project: ;;; $Id$ ;;; This program is free software; you can redistribute it and/or ;;; modify it under the terms of the GNU General Public License as ;;; published by the Free Software Foundation; either version 2, or ;;; (at your option) any later version. ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; General Public License for more details. ;;; You should have received a copy of the GNU General Public License ;;; along with this program; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;;; Boston, MA 02111-1307, USA. ;;; Commentary: (define-structure brightness (export increase-brightness decrease-brightness br-change-delta) (open rep rep.system rep.io.timers sawfish.wm.custom sawfish.wm.misc) (defun setbrightness (intensity) (system (format nil "setbrightness %d" (quotient (* 255 (- 100 intensity)) 100)))) (defvar *brightness* 100) (defvar *brightness-window-timer* nil) (defcustom br-change-delta 5 "Brightness percent change delta." :type number :user-level novice :group misc) (defun display-brightness () (display-message (format nil "Brightness: %d%%" *brightness*)) (if *brightness-window-timer* (set-timer *brightness-window-timer* 5) (setq *brightness-window-timer* (make-timer (lambda () (setq *brightness-window-timer* nil) (display-message nil)) 5)))) (defun increase-brightness () "Increase LCD backlight brightness of br-change-delta." (interactive) (setq *brightness* (min 100 (+ *brightness* br-change-delta))) (display-brightness) (setbrightness *brightness*)) (defun decrease-brightness () "Decrease LCD backlight brightness of br-change-delta." (interactive) (setq *brightness* (max 0 (- *brightness* br-change-delta))) (display-brightness) (setbrightness *brightness*)))