#!/bin/sh
# Crude script to run command in user session. Works with DM started sessions only.
# Use: xdo 'command line'
# Equivalent to: su user -c 'command line'

command="$1"
w | while read user tty from blah ; do
[ "$tty" = "console" ] && echo "$from" grep -q ^: && DISPLAY="$from" XAUTHORITY="/home/$user/.Xauthority" su -c "$command" "$user" &
done
