You are not logged in.

#1 2009-02-24 19:33:30

vinicius
Member
Registered: 2009-02-07
Posts: 37

[SOLVED] How to turn off monitor at CLI

Hi

    I've been trying to find a way to turn off my monitor, but the solutions I've found were almost all for X environment.

    The best hint I've got was add following lines to /etc/rc.local:

setterm -blank 1
setterm -powersave on
setterm -powerdown 1

With that, monitor was suppose to blank screen after 1 minute and, after another 1 minute, shutdown. But it only blanks and nothing more. Without the first line: "setterm -blank 1", it just don't do anything.

    Does anybody has idea of what else should I try?

    Thanks in advance.

Last edited by vinicius (2009-02-27 02:48:43)

Offline

#2 2009-02-24 20:07:49

Hrod beraht
Member
Registered: 2008-09-30
Posts: 186

Re: [SOLVED] How to turn off monitor at CLI

I like slock.
Run it, and it both locks the screen and puts the monitor to sleep. To unlock, just type your password and press enter.

Or do you mean from console, rather than a terminal?

Bob

Last edited by Hrod beraht (2009-02-24 20:11:03)

Offline

#3 2009-02-24 20:42:23

vinicius
Member
Registered: 2009-02-07
Posts: 37

Re: [SOLVED] How to turn off monitor at CLI

Hrod beraht wrote:

Or do you mean from console, rather than a terminal?

Hi, Bob

It's exactly that: I am using the console without a X server running.

Thanks for your reply. smile

P.S.: For those little confused with terminology (like me big_smile ), here is a fast explanation http://www.linuxforums.org/forum/linux- … xterm.html

Offline

#4 2009-02-24 23:18:41

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: [SOLVED] How to turn off monitor at CLI


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#5 2009-02-25 02:49:38

vinicius
Member
Registered: 2009-02-07
Posts: 37

Re: [SOLVED] How to turn off monitor at CLI

Hi, dyscoria

In fact, when I started searching before post my question, I've found that thread you pointed and was from there that I got setterm hint.
The other suggestions there only work at X environment and I am not starting X.

Thanks for helping.

Offline

#6 2009-02-25 14:09:09

nesna
Member
Registered: 2009-02-20
Posts: 4

Re: [SOLVED] How to turn off monitor at CLI

Are you trying to just turn off the monitor but have the OS running or are you trying to do suspends, hibernates and that sort of thing?

Offline

#7 2009-02-25 14:18:10

vinicius
Member
Registered: 2009-02-07
Posts: 37

Re: [SOLVED] How to turn off monitor at CLI

nesna wrote:

Are you trying to just turn off the monitor but have the OS running or are you trying to do suspends, hibernates and that sort of thing?

Just turn off the monitor.

Offline

#8 2009-02-25 23:15:25

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: [SOLVED] How to turn off monitor at CLI

I like vlock

Offline

#9 2009-02-26 00:03:41

vinicius
Member
Registered: 2009-02-07
Posts: 37

Re: [SOLVED] How to turn off monitor at CLI

Daenyth wrote:

I like vlock

Daenyth,
This is really useful! I didn't know vlock and I liked it very much. big_smile
Thak you.

But it doesn't turn off the monitor. sad

Last edited by vinicius (2009-02-26 00:04:40)

Offline

#10 2009-02-26 20:26:40

vinicius
Member
Registered: 2009-02-07
Posts: 37

Re: [SOLVED] How to turn off monitor at CLI

Hi, guys

I've found something interesting:

# vbetool dpms off

This command turns off the monitor regardless of X is running or not. So, this is almost the answer I'm looking for.
Now, let me explain that almost.
There are two bad points to consider about this command:

1- Only super user is able to run it. (Actually, it's not a big deal. The computer is mine - I am a super user! big_smile )

2- The only way to turn on monitor back is with

# vbetool dpms on

and (this is the boring part) monitor is still off until you finish typing that and hit <enter>.

Do you have idea of how to make monitor power on again just by pressing any key?

Vinicius

Offline

#11 2009-02-26 21:27:37

Nezmer
Member
Registered: 2008-10-24
Posts: 559
Website

Re: [SOLVED] How to turn off monitor at CLI

Well . It's not a perfect solution but why don't you use aliases ?

In /root/.bashrc (If you're using bash)

alias von='vbetool dpms on'
alias voff='vbetool dpms off'

Last edited by Nezmer (2009-02-26 21:28:01)


English is not my native language .

Offline

#12 2009-02-27 02:46:25

vinicius
Member
Registered: 2009-02-07
Posts: 37

Re: [SOLVED] How to turn off monitor at CLI

Hi, Nezmer
Even with aliases, I would have to type von with monitor turned off.

I've done a script, witch is not a perfect solution, but works fine.

monitor_off:

#!/bin/bash

###################################################
# Check if X is running or not, turn off monitor, #
# wait for a key press and turn it on again.      #
###################################################

grep_result_file=$PWD'/x_running'

# Check if X is running.
ps -e | grep -e "\bX\b" > $grep_result_file
ps -e | grep -e "\bxorg\b" >> $grep_result_file
ps -e | grep -e "\bxserver\b" >> $grep_result_file

## If you want to check result file, uncomment following lines.
#echo "===== $grep_result_file - begin ====="
#cat $grep_result_file
#echo "===== $grep_result_file -  end  ====="

if [ ! -s $grep_result_file ] || [[ $(tty) =~ tty ]] || [[ $(tty) =~ vc ]]; then
    echo 'Detected X not runnig or you are at console...'
    if [ $UID -ne 0 ]; then
        echo 'You need super user privileges to run this script at console.'
        echo 'Rerun as super user or start X and run from a terminal.'
        exit 0
    fi
    turn_off='vbetool dpms off'
    turn_on='vbetool dpms on'
else
    echo 'Detected X running...'
    turn_off='xset dpms force off'
fi

echo 'Turning off monitor...'
$turn_off

echo 'Waiting for a key press...'
read -n1 -s

echo 'Turning on monitor...'
$turn_on

rm $grep_result_file

echo 'Finished: monitor_off'

It checks if X is running or not because at X environment vbetool was a little slow, at least for me.

That's it!
I hope this could be useful for someone else.

Thank you for helping, guys. smile

Vinícius

P.S.: I'm setting this thread as solved, but any suggestion about the script is welcome. big_smile

Offline

#13 2009-05-24 08:39:27

fedfol
Member
Registered: 2009-05-15
Posts: 15

Re: [SOLVED] How to turn off monitor at CLI

Thanks vinicius i was looking for something to turn off my laptop (that now acts as a home server) from ssh to save some power and vbetool is perfect big_smile

Offline

#14 2010-06-22 21:46:44

gerteb
Member
Registered: 2010-06-22
Posts: 1

Re: [SOLVED] How to turn off monitor at CLI

Thanks. It was just what i were looking for. Using it on a small netbook running smeserver, but wouldn't let others have easy access as root.

If the you add the line "kill -9 $PPID" as last line. The script will logout of the shell, and show the login message. No root access ;-)

Offline

#15 2010-11-07 18:42:44

killua
Member
Registered: 2010-04-12
Posts: 8

Re: [SOLVED] How to turn off monitor at CLI

Thanks.vbetool is what i need.
#visudo
add this line: username   ALL=NOPASSWD:/usr/sbin/vbetool  ,so no need password.
and i assign a key to turn off ,another to turn on in openbox rc.xml,it's done ^_^

Offline

#16 2010-11-10 06:21:04

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,085

Re: [SOLVED] How to turn off monitor at CLI

Please don't necro-bump old threads..

Closing...


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

Board footer

Powered by FluxBB