35 lines
1.1 KiB
Bash
Executable File
35 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# ALPM package URL handler
|
|
# x-alpm-package://packagename
|
|
# install: xdg-mime default pamac-url-handler.desktop x-scheme-handler/x-alpm-package
|
|
|
|
if [ $# != 1 ] || [[ "$1" != 'x-alpm-package://'* ]]; then
|
|
echo "Usage: $0 [URL]"
|
|
exit 1
|
|
fi
|
|
|
|
content="${1#x-alpm-package://}"
|
|
|
|
# AUR install
|
|
if [[ "$content" == 'aur//'* ]]; then
|
|
packagename="${content#aur//}"
|
|
pamac-installer --build "$packagename"
|
|
|
|
# Flatpak install
|
|
elif [[ "$content" == 'flatpak//'* ]]; then
|
|
appID="${content#flatpak//}"
|
|
info=$(flatpak remote-info flathub "$appID") || {
|
|
yad --image 'dialog-error' --title 'Alert' --buttons-layout=center --text-align=center --button=yad-close --borders=10 --text "Flatpak ID not found:\n$appID"
|
|
exit 1
|
|
}
|
|
yad --image 'dialog-question' --title 'Flatpak install' --button=Cancel:1 --button=Install:0 --text "$info" &&
|
|
exo-open --launch TerminalEmulator \
|
|
bash -c "flatpak install --assumeyes flathub $appID ; printf '\n'; read -n1 -rsp 'press any key to close window...'"
|
|
|
|
# Repo install
|
|
else
|
|
packagename=$content
|
|
pamac-installer "$packagename"
|
|
fi
|