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

It's a little bit complicated as other "how can I run" questions, firstly, because I use this script to run on second screen (TV) full size:

   1 #! /bin/bash
   2 # Launch XBMC in windowed mode, then use wmctrl to remove the titlebar
   4 # Select display 1
   5 # Separate X screennél 0.1 kell
   6 # twinviewnél meg egy monitor van, azaz 0.0
   7 DISPLAY=:0.0
   9 # Start XBMC without blocking this script
  10 xbmc &
  12 # Wait for the XBMC window to appear
  13 status=0
  14 while [ $status -eq 0 ]
  15 do
  16     sleep 1
  17  status=`wmctrl -x -l | grep "XBMC Media Center" | wc -l | awk '{print $1}'`
  18 done
  20 # Force XBMC window to fullscreen
  22 wmctrl -x -t 0 -r XBMC Media Center.XBMC Media Center -b toggle,fullscreen

and second, because XBMC want to connect to the other user's screen. I don't know anything about X sessions or how the screen permissions working. Is it possible at all ?

So how can I achieve that "kati" user could run this script as "walkman" user fully, but not anything else ?

share|improve this question

Add these lines at the top

if [[ ! $EUID == walkman_uid ]] ; then
    echo "this script must be run as walkman"
    exit 1

If you do not know the uid of walkman, run

id walkman | awk '{print $1}'

As kati, run

sudo -u walkman /full/path/to/script

Personally I would put the script in /usr/local/bin and have it owned by root.

share|improve this answer
this doesnt work it says: /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/ GtkWarning: could not open display warnings.warn(str(e), _gtk.Warning) No protocol specified Error: unable to open display :1.0 No protocol specified cannot connect to X server :1.0 No protocol specified Cannot open display. – kissgyorgy Jan 11 '12 at 8:02
So, it is running as "walkman" user but want to connect to "kati"-s screen to which walkman have no permission ? – kissgyorgy Jan 11 '12 at 8:05
It is a security feature. Take a look at xhost ;) – bodhi.zazen Jan 11 '12 at 16:04
Now 06:16:37 T:140539983558528 ERROR: Unable to open audio mixer – kissgyorgy Jan 12 '12 at 5:19
Maybe I should rather make an xbmc group whose files everybody can read, write in a shared folder... – kissgyorgy Jan 12 '12 at 5:20

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.