a heavy fix on bash scripts.

This commit is contained in:
clsty 2023-12-30 10:06:11 +08:00
parent 70f331c89d
commit 9057705592
3 changed files with 109 additions and 53 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
.config/ags/style.css
.config/hypr/colors.conf
.config/ags/scss/_material.scss
/ags

View file

@ -1,47 +1,99 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"
function try { "$@" || sleep 0; }
function v() {
echo -e "[$0]: \e[32mNow executing:\e[0m"
echo -e "\e[34m$@\e[0m"
execute=true
if $ask;then
while true;do
echo "Do you want to execute this command? "
echo " y = Yes"
echo " a = Abort this script"
echo " s = Skip this command; NOT recommended unless you really sure"
echo " yesforall = yes and don't ask again; NOT recommended unless you really sure"
read -p "Enter here [y/a/s/yesforall]:" p
case $p in
[yY]) echo -e "\e[32mOK, executing...\e[0m" ;break ;;
[aA]) echo -e "\e[32mAborting...\e[0m" ;exit ;break ;;
[sS]) echo -e "\e[32mAlright, skipping this one...\e[0m" ;export execute=false ;break ;;
"yesforall") echo -e "\e[32mAlright, won't ask again. Executing...\e[0m"; export ask=false ;break ;;
*) echo -e "\e[31mPlease enter one of [y/a/s/yesforall].\e[0m";;
esac
done
fi
if $execute;then
"$@"
fi
}
checkexist() {
if command -v $1 >/dev/null 2>&1; then
echo "Command $1 found."
else
echo "Error: Command $1 not found, aborting..."
exit 1
fi
}
printf 'Hi there!\n'
printf 'This script 1. only works for ArchLinux and Arch-based distros.\n'
printf ' 2. has not been tested, use at your own risk.\n'
printf ' 3. will show all commands that it runs.\n'
printf "\e[36m== BACKUP YOUR CONFIG FOLDER IF NEEDED! ==\n"
printf 'Ctrl+C to exit. Enter to continue.\n'
read -r
printf ' 2. has not been fully tested, use at your own risk.\n'
printf "\e[36m== PLEASE BACKUP \"$HOME/.config\" AND \"$HOME/.local\" BY YOURSELF IF NEEDED! ==\n\e[97m"
printf '\n'
printf 'Do you want to confirm everytime before a command executes?\n'
printf ' y = Yes, ask me before executing each of them. (RECOMMENDED)\n'
printf ' n = No, just execute them automatically.\n'
printf ' E = Exit this script. (DEFAULT)\n'
read -p "Enter y/n/E: " p
case $p in
y)export ask=true;;
n)export ask=false; export c=" --noconfirm" ;;
*)exit;;
esac
set -e
#####################################################################################
printf '\e[36m1. Get packages and add user to video/input groups\n\e[97m'
set -v
yay -S --needed --noconfirm blueberry brightnessctl coreutils curl fish foot fuzzel gjs gnome-bluetooth-3.0 gnome-control-center gnome-keyring gobject-introspection grim gtk3 gtk-layer-shell libdbusmenu-gtk3 meson networkmanager npm plasma-browser-integration playerctl polkit-gnome python-pywal ripgrep sassc slurp starship swayidle swaylock typescript upower xorg-xrandr webp-pixbuf-loader wget wireplumber wl-clipboard tesseract yad ydotool adw-gtk3-git cava gojq gradience-git gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hyprland-git lexend-fonts-git python-material-color-utilities python-pywal python-poetry python-build python-pillow swaylock-effects-git swww ttf-material-symbols-variable-git ttf-space-mono-nerd ttf-jetbrains-mono-nerd wayland-idle-inhibitor-git wlogout wlsunset-git
v yay -S --needed$c blueberry brightnessctl coreutils curl fish foot fuzzel gjs gnome-bluetooth-3.0 gnome-control-center gnome-keyring gobject-introspection grim gtk3 gtk-layer-shell libdbusmenu-gtk3 meson networkmanager npm plasma-browser-integration playerctl polkit-gnome python-pywal ripgrep sassc slurp starship swayidle typescript upower xorg-xrandr webp-pixbuf-loader wget wireplumber wl-clipboard tesseract yad ydotool adw-gtk3-git cava gojq gradience-git gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hyprland lexend-fonts-git python-material-color-utilities python-pywal python-poetry python-build python-pillow swaylock-effects-git swww ttf-material-symbols-variable-git ttf-space-mono-nerd ttf-jetbrains-mono-nerd wayland-idle-inhibitor-git wlogout wlsunset-git
user=$(whoami)
sudo usermod -aG video "$user"
sudo usermod -aG input "$user"
v sudo usermod -aG video "$(whoami)"
v sudo usermod -aG input "$(whoami)"
#####################################################################################
set +v
printf '\e[36m2. Installing AGS manually\e[97m\n'
printf '\e[36m2. Installing AGS from git repo\e[97m\n'
sleep 1
set -v
git clone --recursive https://github.com/Aylur/ags.git
set +v
v git clone --recursive https://github.com/Aylur/ags.git|| \
if [ -d ags ];then printf "\e[36mSeems \"./ags\" already exists.\e[97m\n";else exit 1;fi
sleep 1
set -v
npm install && meson setup build
meson install -C build
installags (){
cd ags
v npm install
v meson setup build
v meson install -C build
}
checkexist ags || installags
cd "$(dirname "$0")"
#####################################################################################
set +v
printf '\e[36m3. Copying\e[97m\n'
set -v
cp -r "./.config" "$HOME"
cp -r "./.local" "$HOME"
# In case ~/.local/bin does not exists
v mkdir -p "$HOME/.local/bin"
# --delete to make sure that
# original dot files and new ones in the SAME DIRECTORY
# (eg. in ~/.config/hypr) won't be mixed together
for i in .config/* .local/*
do
if [ -d "$i" ];then v rsync -av --delete "$i/" "$HOME/$i/"
elif [ -f "$i" ];then v rsync -av "$i" "$HOME/$i"
fi
done
#####################################################################################
set +v
printf 'Finished. See the "Import manually" folder and grab anything you need.\e[97m\n'
printf 'Press Ctrl+Super+T to select a wallpaper\e[97m\n'
printf 'Press Super+/ for a list of keybinds\e[97m\n'
printf '\e[36mFinished. See the "Import manually" folder and grab anything you need.\e[97m\n'
printf '\e[36mPress Ctrl+Super+T to select a wallpaper\e[97m\n'
printf '\e[36mPress Super+/ for a list of keybinds\e[97m\n'

View file

@ -1,22 +1,30 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
echo 'Hi there!'
echo 'This script 1. will uninstall [end-4/dots-hyprland > illogical-impulse] dotfiles'
echo ' 2. will try to revert *mostly everything* installed using install.sh, so it'\''s pretty destructive'
echo ' 3. has not beed tested, use at your own risk.'
echo ' 4. will show all commands that it runs.'
echo ' 5. should be run from its folder.'
echo 'Ctrl+C to exit. Enter to continue.'
read
function v() {
echo -e "[$0]: \e[32mNow executing:\e[0m"
echo -e "\e[32m$@\e[0m"
"$@"
}
printf 'Hi there!\n'
printf 'This script 1. will uninstall [end-4/dots-hyprland > illogical-impulse] dotfiles\n'
printf ' 2. will try to revert *mostly everything* installed using install.sh, so it'\''s pretty destructive\n'
printf ' 3. has not beed tested, use at your own risk.\n'
printf ' 4. will show all commands that it runs.\n'
printf 'Ctrl+C to exit. Enter to continue.\n'
read -r
set -e
##############################################################################################################################
# Undo Step 3: Removing copied config and local folders
echo 'Removing copied config and local folders...'
echo 'rm -rf "$HOME/.config/ags" "$HOME/.config/fish" "$HOME/.config/frontconfig" "$HOME/.config/foot" "$HOME/.config/fuzzel" "$HOME/.config/gtklock" "$HOME/.config/hypr" "$HOME/.config/mpv" "$HOME/.config/swaylock" "$HOME/.config/wlogout" "$HOME/.config/starship.toml" '
rm -rf "$HOME/.config/ags" "$HOME/.config/fish" "$HOME/.config/frontconfig" "$HOME/.config/foot" "$HOME/.config/fuzzel" "$HOME/.config/gtklock" "$HOME/.config/hypr" "$HOME/.config/mpv" "$HOME/.config/swaylock" "$HOME/.config/wlogout" "$HOME/.config/starship.toml"
echo 'rm -rf "$HOME/.local/bin/fuzzel-emoji" "$HOME/.config/rubyshot"'
rm -rf "$HOME/.local/bin/fuzzel-emoji" "$HOME/.config/rubyshot"
printf '\e[36mRemoving copied config and local folders...\n\e[97m'
for i in ags fish fontconfig foot fuzzel gtklock hypr mpv swaylock wlogout "starship.toml" rubyshot
do v rm -rf "$HOME/.config/$i"
done
v rm -rf "$HOME/.local/bin/fuzzel-emoji"
##############################################################################################################################
@ -28,19 +36,14 @@ rm -rf "$HOME/.local/bin/fuzzel-emoji" "$HOME/.config/rubyshot"
##############################################################################################################################
# Undo Step 1: Remove added user from video and input groups and remove yay packages
echo 'Removing user from video and input groups and removing packages...'
printf '\e[36mRemoving user from video and input groups and removing packages...\n\e[97m'
user=$(whoami)
echo 'sudo deluser "$user" video'
sudo deluser "$user" video
echo 'sudo deluser "$user" input'
sudo deluser "$user" input
echo 'User removed from video and input groups.'
v sudo deluser "$user" video
v sudo deluser "$user" input
##############################################################################################################################
# Removing installed yay packages and dependencies
echo 'yay -Rns adw-gtk3-git brightnessctl cava foot fuzzel gjs gojq gradience-git grim gtk-layer-shell gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hyprland-git lexend-fonts-git libdbusmenu-gtk3 plasma-browser-integration playerctl python-build python-material-color-utilities python-poetry python-pywal ripgrep sassc slurp starship swayidle swaylock swww tesseract ttf-jetbrains-mono-nerd ttf-material-symbols-variable-git ttf-space-mono-nerd typescript webp-pixbuf-loader wl-clipboard wlogout yad ydotool'
yay -Rns adw-gtk3-git brightnessctl cava foot fuzzel gjs gojq gradience-git grim gtk-layer-shell gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hyprland-git lexend-fonts-git libdbusmenu-gtk3 plasma-browser-integration playerctl python-build python-material-color-utilities python-poetry python-pywal ripgrep sassc slurp starship swayidle swaylock swww tesseract ttf-jetbrains-mono-nerd ttf-material-symbols-variable-git ttf-space-mono-nerd typescript webp-pixbuf-loader wl-clipboard wlogout yad ydotool
v yay -Rns adw-gtk3-git brightnessctl cava foot fuzzel gjs gojq gradience-git grim gtk-layer-shell gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hyprland-git lexend-fonts-git libdbusmenu-gtk3 plasma-browser-integration playerctl python-build python-material-color-utilities python-poetry python-pywal ripgrep sassc slurp starship swayidle swaylock swww tesseract ttf-jetbrains-mono-nerd ttf-material-symbols-variable-git ttf-space-mono-nerd typescript webp-pixbuf-loader wl-clipboard wlogout yad ydotool
echo 'Uninstall Complete.'
printf '\e[36mUninstall Complete.\n\e[97m'