Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 2060  / 2 Years ago, thu, june 9, 2022, 11:01:45

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!


More From » unity

 Answers
3

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.


[#29759] Saturday, June 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aclavadoug

Total Points: 317
Total Questions: 103
Total Answers: 125

Location: Bangladesh
Member since Wed, Mar 24, 2021
3 Years ago
;