Created
September 9, 2024 07:55
-
-
Save GongT/01e1db2e062419173e72862100d50217 to your computer and use it in GitHub Desktop.
expose VSCode remote socket to all user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
SHOULD_CONNECT= | |
for SOCKET_FILE in "/run/user/$UID/vscode-ipc-"*.sock; do | |
if socat -u OPEN:/dev/null "UNIX-CONNECT:$SOCKET_FILE" &>/dev/null; then | |
echo "may connect? $SOCKET_FILE" >&2 | |
SHOULD_CONNECT=$SOCKET_FILE | |
else | |
echo "delete ununsed socket: $SOCKET_FILE" >&2 | |
unlink "$SOCKET_FILE" | |
fi | |
done | |
if [[ $SHOULD_CONNECT ]]; then | |
exec /usr/lib/systemd/systemd-socket-proxyd --exit-idle-time=10s "$SHOULD_CONNECT" | |
else | |
echo "no socket exists" >&2 | |
exit 233 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=expose VSCode remote to all user | |
Requires=vscode-remote.socket | |
After=vscode-remote.socket | |
[Service] | |
Type=notify | |
WorkingDirectory=%Y | |
ExecStart=/usr/bin/bash start-proxy.sh | |
NotifyAccess=all | |
RestartPreventExitStatus=233 | |
Restart=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=expose VSCode remote to all user | |
[Install] | |
WantedBy=sockets.target | |
[Socket] | |
ListenStream=/tmp/vscode-remote.socket | |
Service=vscode-remote.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment