Clean install.sh and improve p.sh
This commit is contained in:
86
install.sh
86
install.sh
@@ -1,43 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Parse flags
|
||||
help_message="Usage: $0 [--desktop|-d | --hyprland|-h | --terminal|-t]
|
||||
|
||||
Options:
|
||||
--desktop, -d Install desktop programs and configure GNOME (must already be installed).
|
||||
--hyprland, -h Install desktop programs and Hyprland.
|
||||
--terminal, -t Only install the basic dependencies for CLI use."
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "$help_message"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--desktop | -d)
|
||||
desktop=true
|
||||
hyprland=false
|
||||
shift
|
||||
;;
|
||||
--hyprland | -h)
|
||||
desktop=true
|
||||
hyprland=true
|
||||
shift
|
||||
;;
|
||||
--terminal | -t)
|
||||
desktop=false
|
||||
hyprland=false
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "$help_message"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
@@ -75,49 +37,7 @@ echo -e "${CYAN}Package managers: ${PURPLE}${packageManagers[@]}${NC}"
|
||||
echo
|
||||
|
||||
# Install Programs
|
||||
programs=(neovim curl git tmux htop fzf gcc make)
|
||||
|
||||
if $desktop; then
|
||||
programs+=(
|
||||
tldr # Simplified man pages
|
||||
fastfetch # System information
|
||||
timeshift # System restore
|
||||
s-tui # CPU monitoring / Detect overheating
|
||||
#weechat # IRC client
|
||||
#w3m # Text-based web browser
|
||||
#nnn # File manager
|
||||
#taskwarrior # Task manager
|
||||
#mutt # Email client
|
||||
#pass-otp # Password manager
|
||||
#zbar-tools # QR code reader
|
||||
)
|
||||
fi
|
||||
|
||||
if $hyprland; then
|
||||
if [[ " ${packageManagers[@]} " =~ "pacman" ]]; then
|
||||
programs+=(
|
||||
dunst # Notifications
|
||||
foot # Terminal
|
||||
hyprland # Window manager
|
||||
hyprlock # Screen locker
|
||||
hyprpaper # Wallpaper manager
|
||||
hyprpicker # Color picker
|
||||
hyprpolkitagent # Auth pop-up for sudo access
|
||||
nautilus # File manager
|
||||
network-manager # Network manager
|
||||
pipewire # Audio server
|
||||
udiskie # Automount USB drives
|
||||
waybar # Status bar
|
||||
wireplumber # PipeWire session manager
|
||||
wofi # Launcher
|
||||
xdg-desktop-portal-hyprland # D-Bus support for Hyprland programs
|
||||
)
|
||||
else
|
||||
echo -e "${RED}[E] Hyprland not available in your distro's repositories.${NC}"
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
|
||||
programs=(neovim curl git tmux htop fzf gcc make tldr s-tui)
|
||||
p i ${programs[@]}
|
||||
|
||||
# Copy files
|
||||
@@ -160,8 +80,7 @@ else
|
||||
fi
|
||||
|
||||
# Load Dconf (GNOME settings)
|
||||
if $desktop; then
|
||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
echo -e "${YELLOW}[+] Loading Dconf settings...${NC}"
|
||||
dconf load / <$HOME/dotfiles/dconf-settings.ini
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -169,5 +88,4 @@ if $desktop; then
|
||||
else
|
||||
echo -e "${GREEN}[I] Dconf settings loaded successfully.${NC}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#! /bin/bash
|
||||
|
||||
/opt/multimc/run.sh
|
||||
|
||||
65
scripts/p.sh
65
scripts/p.sh
@@ -100,34 +100,13 @@ p() (
|
||||
echo -e "${GREEN}${BOLD}Flatpak:${ENDCOLOR}${GREEN} $(echo $flatpak_apps | tr ' ' '\n' | grep -i $app_name)${ENDCOLOR}"
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "nix" ]]; then
|
||||
nix_apps=$(nix-env -q)
|
||||
echo $nix_apps | grep -iq $app_name
|
||||
nix_success=$?
|
||||
if [[ $nix_success == 0 ]]; then
|
||||
echo -e "${GREEN}${BOLD}Nix:${ENDCOLOR}${GREEN} $(echo $nix_apps | tr ' ' '\n' | grep -i $app_name)${ENDCOLOR}"
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "brew" ]]; then
|
||||
brew_apps=$(brew list)
|
||||
echo $brew_apps | grep -iq $app_name
|
||||
brew_success=$?
|
||||
if [[ $brew_success == 0 ]]; then
|
||||
echo -e "${GREEN}${BOLD}Brew:${ENDCOLOR}${GREEN} $(echo $brew_apps | tr ' ' '\n' | grep -i $app_name)${ENDCOLOR}"
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "apt" ]]; then
|
||||
distro_apps=$(dpkg-query -l | grep '^ii' | awk '{print $2}')
|
||||
elif [[ ${packageManagers[@]} =~ "pacman" ]]; then
|
||||
distro_apps=$(pacman -Q)
|
||||
elif [[ ${packageManagers[@]} =~ "dnf" ]]; then
|
||||
distro_apps=$(dnf list)
|
||||
fi
|
||||
|
||||
echo $distro_apps | grep -Eiq "(^|\s)$app_name($|\s)"
|
||||
# Some package names are different from the command name
|
||||
declare -A altNames=(["neovim"]="nvim" ["python"]="python3" ["nodejs"]="node" ["docker-compose"]="docker compose" ["pip"]="pip3")
|
||||
commandName="${altNames[$app_name]:-$app_name}"
|
||||
which "$commandName" &>/dev/null
|
||||
distro_success=$?
|
||||
if [[ $distro_success == 0 ]]; then
|
||||
echo -e "${GREEN}${BOLD}Distro:${ENDCOLOR}${GREEN} $(echo $distro_apps | tr ' ' '\n' | grep -Ei "(^|\s)$app_name($|\s)")${ENDCOLOR}"
|
||||
echo -e "${GREEN}${BOLD}Distro:${ENDCOLOR}${GREEN} $app_name is installed.${ENDCOLOR}"
|
||||
fi
|
||||
|
||||
if [[ $flatpak_success != 0 && $nix_success != 0 && $brew_success != 0 && $distro_success != 0 ]]; then
|
||||
@@ -139,103 +118,103 @@ p() (
|
||||
installP() {
|
||||
checkP $1
|
||||
if [[ $? != 1 ]]; then
|
||||
echo "$1 is already installed."
|
||||
echo -e "${GREEN}$1 is already installed.${ENDCOLOR}"
|
||||
return 0
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "nix" ]]; then
|
||||
echo "Attempting nix install..."
|
||||
echo -e "${YELLOW}Attempting nix install...${ENDCOLOR}"
|
||||
nix-env -iA nixpkgs.$1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "brew" ]]; then
|
||||
echo "Attempting brew install..."
|
||||
echo -e "${YELLOW}Attempting brew install...${ENDCOLOR}"
|
||||
brew install $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "apt" ]]; then
|
||||
echo "Attempting apt install..."
|
||||
echo -e "${YELLOW}Attempting apt install...${ENDCOLOR}"
|
||||
sudo apt install $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
elif [[ ${packageManagers[@]} =~ "paru" ]]; then
|
||||
echo "Attempting paru install..."
|
||||
echo -e "${YELLOW}Attempting paru install...${ENDCOLOR}"
|
||||
paru -Sy $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
elif [[ ${packageManagers[@]} =~ "pacman" ]]; then
|
||||
echo "Attempting pacman install..."
|
||||
echo -e "${YELLOW}Attempting pacman install...${ENDCOLOR}"
|
||||
sudo pacman -Sy $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
elif [[ ${packageManagers[@]} =~ "dnf" ]]; then
|
||||
echo "Attempting dnf install..."
|
||||
echo -e "${YELLOW}Attempting dnf install...${ENDCOLOR}"
|
||||
sudo dnf install $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "flatpak" ]]; then
|
||||
echo "Attempting flatpak install..."
|
||||
echo -e "${YELLOW}Attempting flatpak install...${ENDCOLOR}"
|
||||
flatpak install $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
echo "ERROR - $1 not found."
|
||||
echo -e "${RED}ERROR - $1 not found.${ENDCOLOR}"
|
||||
return 1
|
||||
}
|
||||
|
||||
removeP() {
|
||||
checkP $1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo "$1 is not installed."
|
||||
echo -e "${YELLOW}$1 is not installed.${ENDCOLOR}"
|
||||
return 0
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "flatpak" ]]; then
|
||||
echo "Attempting flatpak uninstall..."
|
||||
echo -e "${YELLOW}Attempting flatpak uninstall...${ENDCOLOR}"
|
||||
flatpak uninstall $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "nix" ]]; then
|
||||
echo "Attempting nix uninstall..."
|
||||
echo -e "${YELLOW}Attempting nix uninstall...${ENDCOLOR}"
|
||||
nix-env --uninstall $1
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "brew" ]]; then
|
||||
echo "Attempting brew uninstall..."
|
||||
echo -e "${YELLOW}Attempting brew uninstall...${ENDCOLOR}"
|
||||
brew uninstall $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "apt" ]]; then
|
||||
echo "Attempting apt uninstall..."
|
||||
echo -e "${YELLOW}Attempting apt uninstall...${ENDCOLOR}"
|
||||
sudo apt remove $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
elif [[ ${packageManagers[@]} =~ "pacman" ]]; then
|
||||
echo "Attempting pacman uninstall..."
|
||||
echo -e "${YELLOW}Attempting pacman uninstall...${ENDCOLOR}"
|
||||
sudo pacman -Rs $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
elif [[ ${packageManagers[@]} =~ "dnf" ]]; then
|
||||
echo "Attempting dnf uninstall..."
|
||||
echo -e "${YELLOW}Attempting dnf uninstall...${ENDCOLOR}"
|
||||
sudo dnf remove $1
|
||||
if [[ $? == 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
echo "ERROR - Failed to uninstall $1."
|
||||
echo -e "${RED}ERROR - Failed to uninstall $1.${ENDCOLOR}"
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to symlink all files in one directory, to another.
|
||||
# Example use-case: Symlink all files in .dotfiles to the $HOME directory.
|
||||
# Usage example: symlink_files $source $destination
|
||||
|
||||
symlink_files() {
|
||||
# Check if source and destination directories exist
|
||||
if [ ! -d "$1" ] || [ ! -d "$2" ]; then
|
||||
echo "Error: Source or destination directory does not exist!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Loop through each file in the source directory (including hidden)
|
||||
for file in $(find "$1" -type f -print); do
|
||||
filePath=$(realpath $file)
|
||||
ln -s "$filePath" "$2/$(basename "$file")"
|
||||
echo "Linked: $file to $2/$(basename "$file")"
|
||||
done
|
||||
}
|
||||
Reference in New Issue
Block a user