You are not logged in.

#1 2023-05-15 17:36:36

francesco
Member
Registered: 2023-05-15
Posts: 17

(SOLVED): Turning off and on my laptop's screen on demand

Hello everyone,

For privacy and battery saving I'd like to sometimes turn off my screen and turn it on again when I need it on.
I'd also like to assign the screen off and on functions to a keyboard shortcut.
Since I'm blind I hardly need the screen except when I'm working with sighted peers.

I am using arch with the latest packages as of the 15th of may 2023 time 19:35 CEST and kernel 6.3.2-arch1-1 with KDE as my DE.

Thanks for any help.

Last edited by francesco (2023-06-08 17:06:00)

Offline

#2 2023-05-15 18:32:24

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,471
Website

Re: (SOLVED): Turning off and on my laptop's screen on demand

I would just add your user to the 'video' group, then write a brightness value to the backlight node in sysfs.  For example, on my lenovo laptop the following two commands set the brightness to zero (or off) and to full:

echo 0 >> /sys/class/backlight/intel_backlight/brightness 
echo 852 >> /sys/class/backlight/intel_backlight/brightness

You can then bind commands like these to key presses under KDE settings.  Or if you are running KDE under Xorg, you could also just use xbindkeys.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2023-05-15 20:44:56

francesco
Member
Registered: 2023-05-15
Posts: 17

Re: (SOLVED): Turning off and on my laptop's screen on demand

Thanks!
Is that different than setting my brightness value to zero in the kde systray? I ask because when I set it to zero the screen's content can still be seen

Offline

#4 2023-05-16 01:07:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,471
Website

Re: (SOLVED): Turning off and on my laptop's screen on demand

I'm not familiar with kde or what the systray widget does, but to a degree yes.  The commands above just adjust the backlight.  Technically depending on the lighting one can pick up hints of what's on the screen if they look close even when the backlight is completely off - but for the most part others wouldn't be able to see anything.  So if you want it completely off for high security reasons, then shutting off the backlight might not be sufficient, but for everything else I imagine it would be.

You could try it and ask friends / coworkers whether they can still make anything out on the screen.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2023-05-16 08:01:41

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,234

Re: (SOLVED): Turning off and on my laptop's screen on demand

You can try "sudo vbetool dpms off" (and "sudo vbetool dpms on") from the vbetool package, but be careful:
I just screwed myself testing that. It also killed any input here and consequently I wasn't able to break dpms or regain input (and didn't have sshd running either…)
Since this operates on the video bios, your results might be better - but be prepared to lose the system.

Offline

#6 2023-05-16 10:12:20

SimonJ
Member
From: Spain
Registered: 2021-05-11
Posts: 334
Website

Re: (SOLVED): Turning off and on my laptop's screen on demand

I used to do this and had a script which would toggle the display on and off with  a key board shortcut, the command was xrandr --output DVI-D-1  --mode 1920x1080 or off

Just another option :-)


Rlu: 222126

Offline

#7 2023-05-16 12:07:53

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,471
Website

Re: (SOLVED): Turning off and on my laptop's screen on demand

I don't think the xrandr option would work ... or more specifically, it would have undesirable side effects as KDE would (almost certainly) respond by removing the desktop that the OP interacts with through other mechanisms.  The goal is not for the entire backend representation of the output to be gone (which xrandr would do) but rather just for no actual signal to go to the display.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2023-05-16 12:22:49

SimonJ
Member
From: Spain
Registered: 2021-05-11
Posts: 334
Website

Re: (SOLVED): Turning off and on my laptop's screen on demand

Trilby wrote:

I don't think the xrandr option would work ... or more specifically, it would have undesirable side effects as KDE would (almost certainly) respond by removing the desktop that the OP interacts with through other mechanisms.  The goal is not for the entire backend representation of the output to be gone (which xrandr would do) but rather just for no actual signal to go to the display.

Ah OK, it works on XFCE4 but I have no experience of KDE, well since 3.5 anyway.


Rlu: 222126

Offline

#9 2023-05-16 15:08:06

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,234

Re: (SOLVED): Turning off and on my laptop's screen on demand

There's however something else I realized when sseing SimonJ's post

xrandr --output DVI-D-1 --brightness 0
xrandr --output DVI-D-1 --brightness 1

This fakes backlight changes and while it will not save any battery (you'll still have to alter the *_backlight/brightness) it will provide the security feature because the output is rendered black.

Offline

#10 2023-05-16 17:42:21

espritlibre
Member
Registered: 2022-12-15
Posts: 138

Re: (SOLVED): Turning off and on my laptop's screen on demand

francesco wrote:

Thanks!
Is that different than setting my brightness value to zero in the kde systray? I ask because when I set it to zero the screen's content can still be seen

i'm not familiar with kde but i doubt that if you ramp down the brightness in the systray that the value gets set to zero, maybe more like 3 or 4 to prevent user error.

Offline

#11 2023-05-16 19:09:47

francesco
Member
Registered: 2023-05-15
Posts: 17

Re: (SOLVED): Turning off and on my laptop's screen on demand

Hey guys,

Thanks for all your answers!

Tomorrow I'll have a look at all the options, except those that either wouldn't work or would be too risky and give you feedback on what happens.

Offline

#12 2023-05-18 09:21:23

francesco
Member
Registered: 2023-05-15
Posts: 17

Re: (SOLVED): Turning off and on my laptop's screen on demand

Hey guys,

I tried both "sudo vbetool dpms off" and "xrandr --output DVI-D-1 --brightness 0".
The first command gives me "Real mode call failed" as output while the second command gives me "warning: output DVI-D-1 not found; ignoring
xrandr: Need crtc to set gamma on."

Offline

#13 2023-05-18 09:24:02

SimonJ
Member
From: Spain
Registered: 2021-05-11
Posts: 334
Website

Re: (SOLVED): Turning off and on my laptop's screen on demand

If you type

xrandr | grep connected

It will show the device name for your setup, then substitute for the DVI-D-1  in the example


Rlu: 222126

Offline

#14 2023-05-18 11:46:38

Mortimer Houghton
Member
Registered: 2014-09-28
Posts: 89

Re: (SOLVED): Turning off and on my laptop's screen on demand

You can also use wlr-randr on wayland as a substitute for xrandr

https://aur.archlinux.org/packages/wlr-randr

Last edited by Mortimer Houghton (2023-05-18 11:47:31)

Offline

#15 2023-05-18 17:48:31

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,248

Re: (SOLVED): Turning off and on my laptop's screen on demand

That only works on wl roots compositors and won't work with Kwin

Offline

#16 2023-05-20 12:23:42

francesco
Member
Registered: 2023-05-15
Posts: 17

Re: (SOLVED): Turning off and on my laptop's screen on demand

Hey guys,

When trying the grep command with xrander, here's the output, isn't it strange?

"eDP connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 2
93mm x 165mm
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1 disconnected (normal left inverted right x axis y axis)"

Offline

#17 2023-05-20 12:38:53

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,234

Re: (SOLVED): Turning off and on my laptop's screen on demand

No, the relevant output name is "eDP"

Have somebody with a porn-compatible bio-infrastructure (working eyes wink next to you and run

xrandr --output eDP --brightness 0; sleep 10; xrandr --output eDP --brightness 1

The screen should turn black and then back on 10 seconds later.

Notice again that this will NOT save any power, just provide visual cover.
For the battery, you'll have to adjust the backlight.

Offline

#18 2023-05-20 16:40:27

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,471
Website

Re: (SOLVED): Turning off and on my laptop's screen on demand

seth wrote:

... a porn-compatible bio-infrastructure (working eyes wink

Clearly you've never heard (of) ASMR porn...  SCNR


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#19 2023-05-20 17:00:22

francesco
Member
Registered: 2023-05-15
Posts: 17

Re: (SOLVED): Turning off and on my laptop's screen on demand

LOL guys, thanks! I'll do exactly what 17 suggested hahaha! Thanks again! I'll et you know what happens.
Am I correct in assuming that if I do everything before the first ; the screen will just turn black ad do nothing else untill I turn it back on with... say... Brightness 50?

PS, beeing blind gets ya some advantages, such as turning off your screen and hmm... well, I'll let you think on that LOL.

Offline

#20 2023-05-20 19:46:34

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,234

Re: (SOLVED): Turning off and on my laptop's screen on demand

The sane range is [0,1] - 50 turns the output essentially white.

Offline

#21 2023-06-08 17:00:31

francesco
Member
Registered: 2023-05-15
Posts: 17

Re: (SOLVED): Turning off and on my laptop's screen on demand

Hey guys,

Sorry for taking so long to try this stuff out and getting back to you, but school was taking all my time, not anymore!

The command that post 17 suggested works like a charm!
@20, thanks for teh range, it is most appreciated!

Offline

Board footer

Powered by FluxBB