How can I put the display to sleep on screen lock?
When I invoke the "Lock Screen" action, is there a way to have the monitor go to sleep instantly? I'm aware of the power management setting to turn off the display after a set amount of time, but I want this to happen immediately.
I'm hoping there is a bash script that will lock the screen and put the display to sleep, and that I can have this invoked when a screen lock operation occurs.
The following script will check every ten seconds to see if the screensaver is enabled, and if it is, turn of the display using the command xset dpms force off
.
It also checks to make sure it didn't already turn off the display, so you can unlock the screen without the monitor turning off while you are typing your password.
#!/bin/bash
ALREADY_SHUTOFF="yes"
while true; do
if (gnome-screensaver-command -q | grep "is active");
then
echo $ALREADY_SHUTOFF
if [ "$ALREADY_SHUTOFF" == "no" ];
then
# this command turns off the display
xset dpms force off
fi
ALREADY_SHUTOFF="yes"
else
ALREADY_SHUTOFF="no"
fi
sleep 10
done