160 lines
6 KiB
Shell
160 lines
6 KiB
Shell
#!/usr/bin/env bash
|
|
# The apps the installer offers, a page each. Every page can take any number of them, or None.
|
|
# A line is: package|name|the commands that mean it is here|its desktop id, for the dock.
|
|
# `*` before a package marks the recommended one, ticked when that kind has nothing here yet.
|
|
# `@` means it is not a package: it is one of our own apps, from its latest release on Astar Hub.
|
|
# Own apps come first on their page, are marked recommended and are ticked while not installed.
|
|
|
|
APP_PAGES=(terminal files editor browser discord music extras)
|
|
declare -A APP_TITLE=(
|
|
[terminal]="Terminal" [files]="File manager" [editor]="Text editor" [browser]="Browser"
|
|
[discord]="Discord" [music]="Music" [extras]="Extras"
|
|
)
|
|
|
|
app_list() {
|
|
case "$1" in
|
|
terminal) cat <<'L'
|
|
*kitty|kitty|kitty|kitty
|
|
foot|foot|foot|foot
|
|
alacritty|Alacritty|alacritty|Alacritty
|
|
ghostty|Ghostty|ghostty|com.mitchellh.ghostty
|
|
wezterm|WezTerm|wezterm|org.wezfurlong.wezterm
|
|
konsole|Konsole|konsole|org.kde.konsole
|
|
gnome-terminal|GNOME Terminal|gnome-terminal|org.gnome.Terminal
|
|
L
|
|
;;
|
|
files) cat <<'L'
|
|
*thunar|Thunar|thunar|thunar
|
|
dolphin|Dolphin|dolphin|org.kde.dolphin
|
|
nautilus|Nautilus|nautilus|org.gnome.Nautilus
|
|
nemo|Nemo|nemo|nemo
|
|
pcmanfm-gtk3|PCManFM|pcmanfm|pcmanfm
|
|
yazi|yazi|yazi|yazi
|
|
L
|
|
;;
|
|
editor) cat <<'L'
|
|
@damson|Damson|damson|damson
|
|
*gnome-text-editor|GNOME Text Editor|gnome-text-editor|org.gnome.TextEditor
|
|
kate|Kate|kate|org.kde.kate
|
|
mousepad|Mousepad|mousepad|org.xfce.mousepad
|
|
neovim|Neovim|nvim|nvim
|
|
micro|micro|micro|micro
|
|
helix|Helix|helix hx|Helix
|
|
zed|Zed|zed zeditor|dev.zed.Zed
|
|
code|Code - OSS|code|code-oss
|
|
visual-studio-code-bin|Visual Studio Code|code|code
|
|
sublime-text-4|Sublime Text|subl|sublime_text
|
|
L
|
|
;;
|
|
browser) cat <<'L'
|
|
@nacre|Nacre|nacre|dev.nacre.Nacre
|
|
*ungoogled-chromium-bin|Ungoogled Chromium|ungoogled-chromium chromium|ungoogled-chromium
|
|
brave-bin|Brave|brave|brave-browser
|
|
firefox|Firefox|firefox|firefox
|
|
opera|Opera|opera|opera
|
|
zen-browser-bin|Zen Browser|zen-browser|zen
|
|
vivaldi|Vivaldi|vivaldi vivaldi-stable|vivaldi-stable
|
|
chromium|Chromium|chromium|chromium
|
|
google-chrome|Google Chrome|google-chrome-stable|google-chrome
|
|
L
|
|
;;
|
|
discord) cat <<'L'
|
|
equibop-bin|Equibop|equibop|equibop
|
|
vesktop-bin|Vesktop|vesktop|vesktop
|
|
discord|Discord|discord|discord
|
|
legcord-bin|Legcord|legcord|legcord
|
|
webcord|WebCord|webcord|webcord
|
|
L
|
|
;;
|
|
music) cat <<'L'
|
|
@mulberry|Mulberry|mulberry|mulberry
|
|
@audiphi|Audiphi|audiphi|audiphi
|
|
spotify|Spotify|spotify|spotify
|
|
strawberry|Strawberry|strawberry|org.strawberrymusicplayer.strawberry
|
|
tauon-music-box|Tauon|tauon|tauonmb
|
|
rhythmbox|Rhythmbox|rhythmbox|org.gnome.Rhythmbox3
|
|
vlc|VLC|vlc|vlc
|
|
mpv|mpv|mpv|mpv
|
|
L
|
|
;;
|
|
extras) cat <<'L'
|
|
steam|Steam|steam|steam
|
|
heroic-games-launcher-bin|Heroic Games Launcher|heroic|heroic
|
|
lutris|Lutris|lutris|net.lutris.Lutris
|
|
prismlauncher|Prism Launcher|prismlauncher|org.prismlauncher.PrismLauncher
|
|
obs-studio|OBS Studio|obs|com.obsproject.Studio
|
|
gimp|GIMP|gimp|gimp
|
|
krita|Krita|krita|org.kde.krita
|
|
libreoffice-fresh|LibreOffice|libreoffice soffice|libreoffice-startcenter
|
|
onlyoffice-bin|ONLYOFFICE|onlyoffice-desktopeditors|onlyoffice-desktopeditors
|
|
qbittorrent|qBittorrent|qbittorrent|org.qbittorrent.qBittorrent
|
|
telegram-desktop|Telegram|telegram-desktop Telegram|org.telegram.desktop
|
|
signal-desktop|Signal|signal-desktop|signal-desktop
|
|
thunderbird|Thunderbird|thunderbird|thunderbird
|
|
obsidian|Obsidian|obsidian|obsidian
|
|
bitwarden|Bitwarden|bitwarden|bitwarden
|
|
keepassxc|KeePassXC|keepassxc|org.keepassxc.KeePassXC
|
|
btop|btop|btop|btop
|
|
L
|
|
;;
|
|
esac
|
|
}
|
|
|
|
HUB_URL="${HUB_URL:-https://archlinux.tail7c4f5e.ts.net/git/astar76}"
|
|
# Each own app's repo, and the release used when the hub's API does not answer.
|
|
own_repo() {
|
|
case "$1" in
|
|
@mulberry) echo "Mulberry v2.0.4 Mulberry-2.0.4" ;;
|
|
@audiphi) echo "Audiphi v0.2.1 Audiphi-0.2.1" ;;
|
|
@damson) echo "Damson v0.1.1 Damson-0.1.1" ;;
|
|
@nacre) echo "Nacre v0.4.1 Nacre-0.4.1" ;;
|
|
esac
|
|
}
|
|
|
|
# The Linux x86_64 tar.gz of the app's latest release, from the Forgejo API, else the known one.
|
|
own_url() {
|
|
local repo tag stem url
|
|
read -r repo tag stem <<<"$(own_repo "$1")"
|
|
url="$(curl -fsS --max-time 5 "${HUB_URL%/*}/api/v1/repos/${HUB_URL##*/}/$repo/releases/latest" 2>/dev/null \
|
|
| grep -oiE '"browser_download_url":"[^"]*-linux-x86_64\.tar\.gz"' | head -1 | cut -d'"' -f4 || true)"
|
|
echo "${url:-$HUB_URL/$repo/releases/download/$tag/$stem-Linux-x86_64.tar.gz}"
|
|
}
|
|
|
|
# Downloads the release and installs it into ~/.local with the installer it ships (binary in
|
|
# ~/.local/bin, desktop file and icons under ~/.local/share). Older archives without one are
|
|
# unpacked into ~/.local/lib by hand.
|
|
install_own() {
|
|
local name="${1#@}" url dir top
|
|
url="$(own_url "$1")"
|
|
dir="$(mktemp -d)"
|
|
curl -fsSL --max-time 300 "$url" | tar -xz -C "$dir" || { rm -rf "$dir"; return 1; }
|
|
top="$(find "$dir" -mindepth 1 -maxdepth 1 -type d | head -1)"
|
|
if [[ -f "$top/install.sh" ]]; then
|
|
sh "$top/install.sh" --user || { rm -rf "$dir"; return 1; }
|
|
rm -rf "$dir"
|
|
return 0
|
|
fi
|
|
local lib="$HOME/.local/lib/$name" data="${XDG_DATA_HOME:-$HOME/.local/share}"
|
|
mkdir -p "$HOME/.local/lib" "$HOME/.local/bin" "$data/applications" "$data/icons/hicolor/scalable/apps" "$data/icons/hicolor/256x256/apps"
|
|
rm -rf "$lib"
|
|
mv "$top" "$lib"
|
|
rm -rf "$dir"
|
|
local exe="$lib/$name"
|
|
[[ -x "$exe" ]] || exe="$lib/$name-rust"
|
|
ln -sf "$exe" "$HOME/.local/bin/$name"
|
|
if [[ -f "$lib/$name.desktop" ]]; then
|
|
sed "s|^Exec=[^ ]*|Exec=$HOME/.local/bin/$name|" "$lib/$name.desktop" >"$data/applications/$name.desktop"
|
|
fi
|
|
[[ -f "$lib/$name.svg" ]] && cp "$lib/$name.svg" "$data/icons/hicolor/scalable/apps/"
|
|
[[ -f "$lib/$name.png" ]] && cp "$lib/$name.png" "$data/icons/hicolor/256x256/apps/"
|
|
return 0
|
|
}
|
|
|
|
# Whether one of these commands is here.
|
|
app_present() {
|
|
local c
|
|
for c in $1; do
|
|
command -v "$c" >/dev/null 2>&1 && return 0
|
|
done
|
|
return 1
|
|
}
|