#!/bin/bash # dwm_blank # Version: 0.2 # Last modified: 2012/11/05 # Author: mt progname="dwm_lock" lock="xscreensaver-command -lock" now=false off=false verbose=false printhelp(){ echo "$progname [options]" echo "Options:" echo " -h|--help: prints this message and quit" echo " -now: doesn't wait 1 second to lock screen" echo " -off: power off the monitor/lcd screen (dpms)" echo " -slock: uses slock to lock the screen (default is xscreensaver)" echo " -v: verbose mode" echo " -xlock: uses xlock to lock the screen" return } while [ "$1" != "" ]; do case "$1" in "-h|--help") printhelp ;; "-v") verbose=true ;; "-now") now=true ;; "-off") off=true ;; "-slock") lock=slock ;; "-xlock") lock=xlock ;; *) echo "$progname: error in the options!" >&2 exit 2 ;; esac shift done if ! $now; then sleep 1 # to protect from key-release event fi if $off; then if $verbose; then echo "$progname: power off the screen..." fi xset dpms force off fi $lock