From 926eb2daad12f52168d45a312241ffdaab30bc8f Mon Sep 17 00:00:00 2001 From: TrudeEH Date: Sun, 7 Jan 2024 21:15:54 +0000 Subject: [PATCH] New icons, and major improvements to p --- install.sh | 12 ++-- scripts/codeAI-ollama.sh | 2 +- scripts/debian-maintenance.sh | 0 scripts/generalAI-jan.sh | 2 +- scripts/p.sh | 115 +++++++++++++++++++++++++--------- 5 files changed, 92 insertions(+), 39 deletions(-) mode change 100644 => 100755 scripts/debian-maintenance.sh mode change 100644 => 100755 scripts/generalAI-jan.sh diff --git a/install.sh b/install.sh index 8250a96d..2fd93484 100755 --- a/install.sh +++ b/install.sh @@ -70,14 +70,10 @@ if [ $dist == 2 ]; then fi fi -# Install Tela Icons -echo "Installing Tela Icon Theme..." -git clone https://github.com/vinceliuice/Tela-circle-icon-theme.git -cd Tela-circle-icon-theme -./install.sh -cd .. -rm -rf Tela-circle-icon-theme -gsettings set org.gnome.desktop.interface icon-theme 'Tela-circle' +# Install Icon theme +echo "Installing Papirus Icon Theme..." +wget -qO- https://git.io/papirus-icon-theme-install | sh +gsettings set org.gnome.desktop.interface icon-theme 'Papirus Dark' # Install Cursor theme echo "Installing Cursor Theme..." diff --git a/scripts/codeAI-ollama.sh b/scripts/codeAI-ollama.sh index 1ff22e71..9cf057d4 100755 --- a/scripts/codeAI-ollama.sh +++ b/scripts/codeAI-ollama.sh @@ -1,7 +1,7 @@ #! /bin/bash source ./p.sh -if [[ $(p c ollama) == 0 ]]; then +if p c ollama &>/dev/null; then kgx -e "ollama serve" sleep 1 kgx -e "ollama run codellama" diff --git a/scripts/debian-maintenance.sh b/scripts/debian-maintenance.sh old mode 100644 new mode 100755 diff --git a/scripts/generalAI-jan.sh b/scripts/generalAI-jan.sh old mode 100644 new mode 100755 index e673d944..c74dd00a --- a/scripts/generalAI-jan.sh +++ b/scripts/generalAI-jan.sh @@ -1,5 +1,5 @@ source ./p.sh -if [[ $(p c jan) == 0 ]]; then +if p c jan &>/dev/null; then echo "Jan is installed. Launch it from the app menu." else p i jan diff --git a/scripts/p.sh b/scripts/p.sh index bd5a5d12..db3b5586 100755 --- a/scripts/p.sh +++ b/scripts/p.sh @@ -1,12 +1,5 @@ #! /bin/bash -# Cross-distro package manager - -# p -> update os -# p i package -> install package -# p r package -> remove package -# p c package -> check if package is installed (0 -> installed; 1 -> not installed; 2 -> ERROR) -# d -> returns 1 -> Debian; 2 -> Arch; 0 -> Error -# m -> maintenance script +# Cross-distro package manager wrapper d() { if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then @@ -39,62 +32,126 @@ p() { remove="sudo apt remove" elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then if pacman -Qs paru >/dev/null; then - distro="ARCH" update="paru -Syu" install="paru -S" remove="paru -R" else - distro="ARCH" update="sudo pacman -Syu" install="sudo pacman -S" remove="sudo pacman -R" fi + distro="ARCH" else - echo "DISTRO NOT SUPPORTED" + echo "[E] Distro not supported." return 1 fi + # Detect if flatpak is installed. + if flatpak --version &>/dev/null; then + flatpak=true + else + flatpak=false + fi + # If no parameter - if [ -z $1 ]; then + if [ -z $1 ] || [ $1 == "u" ]; then + echo "[+] Updating distro packages..." $update + if $flatpak; then + echo + echo "[+] Updating flatpaks..." + flatpak upgrade + fi + echo "[I] done." return 0 - fi - - # If first parameter is i (install) - if [ $1 == "i" ]; then - $install $2 + elif [ $1 == "i" ]; then # If first parameter is i (install) + echo "[+] Searching for $2 on the distro repos..." + $install $2 2>/dev/null if [ $? == 0 ]; then + echo "[I] $2 was installed." return 0 else + if $flatpak; then + echo + echo "[E] $2 not found." + echo "[+] Searching for $2 as a flatpak..." + echo + flatpak install $2 2>/dev/null + if [ $? == 0 ]; then + echo "[I] $2 was installed." + return 0 + fi + fi + echo "[E] $2 not found or already installed." return 2 fi - fi - - # If first parameter is r (remove) - if [ $1 == "r" ]; then - $remove $2 + elif [ $1 == "r" ]; then # If first parameter is r (remove) + echo "[+] Removing $2..." + $remove $2 2>/dev/null if [ $? == 0 ]; then + echo "[I] $2 was removed." return 0 else + if $flatpak; then + echo + echo "[E] $2 not found." + echo "[+] Searching for $2 as a flatpak..." + echo + flatpak remove $2 2>/dev/null + if [ $? == 0 ]; then + echo "[I] $2 was removed." + return 0 + fi + fi + echo "[E] $2 not found." return 2 fi - fi - - if [ $1 == "c" ]; then + elif [ $1 == "c" ]; then # If first parameter is c (check) if [ "$distro" == "DEB" ]; then if dpkg-query -W -f='${Status}' $2 2>/dev/null | grep -q "install ok installed"; then - echo 0 + echo true + return 0 else - echo 1 + if $flatpak; then + flatpak list | grep $2 &>/dev/null + if [ $? == 0 ]; then + echo true + return 0 + fi + fi + echo false + return 1 fi elif [ "$distro" == "ARCH" ]; then if pacman -Qs $2 >/dev/null; then - echo 0 + echo true + return 0 else - echo 1 + if $flatpak; then + flatpak list | grep -i $2 &>/dev/null + if [ $? == 0 ]; then + echo true + return 0 + fi + fi + echo false + return 1 fi else echo 2 fi + else + echo "[I] Usage:" + echo "p (u) -> update os" + echo "p i package -> install package" + echo "p r package -> remove package" + echo "p c package -> check if package is installed (true/false; 2 -> ERROR)" + echo "d -> returns 1 -> Debian; 2 -> Arch; 0 -> Error" + echo "m -> maintenance script" + echo + echo "[I] Order of operations:" + echo "1 - Check distro repos" + echo "2 - Check AUR if on Arch" + echo "3 - Check flatpaks (only if flatpak support is enabled)" fi }