There are times when I want to turn off the displays on my workstation, but not actually lock it. In this Linux quicktip we will show you how to turn your displays off using the command line. We will also show you how to use that command as a keyboard shortcut, or HotKey.
Turn Display Off From the Linux Command Line
To turn your display(s) off from the command line we will use the xset
utility.
xset dpms force off
The xset
utility allows you to change user preference options for the display. The dpms
part is specific Energy Star parameters or options. We use force off
to tell the system to instantly switch dpms
to the off
state.
Set Keyboard Shortcut to Turn Off Display
In Gnome you can easily create a shortcut to trigger this command.
First, go into setting by selecting the top right tray.
From the settings menu, select "Keyboard Shortcuts".
Now scroll all the way to the bottom of the list. There you will find a plus sign at the bottom of the list that allows you to add your own custom shortcuts.
When you click the plus sign you will be shown the "Add Custom Shortcut" window which requires some input. First, let's name it something relevant. For this example I named the shortcut "Display Off".
In the command section we will call the xset
utiltiy, just as we did on the command line above.
Last, we need to set the shortcut. Just click it and then enter the key, or keys you want to use. For this example I chose Super+D, which is purposely close to Super+L, which I use all the time.
That's it, click the Add button and you are all set.
Conclusion
Now you can easily turn off your monitors from the Linux command line, or the Gnome Keyboard Shortcuts. We hope you found this quick tip helpful
Resources and Links
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
6 Comments
Join Our Newsletter
Categories
- Bash Scripting (17)
- Basic Commands (50)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (65)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)
After using the command, the screen goes off, but come back on immediately. How to solve it?
Info: Linux Mint 20.2 (Uma) Cinnamon
The X server is detecting the "key release" events as you take your fingers off the keyboard, and turns the display back on again. To fix this, write a simple script like this:
sleep 0.5; xset dpms force off
Put these commands in a file eg /usr/local/bin/blank.sh
Make the file executable: chmod +x /usr/local/bin/blank.sh
Now modify your Short Cut command to be /usr/local/bin/blank.sh
The 0.5 second sleep delay gives you enough time to release the keys before the display blanks.
doesn't seem to work for me
Thank you for this <3 I'm on DEbian 11, XFCE 👍
Works in Manjaro. BTW, hold the trigger key(s) down for a second or two to prevent the screen from coming right back on.
This does not work on Wayland sessions since no dpms support.