32 lines
1.1 KiB
Bash
Executable file
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
|
|
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
|