Turning Monitor Off With an Icon
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!
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.