Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # 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
- user=$(whoami)
- else
- user=$1
- fi
- # 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
- fi
- # You'll need root.
- for x in $(sudo ls /var/run/gdm3/); do
- gdmuser=$(echo "$x" | grep auth-for-$user-)
- xauth=/var/run/gdm3/$gdmuser/database
- done
- # 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
- fi
- # Export it.
- export XAUTHORITY=$xauth
- # Done.
- echo "\$XAUTHORITY export set, with value '$xauth'"
- return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement