How can I disable backlight when I lock the screen?
Solution 1
- Go to System Settings --> Keyboard --> Shortcuts,
- Create a new Custom Shortcut.
-
Reassign Ctrl + Alt + L to the following command.
bash -c "xset dpms force off; gnome-screensaver-command -l"
Solution 2
I am running a script for same problem (source):
#!/bin/bash
sleep 0.5
xset dpms force off
gnome-screensaver-command -l
This turns monitor off and locks the session. The sleep 0.5
is there to avoid the monitor turning on when you release the Ctrl+Alt keys; maybe you don't need this.
You can try other solution also from there (didn't tried this one yet).
The solution I use is:
I have added the Inhibit Applet to my top panel (this lets me toggle the sleep mode off and on)
In power management I set Put display to sleep when inactive for: 1 minute.
I use the Ctrl+Alt+L (I actually changed my shortcut to Ctrl+Alt+Spacebar) to lock the screen.
So when I am using the laptop the first thing I do is click on my Inhibit Applet in my top panel so my display does not go to sleep in 1 minute of inactivity.
When I am all done and want to lock the screen and turn off the monitor I click on the Inhibit Applet so it allows the sleep timer to work, and I hit my combination of keys to lock the screen Ctrl+Alt+L.
The Screen is locked and in 1 minute the display turns itself off.
Solution 3
Go to System settings > Keyboard > Shortcuts > new Custom shortcut and set command to:
bash -c "xset dpms force off; gnome-screensaver-command -l"
Then set a key combination, for example, ctrl + escape.
It worked on my desktop, but didn't work without the above bash
command.
Solution 4
I have tried this:
xset dpms force off && gnome-screensaver-command --lock && sleep 10
And it turns off display. Now make file called .turnScreenOff.pl and write this in that file, like using gedit ~/.turnScreenOff.pl
#!/usr/bin/perl `xset dpms force off && gnome-screensaver-command --lock && sleep 10`;
After that, go to terminal (to open Ctrl+Alt+T) and write in:
chmod +x .turnScreenOff.pl
Now what we will do: is just change lock screen command
To disable use Backspace. Than move on to Custom shuortcuts
Set name something like
turn screen off and lock screen
and set command to perl ~/.turnScreenOff.pl
And now select that and press buttons you want to set shortcut to, e.g. Ctrl+Alt+L or whatever you want :-)
Hope this helped.
Solution 5
Command that worked for me :
#!/usr/bin/perl
`gnome-screensaver-command --lock && sleep 5 && xset dpms force off `;
Somehow the lock command was switching on the screen back. Also the sleep was needed to fire the screen off after a delay.
Related videos on Youtube
TheKojuEffect
Updated on September 18, 2022Comments
-
TheKojuEffect over 1 year
When I lock screen, the display does turn black but the display isn't completely off. There is some light coming out of the display in screen lock mode but it get turned off when inactive for 10 minutes as configured from Brightness and Lock setting.
I tried
xset dpms force off
which completely turn off the display.Is there any way that when I press Ctrl + Alt + L to lock screen, the screen get locked and the display is completely turned off saving some power.
-
TheKojuEffect over 11 yearsThank You, but the method I used seems very easy for me.
-
geekQ about 11 years
sleep
was required for me -
Grzegorz about 8 yearswhy do you use PERL to call bash commands?
-
vishvAs vAsuki about 7 yearsA one line version which can be directly used:
bash -c "sleep 0.5; xset dpms force off; gnome-screensaver-command -l"
-
direwolf over 6 yearsDid not work for me as
gnome-screensaver
wakes up the screen. This one workedbash -c "gnome-screensaver-command -l; sleep 4; xset dpms force off"
.