a guest Feb 16th, 2012 125 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # Script for displaying stuff in the user's screen from ssh without `xhost +`, needs root.
- # See comments in http://superuser.com/a/153864/19668 for more details.
- # Also recommended: something like `export DISPLAY=:0` (and shellinabox for convenience!).
- # CC-BY Camilo Martin (camilomm.deviantart.com)
- # The first parameter is the user. If not supplied, use the current user.
- if [ -z "$1" ]; then
- # Check if user exists, report if doesn't.
- if ! id "$user" > /dev/null 2> /dev/null; then
- echo The user "'$user'" does not even exist.
- return 2
- # You'll need root.
- for x in $(sudo ls /var/run/gdm3/); do
- gdmuser=$(echo "$x" | grep auth-for-$user-)
- # Maybe the user is not running X, or GDM.
- if [ -z "$gdmuser" ]; then
- echo This user is likely either not running an X server, or is using something else than gdm3.
- return 3
- # Export it.
- export XAUTHORITY=$xauth
- # Done.
- echo "\$XAUTHORITY export set, with value '$xauth'"
- return 0
RAW Paste Data