Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
   3
   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
   8
   9 # Start XBMC without blocking this script
  10 xbmc &
  11
  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
  19
  20 # Force XBMC window to fullscreen
  21 #export SDL_VIDEO_FULLSCREEN_DISPLAY=1
  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

1 Answer 1

Add these lines at the top

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

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/__init__.py:57: GtkWarning: could not open display warnings.warn(str(e), _gtk.Warning) No protocol specified Error: unable to open display :1.0 No protocol specified FEH.py: cannot connect to X server :1.0 No protocol specified Cannot open display. –  Walkman 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 ? –  Walkman 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 –  Walkman Jan 12 '12 at 5:19
    
Maybe I should rather make an xbmc group whose files everybody can read, write in a shared folder... –  Walkman Jan 12 '12 at 5:20

Your Answer

 
discard

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.