Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 stackoverflow.com Nov 20 '12 at 12:58

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

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"
else
    touch /tmp/screenstate1
    echo "switching to state 1"
fi
share|improve this answer

You must log in to answer this question.