Turning off your screens in one click or with a hot key

I like to save energy and spare my laptop of unnecessary strains, and I sometimes get annoyed when I leave my computer for a break and only come back in my office to see that my three screens are still on with full luminosity. Of course I could set an automatic screensaver timing, but I also find that annoying because it gets triggered while I'm watching a video.

Command to turn off screens

If you, like me, enjoy being able to turn off all your screens in one click, here is a very simple solution:

Create a shell script that runs this command: sleep 2 && xset dpms force off

This will turn off all your screens within two seconds.

The file should be set as executable, if it is not, you can set it up manually.

Using a hot key

If, instead of running the script through the command line or by clicking the file, you'd like to set up a hot key, go to System > Preferences > Keyboard Shortcuts

and click on "+ Add".

Type a name, such as: Turn off screen

Now, I have noticed on my machine that if you enter the following line in the command field:/path/to/your/script/script_name.sh (replace path and filename to the one you made)

the screens are turned off after 2 seconds.

Your new Action will appear at the bottom of the window, inside "Custom Shortcuts".

On the right of the line, you will see under the "Shortcut" column "Disabled".

Click on it, and then press the shortcut key you would like to assign to it. Make sure it isn't already used.