From 16cc31b947975f5e9b00af3ad3875df83be21087 Mon Sep 17 00:00:00 2001 From: krolxon Date: Thu, 1 Jan 2026 13:45:31 +0530 Subject: install.sh: add logging --- .config/foot/foot.ini | 58 +++++++++++++++++++++--------------------- .config/zsh/.zshrc | 2 +- .local/bin/screenshot | 18 ++++++++++++++ .local/bin/snipping-tool | 18 -------------- install.sh | 65 ++++++++++++++++++++++++++++++++---------------- 5 files changed, 92 insertions(+), 69 deletions(-) create mode 100755 .local/bin/screenshot delete mode 100755 .local/bin/snipping-tool diff --git a/.config/foot/foot.ini b/.config/foot/foot.ini index 94b3edb..621461d 100644 --- a/.config/foot/foot.ini +++ b/.config/foot/foot.ini @@ -6,35 +6,35 @@ font=JetBrains Mono Nerd Font:size=12 [colors] alpha=0.85 -cursor=11111b f5e0dc -foreground=cdd6f4 -background=1e1e2e - -regular0=45475a -regular1=f38ba8 -regular2=a6e3a1 -regular3=f9e2af -regular4=89b4fa -regular5=f5c2e7 -regular6=94e2d5 -regular7=bac2de - -bright0=585b70 -bright1=f38ba8 -bright2=a6e3a1 -bright3=f9e2af -bright4=89b4fa -bright5=f5c2e7 -bright6=94e2d5 -bright7=a6adc8 -16=fab387 -17=f5e0dc -selection-foreground=cdd6f4 -selection-background=414356 -search-box-no-match=11111b f38ba8 -search-box-match=cdd6f4 313244 -jump-labels=11111b fab387 -urls=89b4fa +#cursor=11111b f5e0dc +#foreground=cdd6f4 +#background=1e1e2e +# +#regular0=45475a +#regular1=f38ba8 +#regular2=a6e3a1 +#regular3=f9e2af +#regular4=89b4fa +#regular5=f5c2e7 +#regular6=94e2d5 +#regular7=bac2de +# +#bright0=585b70 +#bright1=f38ba8 +#bright2=a6e3a1 +#bright3=f9e2af +#bright4=89b4fa +#bright5=f5c2e7 +#bright6=94e2d5 +#bright7=a6adc8 +#16=fab387 +#17=f5e0dc +#selection-foreground=cdd6f4 +#selection-background=414356 +#search-box-no-match=11111b f38ba8 +#search-box-match=cdd6f4 313244 +#jump-labels=11111b fab387 +#urls=89b4fa [key-bindings] search-start=Control+Shift+f diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 3cf59dc..a215de3 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -71,4 +71,4 @@ source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting. source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh # Load pywal colors -(cat ~/.cache/wal/sequences &) +# (cat ~/.cache/wal/sequences &) diff --git a/.local/bin/screenshot b/.local/bin/screenshot new file mode 100755 index 0000000..8048bfa --- /dev/null +++ b/.local/bin/screenshot @@ -0,0 +1,18 @@ +#!/bin/sh + +ocr_cmd="wl-copy" + +case "$(printf "a selected area (copy)\ncurrent window (copy)\nfull screen (copy)\na selected area\ncurrent window\nfull screen\na selected area (OCR)" | fuzzel -d -l 7 -i -p "Screenshot which area?")" in + "a selected area (copy)") hyprshot -m region --clipboard-only ;; + "current window (copy)") hyprshot -m window --clipboard-only ;; + "full screen (copy)") hyprshot -m output --clipboard-only ;; + + "a selected area") hyprshot -m region -o ~/pix/ss -f "pic-selected-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; + "current window") hyprshot -m window -o ~/pix/ss -f "pic-window-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; + "full screen") hyprshot -m output -o ~/pix/ss -f "pic-full-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; + + "a selected area (OCR)") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && \ + hyprshot -m region -o "$(dirname "$tmpfile")" -f "$(basename "$tmpfile")" && \ + tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;; +esac + diff --git a/.local/bin/snipping-tool b/.local/bin/snipping-tool deleted file mode 100755 index 8048bfa..0000000 --- a/.local/bin/snipping-tool +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -ocr_cmd="wl-copy" - -case "$(printf "a selected area (copy)\ncurrent window (copy)\nfull screen (copy)\na selected area\ncurrent window\nfull screen\na selected area (OCR)" | fuzzel -d -l 7 -i -p "Screenshot which area?")" in - "a selected area (copy)") hyprshot -m region --clipboard-only ;; - "current window (copy)") hyprshot -m window --clipboard-only ;; - "full screen (copy)") hyprshot -m output --clipboard-only ;; - - "a selected area") hyprshot -m region -o ~/pix/ss -f "pic-selected-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; - "current window") hyprshot -m window -o ~/pix/ss -f "pic-window-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; - "full screen") hyprshot -m output -o ~/pix/ss -f "pic-full-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; - - "a selected area (OCR)") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && \ - hyprshot -m region -o "$(dirname "$tmpfile")" -f "$(basename "$tmpfile")" && \ - tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;; -esac - diff --git a/install.sh b/install.sh index 16279eb..4b5c903 100755 --- a/install.sh +++ b/install.sh @@ -1,23 +1,42 @@ #!/bin/env bash +log() { + local level="$1" + shift + + case "$level" in + INFO) color='\033[0;32m' ;; + WARN) color='\033[0;33m' ;; + ERROR) color='\033[0;31m' ;; + *) color='\033[0m' ;; + esac + + printf '%b[%s] [%s]%b %s\n' \ + "$color" "$(date '+%H:%M:%S')" "$level" '\033[0m' "$*" +} + currentDir="$(dirname "$(readlink -f "$0")")" cd "$currentDir" ## Install necessary desktop packages source "$currentDir/packages/pkg_desktop.sh" source "$currentDir/packages/pkg_utils.sh" +log INFO "Starting Script" +log INFO "Installing necessary packages for hyprland" sudo pacman -Sy --needed "${pkg_desktop[@]}" "${pkg_utils[@]}" ## Install dev tools read -rp "Do you wish to install development tools? [y/N]" install_dev_tools -source "$currentDir/packages/pkg_dev_tools.sh" if [[ $install_dev_tools == y ]]; then + log INFO "Installing development tools" + source "$currentDir/packages/pkg_dev_tools.sh" sudo pacman -S --needed "${pkg_dev_tools[@]}" fi ## Install optional packages read -rp "Do you wish to install optional packages? [y/N]" install_optional_pkg if [[ $install_optional_pkg == y ]]; then + log INFO "Installing development tools" source "$currentDir/packages/pkg_optional.sh" sudo pacman -S --needed "${pkg_optional[@]}" fi @@ -25,6 +44,7 @@ fi ## Install nvidia drivers read -rp "Do you wish to install Nvidia drivers? [y/N]" install_nvidia_drivers if [[ $install_nvidia_drivers == y ]]; then + log INFO "Installing Nvidia Drivers" source "$currentDir/packages/pkg_nvidia.sh" sudo pacman -S --needed "${pkg_nvidia[@]}" fi @@ -35,14 +55,14 @@ read -rp "Do you wish to install aur packages? [y/N]" install_aur_pkg if [[ $install_aur_pkg == y ]]; then ## Install paru if it isn't already installed if ! command -v paru >/dev/null 2>&1; then - echo "Installing paru..." + log INFO "Installing Paru (AUR package manager)" git clone https://aur.archlinux.org/paru-bin.git cd paru-bin makepkg -sri cd .. rm -rf paru-bin else - echo "Skipping paru (already in PATH)" + log INFO "Skipping paru (already in PATH)" fi ## Install aur packages source "$currentDir/packages/pkg_aur.sh" @@ -51,20 +71,21 @@ fi ## Setup dotfiles -echo "⚠️ WARNING: This will DELETE any conflicting files and replace them with symlinks from this repo." -echo "Make sure you have already backed up all your existing config files (~/.config)" +log WARN "⚠️ This will DELETE any conflicting files and replace them with symlinks from this repo." +log WARN "Make sure you have already backed up all your existing config files (~/.config)" read -rp "Continue with stow (y/N): " confirm if [[ "$confirm" =~ ^[Yy]$ ]]; then - echo "Detecting conflicts..." + log INFO "Detecting conflicts..." conflicts=$(stow . --no-folding -nv 2>&1 | \ sed -n 's/.*existing target \(.*\) since neither.*/\1/p') if [[ -z "$conflicts" ]]; then - echo "No conflicts. Running stow normally..." - stow . --no-folding - echo "✅ Done." + log INFO "No conflicts. Running stow normally..." + stow . --no-folding \ + && log INFO "Dotfiles stowed successfully" \ + || log ERROR "Stow failed" else - echo "These paths conflict and will be removed:" + log WARN "These paths conflict and will be removed:" printf ' %s\n' $conflicts read -rp "Proceed with deleting these files? (y/N): " ok if [[ ! "$ok" =~ ^[Yy]$ ]]; then @@ -73,23 +94,23 @@ if [[ "$confirm" =~ ^[Yy]$ ]]; then # Remove conflicts relative to $HOME for path in $conflicts; do - echo "Removing $HOME/$path" - rm -rf "$HOME/$path" + rm -rf "$HOME/$path" && log INFO "Removed $HOME/$path" done - echo "Running stow..." - stow . --no-folding - echo "✅ Dotfiles stowed with overwrite." + log INFO "Running stow..." + stow . --no-folding \ + && log INFO "✅ Dotfiles stowed with overwrite." \ + || log ERROR "Stow failed" fi else - echo "Aborted stow" + log WARN "Aborted stow, the dotfiles are not synced" fi ## Setup neovim dotfiles read -rp "Clone neovim dotfiles as well? (y/N): " confirm if [[ "$confirm" =~ ^[Yy]$ ]]; then - echo "Taking backup of neovim config (if already exists)" + log INFO "Taking backup of neovim config (if already exists)" mv ~/.config/nvim{,.bak} mv ~/.local/share/nvim{,.bak} mv ~/.local/state/nvim{,.bak} @@ -98,17 +119,19 @@ if [[ "$confirm" =~ ^[Yy]$ ]]; then fi ## Change default shell to zsh +log INFO "Changing the default shell to ZSH" if [[ "$SHELL" != "$(which zsh)" ]]; then read -rp "Change default shell to ZSH? (y/N): " confirm if [[ "$confirm" =~ ^[Yy]$ ]]; then - echo "Changing default shell to zsh..." - chsh -s $(which zsh) + chsh -s $(which zsh) \ + && log INFO "Default shell successfully set to zsh" \ + || log ERROR "Default shell could not be set to zsh" fi else - echo "Skipping: zsh is already the default shell" + log INFO "Skipping: zsh is already the default shell" fi printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = echo "" -echo "Done! 😊" +log INFO "Done! 😊" -- cgit v1.2.3