Add MacOS support

This commit is contained in:
2024-01-17 16:34:09 +00:00
parent fad72a6c5d
commit a8847b6421
5 changed files with 122 additions and 74 deletions

View File

@@ -100,25 +100,29 @@ if [ $dist == 2 ]; then
fi fi
# Install Icon theme # Install Icon theme
if ls /usr/share/icons/ | grep -i Papirus &>/dev/null; then if [ $dist != 3 ]; then
echo -e "${GREEN}[i] Icon theme is installed.${ENDCOLOR}" if ls /usr/share/icons/ | grep -i Papirus &>/dev/null; then
else echo -e "${GREEN}[i] Icon theme is installed.${ENDCOLOR}"
echo -e "${GREEN}[+] Downloading Papirus icon theme...${ENDCOLOR}" else
wget -qO- https://git.io/papirus-icon-theme-install | sh echo -e "${GREEN}[+] Downloading Papirus icon theme...${ENDCOLOR}"
wget -qO- https://git.io/papirus-folders-install | sh wget -qO- https://git.io/papirus-icon-theme-install | sh
papirus-folders -C adwaita wget -qO- https://git.io/papirus-folders-install | sh
gsettings set org.gnome.desktop.interface icon-theme 'Papirus-Dark' papirus-folders -C adwaita
echo -e "${GREEN}[i] Theme is set.${ENDCOLOR}" gsettings set org.gnome.desktop.interface icon-theme 'Papirus-Dark'
echo -e "${GREEN}[i] Theme is set.${ENDCOLOR}"
fi
fi fi
# Install Cursor theme # Install Cursor theme
if ls /usr/share/icons/ | grep -i bibata &>/dev/null; then if [ $dist != 3 ]; then
echo -e "${GREEN}[i] Cursor theme is installed.${ENDCOLOR}" if ls /usr/share/icons/ | grep -i bibata &>/dev/null; then
else echo -e "${GREEN}[i] Cursor theme is installed.${ENDCOLOR}"
echo -e "${GREEN}[+] Downloading Bibata cursor theme...${ENDCOLOR}" else
p i bibata-cursor-theme echo -e "${GREEN}[+] Downloading Bibata cursor theme...${ENDCOLOR}"
gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Classic' p i bibata-cursor-theme
echo -e "${GREEN}[i] Cursor theme set.${ENDCOLOR}" gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Classic'
echo -e "${GREEN}[i] Cursor theme set.${ENDCOLOR}"
fi
fi fi
# Install Nerd Font # Install Nerd Font
@@ -141,37 +145,43 @@ else
fi fi
# Enable minimize button # Enable minimize button
echo -e "${GREEN}[+] Adding the minimize button...${ENDCOLOR}" if [ $dist != 3 ]; then
gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,close" echo -e "${GREEN}[+] Adding the minimize button...${ENDCOLOR}"
gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,close"
fi
# Enable flatpak support # Enable flatpak support
if p c flatpak &>/dev/null; then if [ $dist != 3 ]; then
echo -e "${GREEN}[i] Flatpaks are supported.${ENDCOLOR}" if p c flatpak &>/dev/null; then
else echo -e "${GREEN}[i] Flatpaks are supported.${ENDCOLOR}"
if ask "Enable flatpak?"; then
echo -e "${GREEN}[+] Adding flatpak support...${ENDCOLOR}"
p i flatpak
flatpak install flatseal
sudo flatpak override --filesystem=$HOME/.themes
sudo flatpak override --filesystem=$HOME/.icons
echo -e "${GREEN}[+] Flatpak support added.${ENDCOLOR}"
else else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}" if ask "Enable flatpak?"; then
echo -e "${GREEN}[+] Adding flatpak support...${ENDCOLOR}"
p i flatpak
flatpak install flatseal
sudo flatpak override --filesystem=$HOME/.themes
sudo flatpak override --filesystem=$HOME/.icons
echo -e "${GREEN}[+] Flatpak support added.${ENDCOLOR}"
else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}"
fi
fi fi
fi fi
# Install Timeshift # Install Timeshift
if p c flatpak &>/dev/null; then if [ $dist != 3 ]; then
echo -e "${GREEN}[i] Timeshift is installed.${ENDCOLOR}" if p c timeshift &>/dev/null; then
else echo -e "${GREEN}[i] Timeshift is installed.${ENDCOLOR}"
if ask "Install Timeshift?"; then
echo -e "${GREEN}[+] Installing Timeshift...${ENDCOLOR}"
p i timeshift
sudo systemctl enable cronie
sudo systemctl start cronie
echo -e "${GREEN}[i] Timeshift installed.${ENDCOLOR}"
else else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}" if ask "Install Timeshift?"; then
echo -e "${GREEN}[+] Installing Timeshift...${ENDCOLOR}"
p i timeshift
sudo systemctl enable cronie
sudo systemctl start cronie
echo -e "${GREEN}[i] Timeshift installed.${ENDCOLOR}"
else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}"
fi
fi fi
fi fi

12
macos.sh Normal file
View File

@@ -0,0 +1,12 @@
#! /bin/bash
# Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add brew to path
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') > /Users/trude/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
echo 'PATH="/usr/local/bin:$PATH"' > ~/.bash_profile
# Install VScode
brew install visual-studio-code

0
scripts/color.sh Normal file → Executable file
View File

6
scripts/macos-maintenance.sh Executable file
View File

@@ -0,0 +1,6 @@
#! /bin/bash
brew doctor
brew update
brew upgrade
brew list

View File

@@ -9,16 +9,22 @@ d() {
elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then
echo 2 echo 2
else else
echo 0 if [ "$(uname -s)" = "Darwin" ]; then
echo 3
else
echo 0
fi
fi fi
} }
m() { m() {
d=$(d) d=$(d)
if [ $d == 2 ]; then if [ $d -eq 2 ]; then
~/dotfiles/scripts/arch-maintenance.sh ~/dotfiles/scripts/arch-maintenance.sh
elif [ $d == 1 ]; then elif [ $d -eq 1 ]; then
~/dotfiles/scripts/debian-maintenance.sh ~/dotfiles/scripts/debian-maintenance.sh
elif [ $d -eq 3 ]; then
~/dotfiles/scripts/macos-maintenance.sh
else else
echo -e "${RED}[E] Distro not supported.${ENDCOLOR}" echo -e "${RED}[E] Distro not supported.${ENDCOLOR}"
return 1 return 1
@@ -27,12 +33,13 @@ m() {
p() { p() {
# Detect distro type # Detect distro type
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then d=$(d)
if [ $d -eq 1 ]; then
distro="DEB" distro="DEB"
update="sudo apt update; sudo apt upgrade; sudo apt autoremove" update="sudo apt update; sudo apt upgrade; sudo apt autoremove"
install="sudo apt install" install="sudo apt install"
remove="sudo apt remove" remove="sudo apt remove"
elif [ "$(grep -Ei 'arch|manjaro|artix' /etc/*release)" ]; then elif [ $d -eq 2 ]; then
if pacman -Qs paru >/dev/null; then if pacman -Qs paru >/dev/null; then
update="paru -Syu" update="paru -Syu"
install="paru -S" install="paru -S"
@@ -43,6 +50,11 @@ p() {
remove="sudo pacman -R" remove="sudo pacman -R"
fi fi
distro="ARCH" distro="ARCH"
elif [ $d -eq 3 ]; then
distro="MAC"
update="brew update; brew upgrade"
install="brew install"
remove="brew uninstall"
else else
echo "[E] Distro not supported." echo "[E] Distro not supported."
return 1 return 1
@@ -56,68 +68,68 @@ p() {
fi fi
# If no parameter # If no parameter
if [ -z $1 ] || [ $1 == "u" ]; then if [ -z $1 ] || [ $1 = "u" ]; then
echo -e "${GREEN}"[+] Updating distro packages..."${ENDCOLOR}" echo -e "${GREEN}[+] Updating packages...${ENDCOLOR}"
$update bash -c $update
if $flatpak; then if $flatpak; then
echo echo
echo -e "${GREEN}"[+] Updating flatpaks..."${ENDCOLOR}" echo -e "${GREEN}[+] Updating flatpaks...${ENDCOLOR}"
flatpak upgrade flatpak upgrade
fi fi
echo -e "${GREEN}"[i] done."${ENDCOLOR}" echo -e "${GREEN}[i] done.${ENDCOLOR}"
return 0 return 0
elif [ $1 == "i" ]; then # If first parameter is i (install) elif [ $1 = "i" ]; then # If first parameter is i (install)
echo -e "${GREEN}"[+] Searching for $2 on the distro repos..."${ENDCOLOR}" echo -e "${GREEN}[+] Searching for $2 on the repository...${ENDCOLOR}"
$install $2 bash -c "$install $2"
if [ $? == 0 ]; then if [ $? -eq 0 ]; then
echo -e "${GREEN}"[i] $2 installed."${ENDCOLOR}" echo -e "${GREEN}[i] $2 installed.${ENDCOLOR}"
return 0 return 0
else else
if $flatpak; then if $flatpak; then
echo echo
echo -e "${YELLOW}"[E] $2 not found."${ENDCOLOR}" echo -e "${YELLOW}[E] $2 not found.${ENDCOLOR}"
echo -e "${GREEN}"[+] Searching for $2 as a flatpak..."${ENDCOLOR}" echo -e "${GREEN}[+] Searching for $2 as a flatpak...${ENDCOLOR}"
echo echo
flatpak install $2 2>/dev/null flatpak install $2 2>/dev/null
if [ $? == 0 ]; then if [ $? -eq 0 ]; then
echo -e "${GREEN}"[i] $2 installed."${ENDCOLOR}" echo -e "${GREEN}[i] $2 installed.${ENDCOLOR}"
return 0 return 0
fi fi
fi fi
echo -e "${RED}"[E] $2 not found or already installed."${ENDCOLOR}" echo -e "${RED}[E] $2 not found or already installed.${ENDCOLOR}"
return 2 return 2
fi fi
elif [ $1 == "r" ]; then # If first parameter is r (remove) elif [ $1 = "r" ]; then # If first parameter is r (remove)
echo -e "${YELLOW}"[+] Removing $2..."${ENDCOLOR}" echo -e "${YELLOW}[+] Removing $2...${ENDCOLOR}"
$remove $2 bash -c "$remove $2"
if [ $? == 0 ]; then if [ $? -eq 0 ]; then
echo -e "${GREEN}"[i] $2 removed."${ENDCOLOR}" echo -e "${GREEN}[i] $2 removed.${ENDCOLOR}"
return 0 return 0
else else
if $flatpak; then if $flatpak; then
echo echo
echo -e "${YELLOW}"[E] $2 not found."${ENDCOLOR}" echo -e "${YELLOW}[E] $2 not found.${ENDCOLOR}"
echo "[+] Searching for $2 as a flatpak..." echo "[+] Searching for $2 as a flatpak..."
echo -e "${GREEN}"[+] Searching for $2 as a flatpak..."${ENDCOLOR}" echo -e "${GREEN}[+] Searching for $2 as a flatpak...${ENDCOLOR}"
echo echo
flatpak remove $2 2>/dev/null flatpak remove $2 2>/dev/null
if [ $? == 0 ]; then if [ $? -eq 0 ]; then
echo -e "${GREEN}"[i] $2 removed."${ENDCOLOR}" echo -e "${GREEN}[i] $2 removed.${ENDCOLOR}"
return 0 return 0
fi fi
fi fi
echo -e "${RED}"[E] $2 not found."${ENDCOLOR}" echo -e "${RED}[E] $2 not found.${ENDCOLOR}"
return 2 return 2
fi fi
elif [ $1 == "c" ]; then # If first parameter is c (check) elif [ $1 = "c" ]; then # If first parameter is c (check)
if [ "$distro" == "DEB" ]; then if [ "$distro" = "DEB" ]; then
if dpkg-query -W -f='${Status}' $2 2>/dev/null | grep -q "install ok installed"; then if dpkg-query -W -f='${Status}' $2 2>/dev/null | grep -q "install ok installed"; then
echo true echo true
return 0 return 0
else else
if $flatpak; then if $flatpak; then
flatpak list | grep $2 &>/dev/null flatpak list | grep $2 &>/dev/null
if [ $? == 0 ]; then if [ $? -eq 0 ]; then
echo true echo true
return 0 return 0
fi fi
@@ -125,14 +137,14 @@ p() {
echo false echo false
return 1 return 1
fi fi
elif [ "$distro" == "ARCH" ]; then elif [ "$distro" = "ARCH" ]; then
if pacman -Qs $2 >/dev/null; then if pacman -Qs $2 >/dev/null; then
echo true echo true
return 0 return 0
else else
if $flatpak; then if $flatpak; then
flatpak list | grep -i $2 &>/dev/null flatpak list | grep -i $2 &>/dev/null
if [ $? == 0 ]; then if [ $? -eq 0 ]; then
echo true echo true
return 0 return 0
fi fi
@@ -140,6 +152,14 @@ p() {
echo false echo false
return 1 return 1
fi fi
elif [ "$distro" = "MAC" ]; then
if brew list | grep $2 >/dev/null; then
echo true
return 0
else
echo false
return 1
fi
else else
echo 2 echo 2
fi fi