5

I'm running Ubuntu 12.04 on my laptop and sometimes want to turn the display off immediately (without closing the lid and without waiting for it to turn off by itself). I'd prefer not to have to run a command to do this, so I created the "~/Documents/monitor-off.sh" script (making it executable):

#!/bin/bash
sleep 2
xset dpms force off

I then created the "~/.local/share/applications/monitor-off.desktop" file (also making it executable):

[Desktop Entry]
Name=Monitor Off
Exec=/home/nrogers64/Documents/monitor-off.sh
Icon=monitor
Terminal=true
Type=Application
StartupNotify=true

I'm not very familiar with Ubuntu and am wondering if this was the correct way to go about solving this problem or if this solution is overkill. Thanks!

5

As with most Unixy OSes, there are many ways to accomplish the same thing. What you have done works fine, and will work with most Ubuntu desktop environments.

Another way to do this (not using a true icon, but faster to implement) is to simply place the executable script on your desktop and double click it. This will prompt you to open the file or run it. If you click 'run' or 'run in terminal', it will lock the screen.

I think that your way is the best. Just highlighting another way.

0

Actually by going to "Brightness & Lock" in System Settings, and configure "Lock screen after" to "Screen turn off".

After which, locking your session either from the top upper left screen or Ctrl + Shift + L, will lock and turn off ur screen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.