Skip to content

Instantly share code, notes, and snippets.

@AladW
Created October 24, 2015 14:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AladW/de1c5676d93d05a5a0e1 to your computer and use it in GitHub Desktop.
Save AladW/de1c5676d93d05a5a0e1 to your computer and use it in GitHub Desktop.
#!/bin/bash
pid=$(pgrep -t tty$(fgconsole) xinit)
pid=$(pgrep -P $pid -n)
import_environment() {
(( pid )) && for var; do
IFS='=' read key val < <(egrep -z "$var" /proc/$pid/environ)
printf -v "$key" %s "$val"
[[ ${!key} ]] && export "$key"
done
}
import_environment XAUTHORITY USER DISPLAY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment