I have a script in /etc/acpi that runs when I close my laptop's lid. It turns off the internal monitor. It does this by

                export DISPLAY=:0
                sudo -u toothrot xset dpms force off

This works fine, but it would be neater if it didn't depend on my being logged in as toothrot. Is there a way to do it directly from root, without reference to a particular X-session? I tried

            # echo Off >/sys/class/drm/card0/card0-eDP-1/dpms

but got permission denied.

Note that setting the brightness to 0 will not do, since it doesn't save any power.

  • Have you done it as root? – Rui F Ribeiro Jul 24 '18 at 17:54
  • Obviously the that one wont work. I am asking about the echo. – Rui F Ribeiro Jul 24 '18 at 18:00
  • On my FreeBSD I use vbetool dpms off, as Debian also has a vbetool package I guess it's not FreeBSD-specific. – Henrik Jul 24 '18 at 20:40
  • @Henrik, I have vbetool, but for some reason that doesn't do anything on my system. – Toothrot Jul 24 '18 at 22:49
  • If your X server is being run with -auth /some/file then you should be able to run as root, eg DISPLAY=:0 XAUTHORITY=/some/file xset ... – meuh Jul 25 '18 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.