File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_blank_and_unblank_screens_on_lid_close__92__open.mdwn
Revision 1.5: download - view: text, annotated - select for diffs
Wed Sep 9 14:28:56 2020 UTC (2 months, 2 weeks ago) by kim
Branches: MAIN
CVS tags: HEAD
Use man template

    1: The [[!template id=man name="powerd" section="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/`. 
    2: 
    3: 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. 
    4: 
    5: The following `lid_switch` uses [[!template id=man name="xset" section="1"]] to forcibly blank the screen on lid-close, and refresh the screen on lid-open: 
    6:     
    7: [[!template id=programlisting text="""
    8:     #!/bin/sh
    9:     # arguments passed by powerd(8): device event
   10:     # debugging: exec 1>>/tmp/lid_switch.log 2>&1
   11:     if [ -z "$DISPLAY" ]; then export DISPLAY=:0; fi
   12:     case "${2}" in
   13:      pressed)    # lid closed
   14:        /usr/X11R6/bin/xset dpms force off
   15:        exit 0
   16:        ;;
   17:      released)   # lid opened
   18:        # need to both force dpms and reset screensaver
   19:        /usr/X11R6/bin/xset dpms force on
   20:        /usr/X11R6/bin/xset s reset
   21:        exit 0
   22:        ;;
   23:      *)
   24:        logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
   25:        exit 1
   26:        ;;
   27:     esac
   28: """]]

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb