Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 use this script to launch XBMC:

#! /bin/bash
# Launch XBMC in windowed mode, then use wmctrl to remove the titlebar


# Start XBMC without blocking this script
xbmc &

# Wait for the XBMC window to appear
while [ $status -eq 0 ]
    sleep 1
 status=`wmctrl -x -l | grep "XBMC Media Center" | wc -l | awk '{print $1}'`

# Force XBMC window to fullscreen
wmctrl -x -t 0 -r XBMC Media Center.XBMC Media Center -b toggle,fullscreen

but the DISPLAY variable always changing... Why ? (I never change any configuration options) Sometimes it's 0.1, sometimes it's 0.0.
How should I modify the script to run whatever the value is, or what's a better solution ?

share|improve this question
Are you logging in as multiple users (switch user) ? – bodhi.zazen Jan 10 '12 at 23:28
I don't understand your question :D how can you log in as multiple users ? If you mean that multiple user are logged in to the same machine, yes! – kissgyorgy Jan 11 '12 at 0:20
up vote 0 down vote accepted

Each user gets his or her own DISPLAY (Actually each X session), so they will change as users log in / log off and as you use the switch user feature.

share|improve this answer
ok, but how can I determine from the script which is the right DISPLAY right now ? – kissgyorgy Jan 11 '12 at 3:41
echo $DISPLAY or using $DISPLAY in a script will work for your current user. w | awk '/user_name/ {print $3}' will work for other users. – bodhi.zazen Jan 11 '12 at 4:23
So I just remove the DISPLAY variable setting line. LOL. Thanks ! – kissgyorgy Jan 11 '12 at 5:33

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.