-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathxc
More file actions
executable file
·23 lines (16 loc) · 758 Bytes
/
xc
File metadata and controls
executable file
·23 lines (16 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# Runs xtools/xchroot with some predefined stuffs
if [ "$(id -u)" -ne 0 ]; then
>&2 echo "This script must be run as root"
exit 1
fi
command -v xhost >/dev/null && xhost || { >&2 echo "xhost not installed, GUI forwarding and system clipboard won't work"; }
root_path="$(realpath "$1")"
xauth_path="$root_path/root/.Xauthority"
x11_socket_path="$root_path/tmp/.X11-unix"
user=$(stat -c '%U' "$0") || exit_with_failure
user_home=$(cat /etc/passwd | awk "/^$user:/" | cut -d: -f6)
touch "$xauth_path" && mount --bind "$user_home/.Xauthority" "$xauth_path"
touch "$x11_socket_path" && mount --bind /tmp/.X11-unix "$x11_socket_path"
TERM=linux XAUTHORITY="/root/.Xauthority" xchroot "$root_path" $2
umount -R "$xauth_path" "$x11_socket_path"