Skip to content

Instantly share code, notes, and snippets.

@w568w
Last active February 19, 2026 18:10
Show Gist options
  • Select an option

  • Save w568w/0999f61e9a646feac3f5a46aaa17e1d1 to your computer and use it in GitHub Desktop.

Select an option

Save w568w/0999f61e9a646feac3f5a46aaa17e1d1 to your computer and use it in GitHub Desktop.
Antigravity workaround
#!/bin/bash
readonly UNIT_NAME="antigravity-$(date +%s)"
readonly APP_BIN="/usr/bin/antigravity --verbose"
readonly TRIGGER="Lifecycle#onWillShutdown - end 'antigravityAnalytics'"
echo "[*] Start as: $UNIT_NAME"
systemd-run --user \
--scope \
--unit="$UNIT_NAME" \
--property=KillMode=control-group \
/bin/bash -c "exec prlimit --core=0 $APP_BIN 2>&1 | systemd-cat --identifier=$UNIT_NAME" &
journalctl --user --identifier="$UNIT_NAME" --follow | \
grep --line-buffered --max-count=1 "$TRIGGER" && \
systemctl --user kill --signal=SIGKILL "$UNIT_NAME.scope"
echo "[*] Remaining processes are killed."
@0blivi0nis
Copy link

Thank you! This is perfect and fixes the high cpu and leftover process issue. Modified the exec for the app to point to the script and it works perfectly

@nervocalm
Copy link

I didn't test it yet but found it in the AUR page, and I wanted to say thank you for sharing it!

@everyx
Copy link

everyx commented Jan 15, 2026

A version of fish shell and alias code to antigravity:

function code --wraps=antigravity --description 'alias code=antigravity'
    set -l UNIT_NAME "antigravity-"(date +%s)
    set -l APP_BIN "/usr/bin/antigravity --verbose"
    set -l TRIGGER "Lifecycle#onWillShutdown - end 'antigravityAnalytics'"
    set -l ARGV $argv

    begin
        systemd-run --user --scope --unit="$UNIT_NAME" --property=KillMode=control-group \
            /bin/bash -c "exec prlimit --core=0 $APP_BIN $argv 2>&1 | systemd-cat --identifier=$UNIT_NAME" & disown

        fish -c "
            journalctl --user --identifier=$UNIT_NAME --follow | \
            grep --line-buffered --max-count=1 $TRIGGER >/dev/null 2>&1; and \
                systemctl --user kill --signal=SIGKILL $UNIT_NAME.scope
        " & disown
    end >/dev/null 2>&1
end

@topmask
Copy link

topmask commented Jan 24, 2026

zsh shell Is there any?

@sharp2448
Copy link

sharp2448 commented Feb 19, 2026

@topmask here you go zsh version of the original Antigravity workaround

# Wrapper for Antigravity to handle cleanup and core dumps
antigravity() {
    # Generate a unique ID for this session
    local UNIT_NAME="antigravity-$(date +%s)"
    local APP_BIN="/usr/bin/antigravity"
    local TRIGGER="Lifecycle#onWillShutdown - end 'antigravityAnalytics'"

    echo "[*] Starting Antigravity as systemd unit: $UNIT_NAME"

    # 1. Run the app in a systemd scope to track all child processes.
    # We use prlimit to disable core dumps and systemd-cat to forward logs.
    systemd-run --user \
        --scope \
        --unit="$UNIT_NAME" \
        --property=KillMode=control-group \
        /bin/bash -c "exec prlimit --core=0 \"$APP_BIN\" --verbose \"\$@\" 2>&1 | systemd-cat --identifier=\"$UNIT_NAME\"" -- "$@" &

    # 2. Monitor the journal for the shutdown signal. 
    # Once detected, kill the entire control group to clean up lingering processes.
    journalctl --user --identifier="$UNIT_NAME" --follow 2>/dev/null | \
        grep --line-buffered --max-count=1 "$TRIGGER" && \
        systemctl --user kill --signal=SIGKILL "$UNIT_NAME.scope"

    echo "[*] Antigravity closed. Cleaned up remaining processes."
}

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