5

Background

For some reason, X11 / lightdm crashes when pressing the monitor's power button. Instead, running xset dpms force off puts the monitor into low-power mode, which is fine and works around pressing the problematic power button.

Running Arch Linux.

Problem

After pressing a key to switch the monitor back for work, the screen will go blank when the computer is idle for several minutes. I'd like to disable that behaviour.

Question

How would you write a bash alias (e.g., off) that:

  1. Turns the monitor "off" (lower power mode).
  2. Ensures no screen blanking or timeouts after re-enabling the monitor.

For example:

alias off='xset dpms force off ; wait until keypress ; xset -dpms'

Is there a simpler solution?

Giacomo1968
  • 58,727
Dave Jarvis
  • 3,427

2 Answers2

6

Try:

xset dpms 65535 65535 65535

This will set dpms not to automatically activate until the machine has be idle for 18.2... hours. You can make it shorter by changing the number of seconds, but that value is apparently the limit.

I would recommend this for your ~/.xsession or ~/.xinitrc or some similar file that is run when you login to or start your X server. (Possibly wherever the current xset -dpms is.) With this, xset dpms force off will still work.

David G.
  • 314
3

Create $HOME/bin/await.sh:

#!/usr/bin/env bash

xinput test-xi2 --root 2>&1 |
grep --line-buffered -m 1 'EVENT type 2 (KeyPress)' &> /dev/null

Use it:

alias off='xset dpms force off && await.sh && xset -dpms'
Dave Jarvis
  • 3,427