Skip to content

Instantly share code, notes, and snippets.

@heddxh
Last active June 14, 2024 04:19
Show Gist options
  • Save heddxh/57ca9496ab3c77fbbd5bf9ca6f1efb9f to your computer and use it in GitHub Desktop.
Save heddxh/57ca9496ab3c77fbbd5bf9ca6f1efb9f to your computer and use it in GitHub Desktop.
Pacman hook to patch visual-studio-code-bin launch script in official binary, adding `exec` to make VSCode launch in correct cgroup with systemd-run
[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = visual-studio-code-bin
[Action]
Description = Patching vscode official launch script to avoid lauching in wrong cgroup...
Exec = /usr/bin/sed -i -e '$d' -e 's/ELECTRON_RUN_AS_NODE=1 "\$ELECTRON" "\$CLI" "\$@"/ELECTRON_RUN_AS_NODE=1 exec "$ELECTRON" "$CLI" "$@"/' /opt/visual-studio-code/bin/code
When = PostTransaction
@heddxh
Copy link
Author

heddxh commented Jun 14, 2024

The problem is, vscode is launched with ELECTRON_RUN_AS_NODE=1 without exec.
When using systemd-run to launch it as a service/scope, it will exit immediately.
Maybe because the script's PID is watched by systemd but it quit after run as node process, and systemd think the process has finished and remove the service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment