You are not logged in.

#1 2018-08-23 17:55:13

doubleslash
Member
Registered: 2011-08-16
Posts: 80

[SOLVED]Turn screen off

Hi,
I have i3 for my window manager and have it run the code

 xset dpms force off

to turn off the screen when I press a certain key. It can turn off, but when it's woke back up, the mouse and keyboard don't work. How can I fix this? In my i3 config file I have this

bindsym $mod+F2 exec --no-startup-id xset dpms force off

Thanks

Last edited by doubleslash (2018-08-27 15:50:39)

Offline

#2 2018-08-23 19:55:26

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

Re: [SOLVED]Turn screen off

Check your xorg log and dmesg t see what happens to the input devices.
Also elaborate on your setup (notably: is the "screen" an external monitor w/ a USB hub where your input devices are plugged?) and how the devices "don't work" (does the pointer still move?  are the devices powered, ie. do their LEDs light? Can you maybe still switch the numlock state?)

Also: is this effect limited to the shortcut or does the same happen if you run xset from an interactive shell?

Offline

#3 2018-08-24 16:50:51

doubleslash
Member
Registered: 2011-08-16
Posts: 80

Re: [SOLVED]Turn screen off

My setup is just a regular laptop. The cursor moves but the keyboard can't input the characters. It doesn't happen if I run xset from an interactive shell

Offline

#4 2018-08-24 19:11:55

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

Re: [SOLVED]Turn screen off

Sounds as if DPMS "confuses" i3 in a way that it stops processing (incl. focus distribution, possibly any input handling) events.
Try to "sleep 1" before xset, possibly forking the command in a subshell, (sleep 1; xset dpms force off) &, to give yourself time to release the key?

Offline

#5 2018-08-24 21:33:27

doubleslash
Member
Registered: 2011-08-16
Posts: 80

Re: [SOLVED]Turn screen off

There seems to be something wrong with the syntax. I tried

 bindsym $mod+F2 exec (sleep 1; xset dpms force off) & 

and

 bindsym $mod+F2 exec sleep 1; xset dpms force off

but I get the error

ERROR: Expected one of these tokens <end>, '[', 'move', 'exec', 'exit', ...

Last edited by doubleslash (2018-08-24 21:33:51)

Offline

#6 2018-08-24 21:36:24

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

Re: [SOLVED]Turn screen off

I've like zero experience w/ i3, but apparently the exec command has limited shell syntax support - try to wrap the command into a script and bind that.

Offline

#7 2018-08-27 15:47:20

doubleslash
Member
Registered: 2011-08-16
Posts: 80

Re: [SOLVED]Turn screen off

I created a script screenoff.sh

sleep 1; xset dpms force off &

and bind it to a keystroke like this

 bindsym $mod+F2 exec --no-startup-id screenoff.sh

Last edited by doubleslash (2018-08-27 16:22:13)

Offline

#8 2024-02-13 02:48:24

leolace
Member
Registered: 2024-02-13
Posts: 1

Re: [SOLVED]Turn screen off

or you can just

bindsym $mod+F2 exec "i3lock -c '#212121' && sleep 1 && xset dpms force off"

(do not forget the quotes marks)

Last edited by leolace (2024-02-13 02:48:54)

Offline

#9 2024-02-13 09:06:50

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

Re: [SOLVED]Turn screen off

Note your necrobumping a 6 year old thread. Please don't bump solved posts, to essentially mention the same thing again.

Closing.

Offline

Board footer

Powered by FluxBB