illuscape/scripts/detect_platform.sh
pyr0ball 8e245dfe61 feat: cross-platform installer (Windows port)
- install.py / uninstall.py: full Python installer for Linux, macOS, Windows
  - detect_platform.py: shared Inkscape config path detection
  - Windows config path: %APPDATA%\inkscape (native/winget/scoop) or
    %LOCALAPPDATA%\Packages\org.inkscape.Inkscape* (MS Store)
  - Windows desktop: Start Menu .lnk via PowerShell WScript.Shell COM object
  - macOS: XDG / ~/Library/Application Support detection, no desktop step
- install.sh / uninstall.sh: reduced to one-line exec python3 wrappers
  - eliminates SC1091 (source not followed) and SC2155 (declare+assign)
- scripts/detect_platform.sh: export INKSCAPE_CONFIG / INKSCAPE_INSTALL_METHOD
  - fixes SC2034 (variables appear unused to shellcheck)
- assets/illuscape.ico: pre-rendered 16/32/48/64/128/256px ICO (ImageMagick)
- tests/test_install.py: pytest integration tests replacing test_install.bats
  - cross-platform fake inkscape injected via PATH
  - 12 tests covering backup, palettes, templates, prefs, uninstall restore
- ci.yml: add windows-latest matrix leg; shellcheck/inkscape Linux-only;
  bats removed in favour of pytest integration tests; 27 tests total
2026-05-27 11:26:16 -07:00

32 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# detect_platform.sh — Print the Inkscape config root for this system.
# Usage: source scripts/detect_platform.sh && echo "$INKSCAPE_CONFIG"
# Sets: INKSCAPE_CONFIG (path), INKSCAPE_INSTALL_METHOD (flatpak|snap|native)
set -euo pipefail
_detect_inkscape_config() {
# Flatpak takes priority — most common modern Linux install
local flatpak_config="$HOME/.var/app/org.inkscape.Inkscape/config/inkscape"
if [[ -d "$flatpak_config" ]] || flatpak list 2>/dev/null | grep -q "org.inkscape.Inkscape"; then
export INKSCAPE_CONFIG="$flatpak_config"
export INKSCAPE_INSTALL_METHOD="flatpak"
return 0
fi
# Snap
local snap_config="$HOME/snap/inkscape/current/.config/inkscape"
if [[ -d "$snap_config" ]] || snap list 2>/dev/null | grep -q "^inkscape "; then
export INKSCAPE_CONFIG="$snap_config"
export INKSCAPE_INSTALL_METHOD="snap"
return 0
fi
# Native / XDG
local xdg_config="${XDG_CONFIG_HOME:-$HOME/.config}/inkscape"
export INKSCAPE_CONFIG="$xdg_config"
export INKSCAPE_INSTALL_METHOD="native"
return 0
}
_detect_inkscape_config