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/`. 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 [[!template id=man name="xset" section="1"]] to forcibly blank the screen on lid-close, and refresh the screen on lid-open: [[!template id=programlisting text=""" #!/bin/sh # 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 ;; esac """]]