3

In my new laptop in Xubuntu 16.04 toggle screen Fn button is not working so I need to write a script that will toggle the display, for this to work I need to check if screen is on or off, how can I do that from command line?

I can use:

sudo vbetool dpms off/on

but I need to know which command to execute, I didn't test it yet because will need to turn my display on after I turn in off.

jcubic
  • 916
  • 5
  • 16
  • 30

2 Answers2

1

I've ended up with this script:

#!/bin/bash

file=/tmp/display

if [ -e $file ]; then
    rm $file
    sudo vbetool dpms on

else
    touch $file
    sudo vbetool dpms off
fi
jcubic
  • 916
  • 5
  • 16
  • 30
0

xrandr can list the on screens for you. You can then grep any or all of their id's from there:

xrandr --listmonitors

I wrote a bash screen toggle script using it and mentioned it in a similar question: Lubuntu: hotkey to toggle displays

  • I'm using Fedora right now and when I've run xrandr when laptop lid is closed (it turn off the screen) I have the same output as when it's open (screen on). The output say connected and I also have error about size of gamma. – jcubic Dec 14 '17 at 12:40