feat: add platform detection script
This commit is contained in:
parent
2677ccc42b
commit
f577da35aa
1 changed files with 32 additions and 0 deletions
32
scripts/detect_platform.sh
Executable file
32
scripts/detect_platform.sh
Executable file
|
|
@ -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
|
||||
Loading…
Reference in a new issue