File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_blank_and_unblank_screens_on_lid_close__92__open.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sun Feb 5 07:14:36 2012 UTC (6 years, 4 months ago) by schmonz
Branches: MAIN
CVS tags: HEAD

The [powerd(8)]( daemon acts upon power management events posted by the kernel's power management facility, translating the events into a script name and arguments. These scripts are found in `/etc/powerd/scripts/`. 

The `lid_switch` script is called on lid-open and -close events. An event of `pressed` means the lid has been closed, and `released` that the lid has been opened. 

The following `lid_switch` uses [xset(1)]( to forcibly blank the screen on lid-close, and refresh the screen on lid-open: 
    # arguments passed by powerd(8): device event
    # debugging: exec 1>>/tmp/lid_switch.log 2>&1
    if [ -z "$DISPLAY" ]; then export DISPLAY=:0; fi
    case "${2}" in
     pressed)    # lid closed
       /usr/X11R6/bin/xset dpms force off
       exit 0
     released)   # lid opened
       # need to both force dpms and reset screensaver
       /usr/X11R6/bin/xset dpms force on
       /usr/X11R6/bin/xset s reset
       exit 0
       logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
       exit 1

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb