Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want an executable script that changes screen configuration from 1 to 2 or from 2 to 1. I would need a boolean or a variable where the state is saved. It's that possible?

Otherwise, how can I check with xrandr if i'm using config 1 or 2?

share|improve this question

migrated from Nov 20 '12 at 12:58

This question came from our site for professional and enthusiast programmers.

1 Answer 1

You can probably ask xrandr what your current configuration is, and parse that output to decide.

However, failing that, to actually answer the question, the usual method for this is testing for the existence of a file:

if [ -f /tmp/screenstate1 ]; then
    rm /tmp/screenstate1
    echo "switching to state 2"
    touch /tmp/screenstate1
    echo "switching to state 1"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.