From a11d325a192d5679133b82ccbaf55b1a0ac6baa1 Mon Sep 17 00:00:00 2001 From: Dante <150515748+xsghetti@users.noreply.github.com> Date: Wed, 13 Mar 2024 11:42:02 -0500 Subject: [PATCH] Install Script Testing --- Scripts/create_cache.sh | 107 ++++++++++++++++++++++ Scripts/custom_apps.lst | 11 +++ Scripts/custom_hypr.lst | 84 ++++++++++++++++++ Scripts/global_fn.sh | 110 +++++++++++++++++++++++ Scripts/install.sh | 179 +++++++++++++++++++++++++++++++++++++ Scripts/install_aur.sh | 49 ++++++++++ Scripts/install_pkg.lst | 80 +++++++++++++++++ Scripts/install_pkg.sh | 100 +++++++++++++++++++++ Scripts/install_pre.sh | 102 +++++++++++++++++++++ Scripts/install_pst.sh | 112 +++++++++++++++++++++++ Scripts/restore_cfg.lst | 26 ++++++ Scripts/restore_cfg.sh | 88 ++++++++++++++++++ Scripts/restore_fnt.lst | 48 ++++++++++ Scripts/restore_fnt.sh | 33 +++++++ Scripts/restore_lnk.sh | 31 +++++++ Scripts/restore_shl.sh | 62 +++++++++++++ Scripts/restore_zsh.lst | 8 ++ Scripts/system_ctl.lst | 3 + Scripts/themepatcher.lst | 3 + Scripts/themepatcher.sh | 157 ++++++++++++++++++++++++++++++++ Scripts/wallbash.sh | 187 +++++++++++++++++++++++++++++++++++++++ 21 files changed, 1580 insertions(+) create mode 100644 Scripts/create_cache.sh create mode 100644 Scripts/custom_apps.lst create mode 100644 Scripts/custom_hypr.lst create mode 100644 Scripts/global_fn.sh create mode 100644 Scripts/install.sh create mode 100644 Scripts/install_aur.sh create mode 100644 Scripts/install_pkg.lst create mode 100644 Scripts/install_pkg.sh create mode 100644 Scripts/install_pre.sh create mode 100644 Scripts/install_pst.sh create mode 100644 Scripts/restore_cfg.lst create mode 100644 Scripts/restore_cfg.sh create mode 100644 Scripts/restore_fnt.lst create mode 100644 Scripts/restore_fnt.sh create mode 100644 Scripts/restore_lnk.sh create mode 100644 Scripts/restore_shl.sh create mode 100644 Scripts/restore_zsh.lst create mode 100644 Scripts/system_ctl.lst create mode 100644 Scripts/themepatcher.lst create mode 100644 Scripts/themepatcher.sh create mode 100644 Scripts/wallbash.sh diff --git a/Scripts/create_cache.sh b/Scripts/create_cache.sh new file mode 100644 index 00000000..201dd361 --- /dev/null +++ b/Scripts/create_cache.sh @@ -0,0 +1,107 @@ +#!/bin/bash +#|---/ /+------------------------------------+---/ /|# +#|--/ /-| Script to generate wallpaper cache |--/ /-|# +#|-/ /--| Kemipso |-/ /--|# +#|/ /---+------------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + +if ! pkg_installed imagemagick || ! pkg_installed parallel +then + echo "ERROR : dependency failed, imagemagick/parallel is not installed..." + exit 0 +fi + + +# set variables +ctlLine=`grep '^1|' ${ThemeCtl}` +export cacheDir="$HOME/.cache/hyprdots" + + +# evaluate options +while getopts "fc:" option ; do + case $option in + f ) # force remove cache + rm -Rf ${cacheDir} + echo "Cache dir ${cacheDir} cleared...";; + c ) # use custom wallpaper + inWall="$OPTARG" + if [[ "${inWall}" == '~'* ]]; then + inWall="$HOME${inWall:1}" + fi + if [[ -f "${inWall}" ]] ; then + if [ `echo "$ctlLine" | wc -l` -eq "1" ] ; then + curTheme=$(echo "$ctlLine" | cut -d '|' -f 2) + awk -F '|' -v thm="${curTheme}" -v wal="${inWall}" '{OFS=FS} {if($2==thm)$NF=wal;print$0}' "${ThemeCtl}" > /tmp/t2 && mv /tmp/t2 "${ThemeCtl}" + else + echo "ERROR : ${ThemeCtl} Unable to fetch theme..." + exit 1 + fi + else + echo "ERROR: wallpaper ${inWall} not found..." + exit 1 + fi ;; + * ) # invalid option + echo "...valid options are..." + echo "./create_cache.sh -f # force create thumbnails (delete old cache)" + echo "./create_cache.sh -c /path/to/wallpaper # generate cache for custom walls" + exit 1 ;; + esac +done + +shift $((OPTIND - 1)) +ctlRead=$(awk -F '|' -v thm="${1}" '{if($2==thm) print$0}' "${ThemeCtl}") +[ -z "${ctlRead}" ] && ctlRead=$(cat "${ThemeCtl}") + + +# magick function +imagick_t2 () { + theme="$1" + wpFullName="$2" + wpBaseName=$(basename "${wpFullName}") + + if [ ! -f "${cacheDir}/${theme}/${wpBaseName}" ]; then + convert "${wpFullName}"[0] -thumbnail 500x500^ -gravity center -extent 500x500 "${cacheDir}/${theme}/${wpBaseName}" + fi + + if [ ! -f "${cacheDir}/${theme}/${wpBaseName}.rofi" ]; then + convert -strip -resize 2000 -gravity center -extent 2000 -quality 90 "${wpFullName}"[0] "${cacheDir}/${theme}/${wpBaseName}.rofi" + fi + + if [ ! -f "${cacheDir}/${theme}/${wpBaseName}.blur" ]; then + convert -strip -scale 10% -blur 0x3 -resize 100% "${wpFullName}"[0] "${cacheDir}/${theme}/${wpBaseName}.blur" + fi + + if [ ! -f "${cacheDir}/${theme}/${wpBaseName}.dcol" ] ; then + ./wallbash.sh "${wpFullName}" &> /dev/null + fi +} + +export -f imagick_t2 + + +# create thumbnails for each theme > wallpapers +echo "${ctlRead}" | while read ctlLine +do + theme=$(echo $ctlLine | awk -F '|' '{print $2}') + fullPath=$(echo "$ctlLine" | awk -F '|' '{print $NF}' | sed "s+~+$HOME+") + wallPath=$(dirname "$fullPath") + mkdir -p ${cacheDir}/${theme} + mapfile -d '' wpArray < <(find "${wallPath}" -type f \( -iname "*.gif" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -print0 | sort -z) + echo "Creating thumbnails for ${theme} [${#wpArray[@]}]" + parallel --bar imagick_t2 ::: "${theme}" ::: "${wpArray[@]}" + + if pkg_installed code ; then + if [ ! -z "$(echo $ctlLine | awk -F '|' '{print $3}')" ] ; then + codex=$(echo $ctlLine | awk -F '|' '{print $3}' | cut -d '~' -f 1) + if [ $(code --list-extensions | grep -iwc "${codex}") -eq 0 ] ; then + code --install-extension "${codex}" 2> /dev/null || true + fi + fi + fi +done + diff --git a/Scripts/custom_apps.lst b/Scripts/custom_apps.lst new file mode 100644 index 00000000..66e66193 --- /dev/null +++ b/Scripts/custom_apps.lst @@ -0,0 +1,11 @@ +#neovim +#emote +#trash-cli-git +#downgrade +steam +gamemode +#gamescope +#mangohud +#cava +spotify +spicetify-cli diff --git a/Scripts/custom_hypr.lst b/Scripts/custom_hypr.lst new file mode 100644 index 00000000..40882ddb --- /dev/null +++ b/Scripts/custom_hypr.lst @@ -0,0 +1,84 @@ +# --------------------------------------------------- // System +pipewire # audio/video server +pipewire-alsa # pipewire alsa client +pipewire-audio # pipewire audio client +pipewire-jack # pipewire jack client +pipewire-pulse # pipewire pulseaudio client +gst-plugin-pipewire # pipewire gstreamer client +wireplumber # pipewire session manager +pavucontrol # pulseaudio volume control +pamixer # pulseaudio cli mixer +networkmanager # network manager +network-manager-applet # network manager system tray utility +bluez # bluetooth protocol stack +bluez-utils # bluetooth utility cli +blueman # bluetooth manager gui +brightnessctl # screen brightness control + + +# --------------------------------------------------- // Display Manager +sddm # display manager for KDE plasma +qt5-quickcontrols # for sddm theme ui elements +qt5-quickcontrols2 # for sddm theme ui elements +qt5-graphicaleffects # for sddm theme effects + + +# --------------------------------------------------- // Window Manager +hyprland # wlroots-based wayland compositor +dunst # notification daemon +rofi-lbonn-wayland-git # application launcher +waybar # system bar +swww # wallpaper +swaylock-effects-git # lock screen +wlogout # logout menu +grimblast-git # screenshot tool +hyprpicker-git # color picker +slurp # region select for screenshot/screenshare +swappy # screenshot editor +cliphist # clipboard manager + + +# --------------------------------------------------- // Dependencies +polkit-kde-agent # authentication agent +xdg-desktop-portal-hyprland # xdg desktop portal for hyprland +pacman-contrib # for system update check +python-pyamdgpuinfo # for amd gpu info +parallel # for parallel processing +jq # for json processing +imagemagick # for image processing +qt5-imageformats # for dolphin image thumbnails +ffmpegthumbs # for dolphin video thumbnails +kde-cli-tools # for dolphin file type defaults + + +# --------------------------------------------------- // Theming +nwg-look # gtk configuration tool +qt5ct # qt5 configuration tool +qt6ct # qt6 configuration tool +kvantum # svg based qt theme engine +qt5-wayland # wayland support in qt5 +qt6-wayland # wayland support in qt6 + + +# --------------------------------------------------- // Applications +firefox # browser +kitty # terminal +dolphin # kde file manager +ark # kde file archiver +vim # terminal text editor +visual-studio-code-bin # ide text editor + + +# --------------------------------------------------- // Shell +eza|zsh # file lister for zsh +oh-my-zsh-git|zsh # plugin manager for zsh +zsh-theme-powerlevel10k|zsh oh-my-zsh-git # theme for zsh +lsd|fish # file lister for fish +starship|fish # customizable shell prompt +neofetch # fetch tool +pokemon-colorscripts-git|zsh # display pokemon sprites + + +# --------------------------------------------------- // Hyprdots +hyprdots-ctl # cli tool to manage hyprdots + diff --git a/Scripts/global_fn.sh b/Scripts/global_fn.sh new file mode 100644 index 00000000..2f70f67e --- /dev/null +++ b/Scripts/global_fn.sh @@ -0,0 +1,110 @@ +#!/bin/bash +#|---/ /+------------------+---/ /|# +#|--/ /-| Global functions |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+------------------+/ /---|# + +set -e + +CloneDir=`dirname "$(dirname "$(realpath "$0")")"` +ConfDir="${XDG_CONFIG_HOME:-$HOME/.config}" +HyprdotsDir="${ConfDir}/hyprdots" +ThemeCtl="${HyprdotsDir}/theme.ctl" + +service_ctl() +{ + local ServChk=$1 + + if [[ $(systemctl list-units --all -t service --full --no-legend "${ServChk}.service" | sed 's/^\s*//g' | cut -f1 -d' ') == "${ServChk}.service" ]] + then + echo "$ServChk service is already enabled, enjoy..." + else + echo "$ServChk service is not running, enabling..." + sudo systemctl enable ${ServChk}.service + sudo systemctl start ${ServChk}.service + echo "$ServChk service enabled, and running..." + fi +} + +pkg_installed() +{ + local PkgIn=$1 + + if pacman -Qi $PkgIn &> /dev/null + then + #echo "${PkgIn} is already installed..." + return 0 + else + #echo "${PkgIn} is not installed..." + return 1 + fi +} + +pkg_available() +{ + local PkgIn=$1 + + if pacman -Si $PkgIn &> /dev/null + then + #echo "${PkgIn} available in arch repo..." + return 0 + else + #echo "${PkgIn} not available in arch repo..." + return 1 + fi +} + +chk_aurh() +{ + if pkg_installed yay + then + aurhlpr="yay" + elif pkg_installed paru + then + aurhlpr="paru" + fi +} + +aur_available() +{ + local PkgIn=$1 + chk_aurh + + if $aurhlpr -Si $PkgIn &> /dev/null + then + #echo "${PkgIn} available in aur repo..." + return 0 + else + #echo "aur helper is not installed..." + return 1 + fi +} + +nvidia_detect() +{ + if [ `lspci -k | grep -A 2 -E "(VGA|3D)" | grep -i nvidia | wc -l` -gt 0 ] + then + #echo "nvidia card detected..." + return 0 + else + #echo "nvidia card not detected..." + return 1 + fi +} + +prompt_timer() +{ + set +e + local timsec=$1 + local msg=$2 + local pread="" + while [[ $timsec -ge 0 ]] ; do + echo -ne "\033[0K\r${msg} (${timsec}s) : " + read -t 1 -n 1 -s promptIn + [ $? -eq 0 ] && break + ((timsec--)) + done + export promptIn + echo ${promptIn} + set -e +} diff --git a/Scripts/install.sh b/Scripts/install.sh new file mode 100644 index 00000000..14553857 --- /dev/null +++ b/Scripts/install.sh @@ -0,0 +1,179 @@ +#!/bin/bash +#|---/ /+--------------------------+---/ /|# +#|--/ /-| Main installation script |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|--/ /-| xSghetti Edit |--/ /-|# +#|/ /---+--------------------------+/ /---|# + +cat <<"EOF" + +------------------------------------------------------------------------------------ + _____ _ _ _ _ _____ _____ + _ _| __|___| |_ ___| |_| |_|_| _ _ | | |_ _ ___ ___| |___ _ _ _ _ +|_'_|__ | . | | -_| _| _| | |_'_| | | | | . | _| --| _| | |_'_| +|_,_|_____|_ |_|_|___|_| |_| |_| |_,_| |__|__|_ | _|_| |_____|_| |___|_,_| + |___| |___|_| +------------------------------------------------------------------------------------ + +EOF + + +#--------------------------------# +# import variables and functions # +#--------------------------------# +source global_fn.sh +if [ $? -ne 0 ]; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + + +#------------------# +# evaluate options # +#------------------# +flg_Install=0 +flg_Restore=0 +flg_Service=0 + +while getopts idrs RunStep; do + case $RunStep in + i) flg_Install=1 ;; + d) flg_Install=1 + export use_default="--noconfirm" ;; + r) flg_Restore=1 ;; + s) flg_Service=1 ;; + *) echo "...valid options are..." + echo "i : [i]nstall hyprland without configs" + echo "d : install hyprland [d]efaults without configs --noconfirm" + echo "r : [r]estore config files" + echo "s : enable system [s]ervices" + exit 1 ;; + esac +done + +if [ $OPTIND -eq 1 ]; then + flg_Install=1 + flg_Restore=1 + flg_Service=1 +fi + + +#--------------------# +# pre-install script # +#--------------------# +if [ $flg_Install -eq 1 ] && [ $flg_Restore -eq 1 ]; then + cat <<"EOF" + _ _ _ _ + ___ ___ ___ |_|___ ___| |_ ___| | | +| . | _| -_| | | |_ -| _| .'| | | +| _|_| |___| |_|_|_|___|_| |__,|_|_| +|_| + +EOF + + ./install_pre.sh +fi + + +#------------# +# installing # +#------------# +if [ $flg_Install -eq 1 ]; then + cat <<"EOF" + + _ _ _ _ _ +|_|___ ___| |_ ___| | |_|___ ___ +| | |_ -| _| .'| | | | | . | +|_|_|_|___|_| |__,|_|_|_|_|_|_ | + |___| + +EOF + + #----------------------# + # prepare package list # + #----------------------# + shift $((OPTIND - 1)) + cust_pkg=$1 + cp custom_hypr.lst install_pkg.lst + + if [ -f "$cust_pkg" ] && [ ! -z "$cust_pkg" ]; then + cat $cust_pkg >>install_pkg.lst + fi + + #-----------------------# + # add shell to the list # + #-----------------------# + if ! pkg_installed zsh && ! pkg_installed fish ; then + echo -e "Select shell:\n1) zsh\n2) fish" + read -p "Enter option number : " gsh + + case $gsh in + 1) export getShell="zsh" ;; + 2) export getShell="fish" ;; + *) echo -e "...Invalid option selected..." + exit 1 ;; + esac + echo "${getShell}" >>install_pkg.lst + fi + + #--------------------------------# + # add nvidia drivers to the list # + #--------------------------------# + if nvidia_detect; then + cat /usr/lib/modules/*/pkgbase | while read krnl; do + echo "${krnl}-headers" >>install_pkg.lst + done + IFS=$' ' read -r -d '' -a nvga < <(lspci -k | grep -E "(VGA|3D)" | grep -i nvidia | awk -F ':' '{print $NF}' | tr -d '[]()' && printf '\0') + for nvcode in "${nvga[@]}"; do + awk -F '|' -v nvc="${nvcode}" '{if ($3 == nvc) {split(FILENAME,driver,"/"); print driver[length(driver)],"\nnvidia-utils"}}' .nvidia/nvidia*dkms >>install_pkg.lst + done + echo -e "\033[0;32m[GPU]\033[0m detected // ${nvga[@]}" + else + echo "nvidia card not detected, skipping nvidia drivers..." + fi + + #--------------------------------# + # install packages from the list # + #--------------------------------# + ./install_pkg.sh install_pkg.lst + rm install_pkg.lst + +fi + + +#---------------------# +# post-install script # +#---------------------# +if [ $flg_Install -eq 1 ] && [ $flg_Restore -eq 1 ]; then + cat <<"EOF" + + _ _ _ _ _ + ___ ___ ___| |_ |_|___ ___| |_ ___| | | +| . | . |_ -| _| | | |_ -| _| .'| | | +| _|___|___|_| |_|_|_|___|_| |__,|_|_| +|_| + +EOF + + ./install_pst.sh +fi + + +#------------------------# +# enable system services # +#------------------------# +if [ $flg_Service -eq 1 ]; then + cat <<"EOF" + + _ + ___ ___ ___ _ _|_|___ ___ ___ +|_ -| -_| _| | | | _| -_|_ -| +|___|___|_| \_/|_|___|___|___| + +EOF + + while read service ; do + service_ctl $service + done < system_ctl.lst +fi + diff --git a/Scripts/install_aur.sh b/Scripts/install_aur.sh new file mode 100644 index 00000000..b40aaeb6 --- /dev/null +++ b/Scripts/install_aur.sh @@ -0,0 +1,49 @@ +#!/bin/bash +#|---/ /+-----------------------------------+---/ /|# +#|--/ /-| Script to install aur helper, yay |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+-----------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + +aurhlpr="${1:-yay}" + +if pkg_installed yay || pkg_installed paru +then + echo "aur helper is already installed..." + exit 0 +fi + +if [ -d ~/Clone ] +then + echo "~/Clone directory exists..." + rm -rf ~/Clone/$aurhlpr +else + mkdir ~/Clone + echo -e "[Desktop Entry]\nIcon=default-folder-git" > ~/Clone/.directory + echo "~/Clone directory created..." +fi + +if pkg_installed git +then + git clone https://aur.archlinux.org/$aurhlpr.git ~/Clone/$aurhlpr +else + echo "git dependency is not installed..." + exit 1 +fi + +cd ~/Clone/$aurhlpr +makepkg ${use_default} -si + +if [ $? -eq 0 ] +then + echo "$aurhlpr aur helper installed..." + exit 0 +else + echo "$aurhlpr installation failed..." + exit 1 +fi diff --git a/Scripts/install_pkg.lst b/Scripts/install_pkg.lst new file mode 100644 index 00000000..3841f177 --- /dev/null +++ b/Scripts/install_pkg.lst @@ -0,0 +1,80 @@ +# --------------------------------------------------- // System +pipewire # audio/video server +pipewire-alsa # pipewire alsa client +pipewire-audio # pipewire audio client +pipewire-jack # pipewire jack client +pipewire-pulse # pipewire pulseaudio client +gst-plugin-pipewire # pipewire gstreamer client +wireplumber # pipewire session manager +pavucontrol # pulseaudio volume control +pamixer # pulseaudio cli mixer +networkmanager # network manager +network-manager-applet # network manager system tray utility +bluez # bluetooth protocol stack +bluez-utils # bluetooth utility cli +blueman # bluetooth manager gui +brightnessctl # screen brightness control + + +# --------------------------------------------------- // Display Manager +sddm # display manager for KDE plasma +qt5-quickcontrols # for sddm theme ui elements +qt5-quickcontrols2 # for sddm theme ui elements +qt5-graphicaleffects # for sddm theme effects + + +# --------------------------------------------------- // Window Manager +hyprland # wlroots-based wayland compositor +dunst # notification daemon +rofi-lbonn-wayland-git # application launcher +waybar # system bar +swww # wallpaper +swaylock-effects-git # lock screen +wlogout # logout menu +grimblast-git # screenshot tool +hyprpicker-git # color picker +slurp # region select for screenshot/screenshare +swappy # screenshot editor +cliphist # clipboard manager + + +# --------------------------------------------------- // Dependencies +polkit-kde-agent # authentication agent +xdg-desktop-portal-hyprland # xdg desktop portal for hyprland +pacman-contrib # for system update check +python-pyamdgpuinfo # for amd gpu info +parallel # for parallel processing +jq # for json processing +imagemagick # for image processing +qt5-imageformats # for dolphin image thumbnails +ffmpegthumbs # for dolphin video thumbnails +kde-cli-tools # for dolphin file type defaults + + +# --------------------------------------------------- // Theming +nwg-look # gtk configuration tool +qt5ct # qt5 configuration tool +qt6ct # qt6 configuration tool +kvantum # svg based qt theme engine +qt5-wayland # wayland support in qt5 +qt6-wayland # wayland support in qt6 + + +# --------------------------------------------------- // Applications +firefox # browser +kitty # terminal +dolphin # kde file manager +ark # kde file archiver +vim # terminal text editor +visual-studio-code-bin # ide text editor + + +# --------------------------------------------------- // Shell +eza|zsh # file lister for zsh +oh-my-zsh-git|zsh # plugin manager for zsh +zsh-theme-powerlevel10k|zsh oh-my-zsh-git # theme for zsh +neofetch # fetch tool + + +zsh +linux-headers diff --git a/Scripts/install_pkg.sh b/Scripts/install_pkg.sh new file mode 100644 index 00000000..7bd9e4e9 --- /dev/null +++ b/Scripts/install_pkg.sh @@ -0,0 +1,100 @@ +#!/bin/bash +#|---/ /+----------------------------------------+---/ /|# +#|--/ /-| Script to install pkgs from input list |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+----------------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + +if ! pkg_installed git + then + echo "installing dependency git..." + sudo pacman -S git +fi + +chk_aurh + +if [ -z $aurhlpr ] + then + echo -e "Select aur helper:\n1) yay\n2) paru" + read -p "Enter option number : " aurinp + + case $aurinp in + 1) aurhlpr="yay" ;; + 2) aurhlpr="paru" ;; + *) echo -e "...Invalid option selected..." + exit 1 ;; + esac + + echo "installing dependency $aurhlpr..." + ./install_aur.sh $aurhlpr 2>&1 +fi + +install_list="${1:-install_pkg.lst}" +ofs=$IFS +IFS='|' + +while read -r pkg deps +do + pkg="${pkg// /}" + if [ -z "${pkg}" ] ; then + continue + fi + + if [ ! -z "${deps}" ] ; then + deps="${deps%"${deps##*[![:space:]]}"}" + while read -r cdep + do + pass=$(cut -d '#' -f 1 ${install_list} | awk -F '|' -v chk="${cdep}" '{if($1 == chk) {print 1;exit}}') + if [ -z "${pass}" ] ; then + if pkg_installed ${cdep} ; then + pass=1 + else + break + fi + fi + done < <(echo "${deps}" | xargs -n1) + + if [[ ${pass} -ne 1 ]] ; then + echo -e "\033[0;33m[SKIP]\033[0m ${pkg} is missing (${deps}) dependency..." + continue + fi + fi + + if pkg_installed ${pkg} + then + echo -e "\033[0;33m[SKIP]\033[0m ${pkg} is already installed..." + + elif pkg_available ${pkg} + then + repo=$(pacman -Si ${pkg} | awk -F ': ' '/Repository / {print $2}') + echo -e "\033[0;32m[${repo}]\033[0m queueing ${pkg} from official arch repo..." + pkg_arch=`echo ${pkg_arch} ${pkg}` + + elif aur_available ${pkg} + then + echo -e "\033[0;32m[aur]\033[0m queueing ${pkg} from arch user repo..." + pkg_aur=`echo ${pkg_aur} ${pkg}` + + else + echo "error: unknown package ${pkg}..." + fi +done < <( cut -d '#' -f 1 $install_list ) + +IFS=${ofs} + +if [ `echo $pkg_arch | wc -w` -gt 0 ] + then + echo "installing $pkg_arch from arch repo..." + sudo pacman ${use_default} -S $pkg_arch +fi + +if [ `echo $pkg_aur | wc -w` -gt 0 ] + then + echo "installing $pkg_aur from aur..." + $aurhlpr ${use_default} -S $pkg_aur +fi diff --git a/Scripts/install_pre.sh b/Scripts/install_pre.sh new file mode 100644 index 00000000..6b3e6e05 --- /dev/null +++ b/Scripts/install_pre.sh @@ -0,0 +1,102 @@ +#!/bin/bash +#|---/ /+-------------------------------------+---/ /|# +#|--/ /-| Script to apply pre install configs |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+-------------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + + +# grub +if pkg_installed grub && [ -f /boot/grub/grub.cfg ] + then + echo -e "\033[0;32m[BOOTLOADER]\033[0m detected // grub" + + if [ ! -f /etc/default/grub.t2.bkp ] && [ ! -f /boot/grub/grub.t2.bkp ] + then + echo -e "\033[0;32m[BOOTLOADER]\033[0m configuring grub..." + sudo cp /etc/default/grub /etc/default/grub.t2.bkp + sudo cp /boot/grub/grub.cfg /boot/grub/grub.t2.bkp + + if nvidia_detect + then + echo -e "\033[0;32m[BOOTLOADER]\033[0m nvidia detected, adding nvidia_drm.modeset=1 to boot option..." + gcld=$(grep "^GRUB_CMDLINE_LINUX_DEFAULT=" "/etc/default/grub" | cut -d'"' -f2 | sed 's/\b nvidia_drm.modeset=.\b//g') + sudo sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT=/c\GRUB_CMDLINE_LINUX_DEFAULT=\"${gcld} nvidia_drm.modeset=1\"" /etc/default/grub + fi + + echo -e "Select grub theme:\n1) Retroboot (dark)\n2) Pochita (light)" + read -p "Press enter to skip grub theme Enter option number : " grubopt + case ${grubopt} in + 1) grubtheme="Retroboot";; + 2) grubtheme="Pochita";; + *) grubtheme="None";; + esac + + if [ "${grubtheme}" == "None" ] ; then + echo -e "\033[0;32m[BOOTLOADER]\033[0m Skippinng grub theme..." + sudo sed -i "s/^GRUB_THEME=/#GRUB_THEME=/g" /etc/default/grub + else + echo -e "\033[0;32m[BOOTLOADER]\033[0m Setting grub theme // ${grubtheme}" + sudo tar -xzf ${CloneDir}/Source/arcs/Grub_${grubtheme}.tar.gz -C /usr/share/grub/themes/ + sudo sed -i "/^GRUB_DEFAULT=/c\GRUB_DEFAULT=saved + /^GRUB_GFXMODE=/c\GRUB_GFXMODE=1280x1024x32,auto + /^GRUB_THEME=/c\GRUB_THEME=\"/usr/share/grub/themes/${grubtheme}/theme.txt\" + /^#GRUB_THEME=/c\GRUB_THEME=\"/usr/share/grub/themes/${grubtheme}/theme.txt\" + /^#GRUB_SAVEDEFAULT=true/c\GRUB_SAVEDEFAULT=true" /etc/default/grub + fi + + sudo grub-mkconfig -o /boot/grub/grub.cfg + else + echo -e "\033[0;32m[BOOTLOADER]\033[0m grub is already configured..." + fi +fi + + +# systemd-boot +if pkg_installed systemd && nvidia_detect && [ $(bootctl status | awk '{if ($1 == "Product:") print $2}') == "systemd-boot" ] + then + echo -e "\033[0;32m[BOOTLOADER]\033[0m detected // systemd-boot" + + if [ $(ls -l /boot/loader/entries/*.conf.t2.bkp 2> /dev/null | wc -l) -ne $(ls -l /boot/loader/entries/*.conf 2> /dev/null | wc -l) ] + then + echo "nvidia detected, adding nvidia_drm.modeset=1 to boot option..." + find /boot/loader/entries/ -type f -name "*.conf" | while read imgconf + do + sudo cp ${imgconf} ${imgconf}.t2.bkp + sdopt=$(grep -w "^options" ${imgconf} | sed 's/\b quiet\b//g' | sed 's/\b splash\b//g' | sed 's/\b nvidia_drm.modeset=.\b//g') + sudo sed -i "/^options/c${sdopt} quiet splash nvidia_drm.modeset=1" ${imgconf} + done + else + echo -e "\033[0;33m[SKIP]\033[0m systemd-boot is already configured..." + fi +fi + + +# pacman +if [ -f /etc/pacman.conf ] && [ ! -f /etc/pacman.conf.t2.bkp ] + then + echo -e "\033[0;32m[PACMAN]\033[0m adding extra spice to pacman..." + + sudo cp /etc/pacman.conf /etc/pacman.conf.t2.bkp + sudo sed -i "/^#Color/c\Color\nILoveCandy + /^#VerbosePkgLists/c\VerbosePkgLists + /^#ParallelDownloads/c\ParallelDownloads = 5" /etc/pacman.conf + sudo sed -i '/^#\[multilib\]/,+1 s/^#//' /etc/pacman.conf + + #if [ $(grep -w "^\[xero_hypr\]" /etc/pacman.conf | wc -l) -eq 0 ] && [ $(grep "https://repos.xerolinux.xyz/xero_hypr/x86_64/" /etc/pacman.conf | wc -l) -eq 0 ] + # then + # echo "adding [xero_hypr] repo to pacman..." + # echo -e "\n[xero_hypr]\nSigLevel = Required DatabaseOptional\nServer = https://repos.xerolinux.xyz/xero_hypr/x86_64/\n\n" | sudo tee -a /etc/pacman.conf + #fi + sudo pacman -Syyu + sudo pacman -Fy + +else + echo -e "\033[0;33m[SKIP]\033[0m pacman is already configured..." +fi + diff --git a/Scripts/install_pst.sh b/Scripts/install_pst.sh new file mode 100644 index 00000000..325b0f80 --- /dev/null +++ b/Scripts/install_pst.sh @@ -0,0 +1,112 @@ +#!/bin/bash +#|---/ /+--------------------------------------+---/ /|# +#|--/ /-| Script to apply post install configs |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+--------------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + + +# themepatcher +echo -e "\033[0;32m[THEMEPATCHER]\033[0m additional themes available..." +awk -F '"' '{print "["NR"]",$2}' themepatcher.lst +prompt_timer 10 "Patch these additional themes? [Y/n]" +thmopt=${promptIn,,} + +if [ "${thmopt}" = "y" ] ; then + echo -e "\033[0;32m[THEMEPATCHER]\033[0m Patching themes..." + while read -r themeName themeRepo themeCode + do + themeName="${themeName//\"/}" + themeRepo="${themeRepo//\"/}" + themeCode="${themeCode//\"/}" + ./themepatcher.sh "${themeName}" "${themeRepo}" "${themeCode}" + done < themepatcher.lst +else + echo -e "\033[0;33m[SKIP]\033[0m additional themes not patched..." +fi + + +# sddm +if pkg_installed sddm + then + + echo -e "\033[0;32m[DISPLAYMANAGER]\033[0m detected // sddm" + if [ ! -d /etc/sddm.conf.d ] ; then + sudo mkdir -p /etc/sddm.conf.d + fi + + if [ ! -f /etc/sddm.conf.d/kde_settings.t2.bkp ] ; then + echo -e "\033[0;32m[DISPLAYMANAGER]\033[0m configuring sddm..." + echo -e "Select sddm theme:\n1) Candy\n2) Corners" + read -p "Enter option number : " sddmopt + + case $sddmopt in + 1) sddmtheme="Candy";; + *) sddmtheme="Corners";; + esac + + sudo tar -xzf ${CloneDir}/Source/arcs/Sddm_${sddmtheme}.tar.gz -C /usr/share/sddm/themes/ + sudo touch /etc/sddm.conf.d/kde_settings.conf + sudo cp /etc/sddm.conf.d/kde_settings.conf /etc/sddm.conf.d/kde_settings.t2.bkp + sudo cp /usr/share/sddm/themes/${sddmtheme}/kde_settings.conf /etc/sddm.conf.d/ + else + echo -e "\033[0;33m[SKIP]\033[0m sddm is already configured..." + fi + + if [ ! -f /usr/share/sddm/faces/${USER}.face.icon ] && [ -f ${CloneDir}/Source/misc/${USER}.face.icon ] ; then + sudo cp ${CloneDir}/Source/misc/${USER}.face.icon /usr/share/sddm/faces/ + echo -e "\033[0;32m[DISPLAYMANAGER]\033[0m avatar set for ${USER}..." + fi + +else + echo -e "\033[0;33m[WARNING]\033[0m sddm is not installed..." +fi + + +# dolphin +if pkg_installed dolphin && pkg_installed xdg-utils + then + + echo -e "\033[0;32m[FILEMANAGER]\033[0m detected // dolphin" + xdg-mime default org.kde.dolphin.desktop inode/directory + echo -e "\033[0;32m[FILEMANAGER]\033[0m setting" `xdg-mime query default "inode/directory"` "as default file explorer..." + kmenuPath="$HOME/.local/share/kio/servicemenus" + mkdir -p "${kmenuPath}" + echo -e "[Desktop Entry]\nType=Service\nMimeType=image/png;image/jpeg;image/jpg;image/gif\nActions=Menu-Refresh\nX-KDE-Submenu=Set As Wallpaper..." > "${kmenuPath}/hydewallpaper.desktop" + echo -e "\n[Desktop Action Menu-Refresh]\nName=.: Refresh List :.\nExec=${HyprdotsDir}/scripts/swwwallkon.sh" >> "${kmenuPath}/hydewallpaper.desktop" + chmod +x "${kmenuPath}/hydewallpaper.desktop" + +else + echo -e "\033[0;33m[WARNING]\033[0m dolphin is not installed..." +fi + + +# shell +./restore_shl.sh ${getShell} + + +# flatpak +if ! pkg_installed flatpak + then + + echo -e "\033[0;32m[FLATPAK]\033[0m flatpak application list..." + awk -F '#' '$1 != "" {print "["++count"]", $1}' .extra/custom_flat.lst + prompt_timer 10 "Install these flatpaks? [Y/n]" + fpkopt=${promptIn,,} + + if [ "${fpkopt}" = "y" ] ; then + echo -e "\033[0;32m[FLATPAK]\033[0m intalling flatpaks..." + .extra/install_fpk.sh + else + echo -e "\033[0;33m[SKIP]\033[0m intalling flatpaks..." + fi + +else + echo -e "\033[0;33m[SKIP]\033[0m flatpak is already installed..." +fi + diff --git a/Scripts/restore_cfg.lst b/Scripts/restore_cfg.lst new file mode 100644 index 00000000..67b939e9 --- /dev/null +++ b/Scripts/restore_cfg.lst @@ -0,0 +1,26 @@ +N|Y|${HOME}|.zshrc .p10k.zsh|zsh oh-my-zsh-git zsh-theme-powerlevel10k pokemon-colorscripts-git +Y|Y|${HOME}/.config/Code/User|settings.json|visual-studio-code-bin +Y|Y|${HOME}/.config|dunst|dunst +Y|Y|${HOME}/.config|fish|fish +Y|Y|${HOME}/.config/hypr|animations.conf hyprland.conf windowrules.conf themes|hyprland +N|Y|${HOME}/.config/hypr|keybindings.conf monitors.conf userprefs.conf|hyprland +N|Y|${HOME}/.config/hypr|nvidia.conf|hyprland nvidia-utils +Y|Y|${HOME}/.config/hyprdots|theme.ctl scripts wallbash|hyprland +Y|Y|${HOME}/.config|kitty|kitty +Y|Y|${HOME}/.config|Kvantum|kvantum +Y|Y|${HOME}/.config|lsd|lsd +Y|Y|${HOME}/.config|MangoHud|mangohud +Y|Y|${HOME}/.config|neofetch|neofetch +Y|Y|${HOME}/.config|qt5ct|qt5ct +Y|Y|${HOME}/.config|qt6ct|qt6ct +Y|Y|${HOME}/.config|rofi|rofi +Y|Y|${HOME}/.config|swaylock|swaylock-effects +Y|N|${HOME}/.config|swww|swww +Y|Y|${HOME}/.config|waybar|waybar +Y|Y|${HOME}/.config|wlogout|wlogout +Y|Y|${HOME}/.config|xsettingsd nwg-look gtk-3.0|nwg-look +Y|Y|${HOME}/.icons|default|nwg-look +Y|Y|${HOME}|.gtkrc-2.0|nwg-look +Y|Y|${HOME}/.config|dolphinrc kdeglobals|dolphin +Y|Y|${HOME}/.local/share|dolphin|dolphin +Y|Y|${HOME}/.local/share/kxmlgui5|dolphin|dolphin diff --git a/Scripts/restore_cfg.sh b/Scripts/restore_cfg.sh new file mode 100644 index 00000000..0c9c6e0b --- /dev/null +++ b/Scripts/restore_cfg.sh @@ -0,0 +1,88 @@ +#!/bin/bash +#|---/ /+------------------------------------+---/ /|# +#|--/ /-| Script to restore personal configs |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+------------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + +ThemeOverride="${1:-}" #override default config list with custom theme list [param 1] +CfgDir="${2:-${CloneDir}/Configs}" #override default config path with custom theme path [param 2] + +if [ ! -f "${ThemeOverride}restore_cfg.lst" ] || [ ! -d "${CfgDir}" ] ; then + echo "ERROR : '${ThemeOverride}restore_cfg.lst' or '${CfgDir}' does not exist..." + exit 1 +fi + +BkpDir="${HOME}/.config/cfg_backups/$(date +'%y%m%d_%Hh%Mm%Ss')" + +if [ -d "${BkpDir}" ] ; then + echo "ERROR : ${BkpDir} exists!" + exit 1 +else + mkdir -p "${BkpDir}" +fi + +cat "${ThemeOverride}restore_cfg.lst" | while read lst +do + + ovrWrte=`echo "${lst}" | awk -F '|' '{print $1}'` + bkpFlag=`echo "${lst}" | awk -F '|' '{print $2}'` + pth=`echo "${lst}" | awk -F '|' '{print $3}'` + pth=`eval echo "${pth}"` + cfg=`echo "${lst}" | awk -F '|' '{print $4}'` + pkg=`echo "${lst}" | awk -F '|' '{print $5}'` + + while read -r pkg_chk + do + if ! pkg_installed ${pkg_chk} + then + echo "skipping ${pth}/${cfg} as dependency ${pkg_chk} is not installed..." + continue 2 + fi + done < <( echo "${pkg}" | xargs -n 1 ) + + echo "${cfg}" | xargs -n 1 | while read -r cfg_chk + do + if [[ -z "${pth}" ]]; then continue; fi + tgt=`echo "${pth}" | sed "s+^${HOME}++g"` + + if ( [ -d "${pth}/${cfg_chk}" ] || [ -f "${pth}/${cfg_chk}" ] ) && [ "${bkpFlag}" == "Y" ] + then + + if [ ! -d "${BkpDir}${tgt}" ] ; then + mkdir -p "${BkpDir}${tgt}" + fi + + [ "${ovrWrte}" == "Y" ] && mv "${pth}/${cfg_chk}" "${BkpDir}${tgt}" || cp -r "${pth}/${cfg_chk}" "${BkpDir}${tgt}" + echo "config backed up ${pth}/${cfg_chk} --> ${BkpDir}${tgt}..." + fi + + if [ ! -d "${pth}" ] ; then + mkdir -p "${pth}" + fi + + if [ ! -f "${pth}/${cfg_chk}" ] ; then + cp -r "${CfgDir}${tgt}/${cfg_chk}" "${pth}" + echo "config restored ${pth} <-- ${CfgDir}${tgt}/${cfg_chk}..." + elif [ "${ovrWrte}" == "Y" ] ; then + cp -r "${CfgDir}$tgt/${cfg_chk}" "${pth}" + echo "warning: config overwritten without backup ${pth} <-- ${CfgDir}${tgt}/${cfg_chk}..." + else + echo "Skipping ${pth}/${cfg_chk} to preserve user setting..." + fi + done + +done + +if nvidia_detect && [ $(grep '^source = ~/.config/hypr/nvidia.conf' ${HOME}/.config/hypr/hyprland.conf | wc -l) -eq 0 ] ; then + echo -e 'source = ~/.config/hypr/nvidia.conf # auto sourced vars for nvidia\n' >> ${HOME}/.config/hypr/hyprland.conf +fi + +./create_cache.sh "${ThemeOverride}" +[ -z "${ThemeOverride}" ] && ./restore_lnk.sh + diff --git a/Scripts/restore_fnt.lst b/Scripts/restore_fnt.lst new file mode 100644 index 00000000..0372db69 --- /dev/null +++ b/Scripts/restore_fnt.lst @@ -0,0 +1,48 @@ +Font_CascadiaCove|$HOME/.local/share/fonts +Font_MaterialDesign|$HOME/.local/share/fonts +Font_JetBrainsMono|$HOME/.local/share/fonts +Font_MapleNerd|$HOME/.local/share/fonts +Font_MononokiNerd|$HOME/.local/share/fonts +Font_NotoSansCJK|/usr/share/fonts +Gtk_CatppuccinMocha|/usr/share/themes +Gtk_CatppuccinMocha|$HOME/.themes +Gtk_CatppuccinLatte|/usr/share/themes +Gtk_CatppuccinLatte|$HOME/.themes +Gtk_DecayGreen|/usr/share/themes +Gtk_DecayGreen|$HOME/.themes +Gtk_FrostedGlass|/usr/share/themes +Gtk_FrostedGlass|$HOME/.themes +Gtk_GruvboxRetro|/usr/share/themes +Gtk_GruvboxRetro|$HOME/.themes +Gtk_RosePine|/usr/share/themes +Gtk_RosePine|$HOME/.themes +Gtk_TokyoNight|/usr/share/themes +Gtk_TokyoNight|$HOME/.themes +Gtk_MaterialSakura|/usr/share/themes +Gtk_MaterialSakura|$HOME/.themes +Gtk_GraphiteMono|/usr/share/themes +Gtk_GraphiteMono|$HOME/.themes +Gtk_CyberpunkEdge|/usr/share/themes +Gtk_CyberpunkEdge|$HOME/.themes +Icon_TelaBlack|/usr/share/icons +Icon_TelaBlack|$HOME/.icons +Icon_TelaDracula|/usr/share/icons +Icon_TelaDracula|$HOME/.icons +Icon_TelaGreen|/usr/share/icons +Icon_TelaGreen|$HOME/.icons +Icon_TelaGrey|/usr/share/icons +Icon_TelaGrey|$HOME/.icons +Icon_TelaPink|/usr/share/icons +Icon_TelaPink|$HOME/.icons +Icon_TelaPurple|/usr/share/icons +Icon_TelaPurple|$HOME/.icons +Icon_TelaYellow|/usr/share/icons +Icon_TelaYellow|$HOME/.icons +Icon_TelaBlue|/usr/share/icons +Icon_TelaBlue|$HOME/.icons +Icon_Gruvbox|/usr/share/icons +Icon_Gruvbox|$HOME/.icons +Cursor_Gruvbox|/usr/share/icons +Cursor_Gruvbox|$HOME/.icons +Cursor_BibataIce|/usr/share/icons +Cursor_BibataIce|$HOME/.icons diff --git a/Scripts/restore_fnt.sh b/Scripts/restore_fnt.sh new file mode 100644 index 00000000..1c6dd996 --- /dev/null +++ b/Scripts/restore_fnt.sh @@ -0,0 +1,33 @@ +#!/bin/bash +#|---/ /+----------------------------------+---/ /|# +#|--/ /-| Script to extract fonts & themes |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+----------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + +cat restore_fnt.lst | while read lst +do + + fnt=`echo $lst | awk -F '|' '{print $1}'` + tgt=`echo $lst | awk -F '|' '{print $2}'` + tgt=`eval "echo $tgt"` + + if [ ! -d "${tgt}" ] + then + mkdir -p ${tgt} || echo "creating the directory as root instead..." && sudo mkdir -p ${tgt} + echo "${tgt} directory created..." + fi + + sudo tar -xzf ${CloneDir}/Source/arcs/${fnt}.tar.gz -C ${tgt}/ + echo "uncompressing ${fnt}.tar.gz --> ${tgt}..." + +done + +echo "rebuilding font cache..." +fc-cache -f + diff --git a/Scripts/restore_lnk.sh b/Scripts/restore_lnk.sh new file mode 100644 index 00000000..afaa970c --- /dev/null +++ b/Scripts/restore_lnk.sh @@ -0,0 +1,31 @@ +#!/bin/bash +#|---/ /+---------------------------------+---/ /|# +#|--/ /-| Script to fix slinks in .config |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+---------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + +find $CloneDir -type l | while read slink +do + fixd_slink=$(readlink $slink | cut -d '/' -f 4-) + linkd_file=$(echo $slink | awk -F "${CloneDir}/Configs/" '{print $NF}') + echo "linking $HOME/$linkd_file --> $HOME/$fixd_slink..." + ln -fs $HOME/$fixd_slink $HOME/$linkd_file +done + +if [ -f $HOME/.config/hyprdots/scripts/globalcontrol.sh ] ; then + sed -i "/^CloneDir=/c\CloneDir=\"$CloneDir\"" $HOME/.config/hyprdots/scripts/globalcontrol.sh + echo "Clone directory globalcontrol updated..." +fi + +if printenv HYPRLAND_INSTANCE_SIGNATURE &> /dev/null + then + echo "reloading hyprland..." + hyprctl reload +fi + diff --git a/Scripts/restore_shl.sh b/Scripts/restore_shl.sh new file mode 100644 index 00000000..4a3e6e35 --- /dev/null +++ b/Scripts/restore_shl.sh @@ -0,0 +1,62 @@ +#!/bin/bash +#|---/ /+---------------------------+---/ /|# +#|--/ /-| Script to configure shell |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+---------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + +myShell="${1}" + +if [ -z "${myShell}" ] ; then + if pkg_installed zsh ; then + myShell="zsh" + elif pkg_installed fish ; then + myShell="fish" + else + echo -e "\033[0;33m[WARNING]\033[0m no shell detected..." + exit 0 + fi +fi + +echo -e "\033[0;32m[SHELL]\033[0m detected // ${myShell}" + +# add zsh plugins +if pkg_installed zsh && pkg_installed oh-my-zsh-git ; then + + # set variables + Zsh_rc="${ZDOTDIR:-$HOME}/.zshrc" + Zsh_Path="/usr/share/oh-my-zsh" + Zsh_Plugins="$Zsh_Path/custom/plugins" + Fix_Completion="" + + # generate plugins from list + while read r_plugin + do + z_plugin=$(echo $r_plugin | awk -F '/' '{print $NF}') + if [ "${r_plugin:0:4}" == "http" ] && [ ! -d $Zsh_Plugins/$z_plugin ] ; then + sudo git clone $r_plugin $Zsh_Plugins/$z_plugin + fi + if [ "$z_plugin" == "zsh-completions" ] && [ `grep 'fpath+=.*plugins/zsh-completions/src' $Zsh_rc | wc -l` -eq 0 ]; then + Fix_Completion='\nfpath+=${ZSH_CUSTOM:-${ZSH:-/usr/share/oh-my-zsh}/custom}/plugins/zsh-completions/src' + else + w_plugin=$(echo ${w_plugin} ${z_plugin}) + fi + done < <(cut -d '#' -f 1 restore_zsh.lst | sed 's/ //g') + + # update plugin array in zshrc + echo "intalling zsh plugins (${w_plugin})" + sed -i "/^plugins=/c\plugins=($w_plugin)$Fix_Completion" $Zsh_rc +fi + +# set shell +if [[ "$(grep "/${USER}:" /etc/passwd | awk -F '/' '{print $NF}')" != "${myShell}" ]] ; then + echo -e "\033[0;32m[SHELL]\033[0m changing shell to ${myShell}..." + chsh -s "$(which ${myShell})" +else + echo -e "\033[0;33m[SKIP]\033[0m ${myShell} is already configured..." +fi diff --git a/Scripts/restore_zsh.lst b/Scripts/restore_zsh.lst new file mode 100644 index 00000000..d564320a --- /dev/null +++ b/Scripts/restore_zsh.lst @@ -0,0 +1,8 @@ +git # alias and functions for git commands +sudo # press ESC key twice to execute command with sudo prefix +#python # alias for python +#zsh-interactive-cd # press tab to change dir with fzf +https://github.com/chrissicool/zsh-256color # enhance terminal environment with 256 colors +#https://github.com/zsh-users/zsh-completions # press tab to complete command +https://github.com/zsh-users/zsh-autosuggestions # suggests commands as you type based on history +https://github.com/zsh-users/zsh-syntax-highlighting # highlights commands as you type diff --git a/Scripts/system_ctl.lst b/Scripts/system_ctl.lst new file mode 100644 index 00000000..3e3671ac --- /dev/null +++ b/Scripts/system_ctl.lst @@ -0,0 +1,3 @@ +NetworkManager +bluetooth +sddm diff --git a/Scripts/themepatcher.lst b/Scripts/themepatcher.lst new file mode 100644 index 00000000..472e18b4 --- /dev/null +++ b/Scripts/themepatcher.lst @@ -0,0 +1,3 @@ +"One-Dark" "https://github.com/RAprogramm/hyprdots-theme/tree/One-Dark" "mskelton.one-dark-theme~One Dark" +"Synth-Wave" "https://github.com/prasanthrangan/hyprdots-mod/tree/Synth-Wave" "robbowen.synthwave-vscode~SynthWave '84" +"Nordic-Blue" "https://github.com/prasanthrangan/hyprdots-mod/tree/Nordic-Blue" "arcticicestudio.nord-visual-studio-code~Nord" diff --git a/Scripts/themepatcher.sh b/Scripts/themepatcher.sh new file mode 100644 index 00000000..959d2a20 --- /dev/null +++ b/Scripts/themepatcher.sh @@ -0,0 +1,157 @@ +#!/bin/bash +#|---/ /+------------------------------+---/ /|# +#|--/ /-| Script to patch custom theme |--/ /-|# +#|-/ /--| kRHYME7 |-/ /--|# +#|/ /---+------------------------------+/ /---|# + +source global_fn.sh +if [ $? -ne 0 ] ; then + echo "Error: unable to source global_fn.sh, please execute from $(dirname "$(realpath "$0")")..." + exit 1 +fi + +set +e + + +# error function +ask_help(){ +cat << HELP +...Usage... +$0 "Theme-Name" "/Path/to/Configs" +$0 "Theme-Name" "https://github.com/User/Repository" +$0 "Theme-Name" "https://github.com/User/Repository/tree/branch" +HELP +} + +if [[ -z $1 || -z $2 ]]; then ask_help ; exit 1 ; fi + + +# set parameters +Fav_Theme="$1" + +if [ -d "$2" ]; then + Theme_Dir="$2" + +else Git_Repo=${2%/} + if echo "$Git_Repo" | grep -q "/tree/"; then + branch=${Git_Repo#*tree/} Git_Repo=${Git_Repo%/tree/*} + else branches=$(curl -s "https://api.github.com/repos/${Git_Repo#*://*/}/branches" | jq -r '.[].name') ; branches=($branches) + if [[ ${#branches[@]} -le 1 ]]; then + branch=${branches[0]} + else echo "Select a Branch" + select branch in "${branches[@]}"; do [[ -n $branch ]] && break || echo "Invalid selection. Please try again." ; done + fi + fi + + Git_Path=${Git_Repo#*://*/} Git_Owner=${Git_Path%/*} branch_dir=${branch//\//_} + Theme_Dir="$HOME/Clone/HyprdotsPatch-$branch_dir" + + if [ -d "$Theme_Dir" ]; then + echo "Directory $Theme_Dir already exists. Using existing directory." + if cd "$Theme_Dir"; then + git stash 2> /dev/null ; git pull ; git stash pop 2> /dev/null ; cd - + else + echo -e "\033[0;31mCould not navigate to $Theme_Dir. Skipping git pull.\033[0m" + fi + else + echo "Directory $Theme_Dir does not exist. Cloning repository into new directory." + git clone -b "$branch" --depth 1 "$Git_Repo" "$Theme_Dir" + if [ $? -ne 0 ]; then echo "Git clone failed" ; exit 1 ; fi + fi +fi + +echo -e "\nPatching \033[0;32m--//${Fav_Theme}//--\033[0m from \033[0;34m${Theme_Dir}\033[0m\n" + + +# required theme files +config=( #!Hard Coded here to atleast Strictly meet requirements. + ".config/hypr/themes/$Fav_Theme.conf" + ".config/kitty/themes/$Fav_Theme.conf" + ".config/Kvantum/$Fav_Theme/$Fav_Theme.kvconfig" + ".config/Kvantum/$Fav_Theme/$Fav_Theme.svg" + ".config/qt5ct/colors/$Fav_Theme.conf" + ".config/qt6ct/colors/$Fav_Theme.conf" + ".config/rofi/themes/$Fav_Theme.rasi" + ".config/swww/$Fav_Theme/" + ".config/waybar/themes/$Fav_Theme.css" +) + + +# Loop through the config and check if these exist +for fchk in "${config[@]}"; do + if [[ -e "${Theme_Dir}/Configs/${fchk}" ]]; then + echo -e "\033[0;32m[OK]\033[0m ${fchk}" + else + echo -e "\033[0;31m[ERROR]\033[0m ${fchk} --> does not exist in ${Theme_Dir}/Configs/" + exit 1 + fi +done + +mapfile -d '' Wallist < <(find ${Theme_Dir}/Configs/.config/swww/"${Fav_Theme}"/ -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) -print0 | sort -z) + +if [ "${#Wallist[@]}" -eq 0 ] ; then + echo -e "\033[0;31m[ERROR]\033[0m No wallpaper found in ${Theme_Dir}/Configs/.config/swww/" + exit 1 +else + WallSet=$(basename "${Wallist[0]}") + echo -e "\nDefault wallpaper selected : \"${WallSet}\"\n" +fi + + +# extract arcs +prefix=("Gtk" "Font" "Icon" "Cursor") +declare -A TrgtDir +TrgtDir["Gtk"]="$HOME/.themes" #mandatory +TrgtDir["Font"]="${XDG_DATA_HOME:-$HOME/.local/share}/fonts" #optional +TrgtDir["Icon"]="$HOME/.icons" #optional +TrgtDir["Cursor"]="$HOME/.icons" #optional +postfx=("tar.xz" "tar.gz") +GtkFlag=0 + + +# Loop over the themes and extensions +for pre in "${prefix[@]}"; do + for ext in "${postfx[@]}"; do + if [ -f "${Theme_Dir}/Source/arcs/${pre}_${Fav_Theme}.${ext}" ] ; then + echo -e "\033[0;32m[Extacting]\033[0m ${Theme_Dir}/Source/arcs/${pre}_${Fav_Theme}.${ext} --> ${TrgtDir[$pre]}" + tar -xf "${Theme_Dir}/Source/arcs/${pre}_${Fav_Theme}.${ext}" -C "${TrgtDir[$pre]}" + if [ ${pre} == "Gtk" ] ; then + GtkFlag=1 + fi + fi + done +done + +if [ ${GtkFlag} -eq 0 ] ; then + echo -e "\033[0;31m[ERROR]\033[0m Gtk pack not found --> ${Theme_Dir}/Source/arcs/${pre}_${Fav_Theme}.${ext}" + exit 1 +fi + +fc-cache -f + + +# generate restore_cfg control +cat << THEME > "${Fav_Theme}restore_cfg.lst" +Y|Y|${HOME}/.config/hypr/themes|${Fav_Theme}.conf|hyprland +Y|Y|${HOME}/.config/kitty/themes|${Fav_Theme}.conf|kitty +Y|Y|${HOME}/.config/Kvantum|${Fav_Theme}|kvantum +Y|Y|${HOME}/.config/qt5ct/colors|${Fav_Theme}.conf|qt5ct +Y|Y|${HOME}/.config/qt6ct/colors|${Fav_Theme}.conf|qt6ct +Y|Y|${HOME}/.config/rofi/themes|${Fav_Theme}.rasi|rofi +Y|N|${HOME}/.config/swww|${Fav_Theme}|swww +Y|Y|${HOME}/.config/waybar/themes|${Fav_Theme}.css|waybar +THEME + +if grep -q "^.|${Fav_Theme}|" "${ThemeCtl}" ; then + awk -F '|' -v thm="${Fav_Theme}" -v cde="$3" '{OFS=FS} $2 == thm {$3 = cde} {print}' "${ThemeCtl}" > tmp && mv tmp "${ThemeCtl}" +else + echo "0|${Fav_Theme}|${3}|~/.config/swww/${Fav_Theme}/${WallSet}" >> "${ThemeCtl}" +fi + + +# restore configs with theme override +echo -e "\033[0;32m[Restoring]\033[0m restore_cfg.sh \"${Fav_Theme}\" \"${Theme_Dir}/Configs\"\n" +./restore_cfg.sh "$Fav_Theme" "$Theme_Dir/Configs" + +rm "${Fav_Theme}restore_cfg.lst" + diff --git a/Scripts/wallbash.sh b/Scripts/wallbash.sh new file mode 100644 index 00000000..42494e57 --- /dev/null +++ b/Scripts/wallbash.sh @@ -0,0 +1,187 @@ +#!/bin/bash +#|---/ /+---------------------------------------------+---/ /|# +#|--/ /-| Script to generate color palette from image |--/ /-|# +#|-/ /--| Prasanth Rangan |-/ /--|# +#|/ /---+---------------------------------------------+/ /---|# + + +#// accent color profile + +colorProfile="default" +wallbashCurve="32 50\n42 46\n49 40\n56 39\n64 38\n76 37\n90 33\n94 29\n100 20" + +while [ $# -gt 0 ] ; do + case "$1" in + -v|--vibrant) colorProfile="vibrant" + wallbashCurve="18 99\n32 97\n48 95\n55 90\n70 80\n80 70\n88 60\n94 40\n99 24" + ;; + -p|--pastel) colorProfile="pastel" + wallbashCurve="10 99\n17 66\n24 49\n39 41\n51 37\n58 34\n72 30\n84 26\n99 22" + ;; + -m|--mono) colorProfile="mono" + wallbashCurve="10 0\n17 0\n24 0\n39 0\n51 0\n58 0\n72 0\n84 0\n99 0" + ;; + *) break + ;; + esac + shift +done + + +#// set variables + +cacheDir="$HOME/.cache/hyprdots" +wallbashImg="${1}" +wallbashColors=4 +wallbashFuzz=70 +cacheImg=$(basename "${wallbashImg}") +cacheThm=$(dirname "${wallbashImg}" | awk -F '/' '{print $NF}') +wallbashRaw="${cacheDir}/${cacheThm}/${cacheImg}.mpc" +wallbashOut="${cacheDir}/${cacheThm}/${cacheImg}.dcol" +wallbashCache="${cacheDir}/${cacheThm}/${cacheImg}.cache" + + +#// color modulations + +pryDarkBri=116 +pryDarkSat=110 +pryDarkHue=88 +pryLightBri=100 +pryLightSat=100 +pryLightHue=114 +txtDarkBri=188 +txtLightBri=16 + + +#// input image validation + +if [ -z "${wallbashImg}" ] || [ ! -f "${wallbashImg}" ] ; then + echo "Error: Input file not found!" + exit 1 +fi + +magick -ping "${wallbashImg}" -format "%t" info: &> /dev/null +if [ $? -ne 0 ] ; then + echo "Error: Unsuppoted image format ${wallbashImg}" + exit 1 +fi + +echo "wallbash ${colorProfile} profile :: Colors ${wallbashColors} :: Fuzzy ${wallbashFuzz} :: \"${wallbashOut}\"" +mkdir -p "${cacheDir}/${cacheThm}" +> "${wallbashOut}" + + +#// define functions + +rgb_negative() { + local inCol=$1 + local r=${inCol:0:2} + local g=${inCol:2:2} + local b=${inCol:4:2} + local r16=$((16#$r)) + local g16=$((16#$g)) + local b16=$((16#$b)) + r=$(printf "%02X" $((255 - $r16))) + g=$(printf "%02X" $((255 - $g16))) + b=$(printf "%02X" $((255 - $b16))) + echo "${r}${g}${b}" +} + +fx_brightness() { + local inCol="${1}" + local fxb=$(magick "${inCol}" -colorspace gray -format "%[fx:mean]" info:) + if awk -v fxb="${fxb}" 'BEGIN {exit !(fxb < 0.5)}' ; then + return 0 #// echo ":: ${fxb} :: dark :: ${inCol}" + else + return 1 #// echo ":: ${fxb} :: light :: ${inCol}" + fi +} + + +#// quantize raw primary colors + +magick -quiet -regard-warnings "${wallbashImg}"[0] -alpha off +repage "${wallbashRaw}" +readarray -t dcolRaw <<< $(magick "${wallbashRaw}" -depth 8 -fuzz ${wallbashFuzz}% +dither -kmeans ${wallbashColors} -depth 8 -format "%c" histogram:info: | sed -n 's/^[ ]*\(.*\):.*[#]\([0-9a-fA-F]*\) .*$/\1,#\2/p' | sort -r -n -k 1 -t "," | awk -F '#' 'length($NF) == 6 {print $NF}') + +if [ ${#dcolRaw[*]} -lt ${wallbashColors} ] ; then + echo -e "RETRYING :: distinct colors ${#dcolRaw[*]} is less than ${wallbashColors} palette color..." + readarray -t dcolRaw <<< $(magick "${wallbashRaw}" -depth 8 -fuzz ${wallbashFuzz}% +dither -colors $((wallbashColors + 2)) -depth 8 -format "%c" histogram:info: | sed -n 's/^[ ]*\(.*\):.*[#]\([0-9a-fA-F]*\) .*$/\1,#\2/p' | sort -r -n -k 1 -t "," | awk -F '#' 'length($NF) == 6 {print $NF}') +fi + + +#// sort colors based on image brightness + +if fx_brightness "${wallbashRaw}" ; then + colSort="" +else + colSort="-r" +fi + +dcol=($(echo -e "${dcolRaw[@]:0:$wallbashColors}" | tr ' ' '\n' | sort ${colSort})) +greyCheck=$(convert "${wallbashRaw}" -colorspace HSL -channel g -separate +channel -format "%[fx:mean]" info:) + +if (( $(awk 'BEGIN {print ('"$greyCheck"' < 0.12)}') )); then + wallbashCurve="10 0\n17 0\n24 0\n39 0\n51 0\n58 0\n72 0\n84 0\n99 0" +fi + + +#// loop for derived colors + +for (( i=0; i<${wallbashColors}; i++ )) ; do + + + #// generate missing primary colors + + if [ -z "${dcol[i]}" ] ; then + + if fx_brightness "xc:#${dcol[i - 1]}" ; then + modBri=$pryDarkBri + modSat=$pryDarkSat + modHue=$pryDarkHue + else + modBri=$pryLightBri + modSat=$pryLightSat + modHue=$pryLightHue + fi + + echo -e "dcol_pry$((i + 1)) :: regen missing color" + dcol[i]=$(magick xc:"#${dcol[i - 1]}" -depth 8 -normalize -modulate ${modBri},${modSat},${modHue} -depth 8 -format "%c" histogram:info: | sed -n 's/^[ ]*\(.*\):.*[#]\([0-9a-fA-F]*\) .*$/\1,#\2/p' | sort -r -n -k 1 -t "," | awk -F '#' 'length($NF) == 6 {print $NF}') + + fi + + echo "dcol_pry$((i + 1))=\"${dcol[i]}\"" >> "${wallbashOut}" + + + #// generate primary text colors + + nTxt=$(rgb_negative ${dcol[i]}) + + if fx_brightness "xc:#${dcol[i]}" ; then + modBri=$txtDarkBri + else + modBri=$txtLightBri + fi + + tcol=$(magick xc:"#${nTxt}" -depth 8 -normalize -modulate ${modBri},10,100 -depth 8 -format "%c" histogram:info: | sed -n 's/^[ ]*\(.*\):.*[#]\([0-9a-fA-F]*\) .*$/\1,#\2/p' | sort -r -n -k 1 -t "," | awk -F '#' 'length($NF) == 6 {print $NF}') + echo "dcol_txt$((i + 1))=\"${tcol}\"" >> "${wallbashOut}" + + + #// generate accent colors + + xHue=$(magick xc:"#${dcol[i]}" -colorspace HSB -format "%c" histogram:info: | awk -F '[hsb(,]' '{print $2}') + acnt=1 + + echo -e "${wallbashCurve}" | sort -n ${colSort} | while read -r xBri xSat + do + acol=$(magick xc:"hsb(${xHue},${xSat}%,${xBri}%)" -depth 8 -format "%c" histogram:info: | sed -n 's/^[ ]*\(.*\):.*[#]\([0-9a-fA-F]*\) .*$/\1,#\2/p' | sort -r -n -k 1 -t "," | awk -F '#' 'length($NF) == 6 {print $NF}') + echo "dcol_$((i + 1))xa${acnt}=\"${acol}\"" >> "${wallbashOut}" + ((acnt++)) + done + +done + + +#// cleanup temp cache + +rm -f "${wallbashRaw}" "${wallbashCache}" +