No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runx 491B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. #
  3. # pbrisbin 2014 - run X programs from outside of the X session, as the normal
  4. # user or root. Looks up XAUTHORITY dynamically, but assumes the X session is on
  5. # DISPLAY :0.
  6. #
  7. ###
  8. xauthority() {
  9. ps -C xinit -f --no-header | sed 's/.*-auth //; s/ -[^ ].*//'
  10. }
  11. if [ -z "$1" ]; then
  12. printf "usage: runx <command> [argument, ...]\n" >&2
  13. exit 64
  14. fi
  15. if [ $UID -eq 0 ]; then
  16. printf -v cmd "%q " "$@"
  17. set -- su patrick -c "$cmd"
  18. fi
  19. DISPLAY=:0 XAUTHORITY="$(xauthority)" "$@"