From f577da35aabc669797c63fd719f07a1c366c6a22 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 25 May 2026 19:43:45 -0700 Subject: [PATCH] feat: add platform detection script --- scripts/detect_platform.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 scripts/detect_platform.sh diff --git a/scripts/detect_platform.sh b/scripts/detect_platform.sh new file mode 100755 index 0000000..fc26622 --- /dev/null +++ b/scripts/detect_platform.sh @@ -0,0 +1,32 @@ +#!/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 + INKSCAPE_CONFIG="$flatpak_config" + 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 + INKSCAPE_CONFIG="$snap_config" + INKSCAPE_INSTALL_METHOD="snap" + return 0 + fi + + # Native / XDG + local xdg_config="${XDG_CONFIG_HOME:-$HOME/.config}/inkscape" + INKSCAPE_CONFIG="$xdg_config" + INKSCAPE_INSTALL_METHOD="native" + return 0 +} + +_detect_inkscape_config