From f7abd7262b2017dea8b4fb53eff38e9eab4c70c4 Mon Sep 17 00:00:00 2001 From: andwati Date: Wed, 12 Aug 2026 09:13:13 +0300 Subject: [PATCH] Default KGet's download folder to Downloads and add release workflow install.sh now sets KGet's remembered "New Download" folder (kgetrc Internal/LastDirectory) to the XDG downloads directory if it isn't already configured, since KGet's own out-of-the-box default was Documents. Falls back correctly even when xdg-user-dir has no user-dirs.dirs config to read (it silently returns bare $HOME otherwise). Also add a GitHub Actions workflow that packages extension/ into a zip and publishes a GitHub Release with generated notes whenever a v*.*.* tag is pushed. --- .github/workflows/release.yml | 27 ++++++++++++++++++++++++ README.md | 13 ++++++++++++ install.sh | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0d43eb5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,27 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Package extension + run: | + cd extension + zip -r "../kget-capture-${GITHUB_REF_NAME}.zip" . + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + files: kget-capture-${{ github.ref_name }}.zip + generate_release_notes: true diff --git a/README.md b/README.md index 9abbd0f..7e42a9f 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,19 @@ This removes the native messaging host registrations and the installed host script. You'll still need to remove the unpacked extension yourself via `chrome://extensions` — that step can't be scripted. +## Releases + +Pushing a tag matching `v*.*.*` (e.g. `v1.0.0`) triggers a GitHub Actions +workflow ([.github/workflows/release.yml](.github/workflows/release.yml)) +that zips `extension/` and publishes it as a GitHub Release with +auto-generated release notes. Bump `"version"` in `extension/manifest.json` +before tagging so the packaged extension's version matches. + +```bash +git tag v1.0.0 +git push origin v1.0.0 +``` + ## Known limitations - **`blob:`/`data:` URLs can't be captured.** There's no real network URL to diff --git a/install.sh b/install.sh index b4c08c5..48aeca3 100755 --- a/install.sh +++ b/install.sh @@ -51,6 +51,45 @@ if [ "$registered_any" = false ]; then done fi +echo "Checking KGet's default download folder..." +python3 - <<'PYEOF' +import configparser +import os +import subprocess + +kgetrc = os.path.expanduser("~/.config/kgetrc") +key = "LastDirectory[$e]" + +home = os.path.expanduser("~") +try: + result = subprocess.run(["xdg-user-dir", "DOWNLOAD"], capture_output=True, text=True, timeout=5) + downloads = result.stdout.strip() +except (FileNotFoundError, subprocess.TimeoutExpired): + downloads = "" +# xdg-user-dir falls back to bare $HOME (not $HOME/Downloads) when there's +# no ~/.config/user-dirs.dirs at all -- treat that the same as "not found". +if not downloads or downloads.rstrip("/") == home.rstrip("/"): + downloads = os.path.join(home, "Downloads") + +cp = configparser.ConfigParser(interpolation=None) +cp.optionxform = str +if os.path.exists(kgetrc): + cp.read(kgetrc) + +if not cp.has_section("Internal"): + cp.add_section("Internal") + +if key in cp["Internal"]: + print(f"KGet's default download folder is already set ({cp['Internal'][key]}), leaving it as-is") +else: + cp["Internal"][key] = downloads + "/" + os.makedirs(os.path.dirname(kgetrc), exist_ok=True) + with open(kgetrc, "w") as f: + cp.write(f) + print(f"Set KGet's default download folder to {downloads}") + print("(If KGet is currently running, restart it for this to take effect.)") +PYEOF + EXT_ID=$(cat "$SCRIPT_DIR/keys/extension-id.txt") cat <