Commit 3d8218f

Ansari <ping@ansari.wtf>
2025-12-19 17:57:32
Update keybinds and monitors configuration; add firewall setup script
1 parent 6fe6a97
Changed files (4)
.config/hypr/modules/keybinds.conf
@@ -13,18 +13,18 @@ bind = $mainMod CTRL,     s,swapwindow, d
 bind = $mainMod CTRL,     d,  swapwindow, r  
 bind = $mainMod,    TAB, hyprexpo:expo, toggle
 
-bind = $mainMod, S, togglespecialworkspace, scratchpad
-bind = $mainMod SHIFT, TAB, movetoworkspace, special:scratchpad
+bind = $mainMod, S, togglespecialworkspace, temp
+bind = $mainMod SHIFT, TAB, movetoworkspace, special:temp
 
 #CUSTOM SCRIPTS and Commands
 bind = $mainMod,    SPACE,  exec, $menu
-bind = CONTROLALT,  T,      exec, $terminal
+bind = $mainMod,    T,      exec, $terminal
 bind = $mainMod,    E,      exec, $fileManager
 bind = $mainMod,    L,      exec, hyprlock
-bind = $mainMod,    R,		  exec, killall -9 waybar && waybar
+bind = $mainMod,    R,		exec, killall -9 waybar && waybar
 bind = $mainMod,    V,      exec, $cliphistMenu
 bind = $mainMod,    period, exec, $emojiMenu
-bind = $mainMod SHIFT,S,    exec, $screenshotMenu
+bind = $mainMod     SHIFT,S,exec, $screenshotMenu
 
 # Switch workspaces with mainMod + [0-9]
 bind = $mainMod, 1, workspace, 1
.config/hypr/modules/monitors.conf
@@ -16,4 +16,5 @@ windowrule = rounding 8, match:tag pop
 # Apps Rules
 windowrule = workspace 1, match:class ^(zen)$
 windowrule = workspace 2, match:class ^(code|code-oss|Code-Insiders)$
-windowrule = workspace special:music, match:class ^(chrome-music\.youtube\..*)$
\ No newline at end of file
+windowrule = workspace special:music, match:class ^(chrome-music\.youtube\..*)$
+windowrule = workspace 3, match:class ^(chrome-gemini.google.com.*)$
\ No newline at end of file
.wraith/scripts/arch-spring-cleanup.sh
@@ -1,175 +1,206 @@
 #!/usr/bin/env zsh
 # ============================================================================
-# Arch Linux "Spring‑Clean" Maintenance Script
+# Arch Linux Maintenance TUI
 # ============================================================================
 
-set -euo pipefail
-trap 'echo "[!] Script aborted by user."; exit 1' INT TERM
+center_box() {
+  local content="$1"
+  local term_width box_width pad
+
+  term_width=$(tput cols)
+  
+  # Get the width of the content (rough estimate)
+  box_width=$(echo "$content" | wc -L)
+  
+  pad=$(( (term_width - box_width) / 2 ))
+  (( pad < 0 )) && pad=0
+
+  # Add left padding to each line of the box
+  echo "$content" | while IFS= read -r line; do
+    printf "%*s%s\n" "$pad" "" "$line"
+  done
+}
+
+cleanup() {
+  echo ""
+  tput cnorm 2>/dev/null || true
+  show_header
+  gum style --foreground "$MOCHA_RED" --bold "Operation cancelled by user."
+  sub_text "Press any key to exit..."
+  read -n 1
+  exit 130
+}
+
+gum_safe() {
+  local resultCode
+  gum "$@"
+  resultCode=$?
+
+  if (( resultCode == 130 )); then
+    cleanup
+  elif (( resultCode != 0 )); then
+    return $resultCode
+  fi
+}
+
 
-# -------------------------------------
-# 0: Detect AUR helper (paru or yay)
 # -------------------------------------
 
-if command -v paru &>/dev/null; then
-  AUR=paru
-elif command -v yay &>/dev/null; then
-  AUR=yay
-else
-  echo "Error: You need to install either 'paru' or 'yay' to use this script." >&2
-  exit 1
-fi
+export MOCHA_MAUVE="#cba6f7"
+export MOCHA_LAVENDER="#b4befe"
+export MOCHA_GREEN="#a6e3a1"
+export MOCHA_RED="#f38ba8"
+export MOCHA_TEXT="#cdd6f4"
+export MOCHA_OVERLAY="#6c7086"
+export MOCHA_BASE="#1e1e2e"
+
+# -- Gum Defaults --
+export GUM_SPIN_SPINNER="dot"
+export GUM_SPIN_SPINNER_FOREGROUND="$MOCHA_LAVENDER"
+export GUM_SPIN_TITLE_FOREGROUND="$MOCHA_TEXT"
+export GUM_CONFIRM_PROMPT_FOREGROUND="$MOCHA_MAUVE"
+export GUM_CONFIRM_SELECTED_BACKGROUND="$MOCHA_MAUVE"
+export GUM_CONFIRM_SELECTED_FOREGROUND="$MOCHA_BASE"
+export GUM_CONFIRM_UNSELECTED_FOREGROUND="$MOCHA_OVERLAY"
+export GUM_STYLE_BORDER="double"
+export GUM_STYLE_BORDER_FOREGROUND="$MOCHA_MAUVE"
+export GUM_STYLE_FOREGROUND="$MOCHA_TEXT"
 
 # -------------------------------------
-# 1: Set up logging and configuration
+# Dependency Checks
 # -------------------------------------
 
 LOG_DIR="$HOME/.local/var/log"
 mkdir -p "$LOG_DIR"
-LOG_FILE="$LOG_DIR/spring-clean-$(date +%F_%H-%M-%S).log"
-
-PACCACHE_RETAIN=2     # Keep only the latest 2 versions of packages
-CACHE_DAYS=30         # Delete ~/.cache files older than 30 days
-JOURNAL_RETAIN="7d"   # Keep only 7 days of system logs
-
-exec > >(tee -a "$LOG_FILE") 2>&1  # Everything goes to log file AND terminal
+LOG_FILE="$LOG_DIR/maintenance-$(date +%F_%H-%M-%S).log"
+
+CACHE_TARGETS=(
+  "$HOME/.cache/thumbnails"
+  "$HOME/.cache/yay"
+  "$HOME/.cache/paru"
+  "$HOME/.cache/pip"
+  "$HOME/.cache/npm"
+)
+
+AUR_HELPER="yay"
+
+if ! command -v gum &>/dev/null || ! command -v yay &>/dev/null || ! command -v paccache &>/dev/null; then
+  command -v gum &>/dev/null || { echo "❌ Error: 'gum' is not installed. Please install it to proceed."; exit 1; }
+  command -v yay &>/dev/null || { gum style --foreground "$MOCHA_RED" "❌ Error: No AUR helper (paru/yay) found."; exit 1; }
+  command -v paccache &>/dev/null || { gum style --foreground "$MOCHA_RED" "❌ Error: 'pacman-contrib' is missing." "Install it with: sudo pacman -S pacman-contrib"; exit 1; }
+fi
 
-# -------------------------------------
-# Helper functions
-# -------------------------------------
+show_header() {
+  clear
+  header=$(gum_safe style \
+    --align "center" \
+    --border "double" \
+    --margin "1" \
+    --padding "1 2" \
+    --border-foreground "$MOCHA_MAUVE" \
+    "☕ Arch Linux Spring-Clean"
+  )
+  center_box "$header"
+}
 
-confirm() {
-  read -r -p "${1:-Are you sure? [y/N]} " ans
-  [[ "$ans" =~ ^([yY][eE][sS]|[yY])$ ]]
+run_task() {
+  local label="$1"
+  local cmd="$2"
+  
+  if gum_safe spin --title "$label" -- sh -c "$cmd >> $LOG_FILE 2>&1"; then
+    gum_safe style --foreground "$MOCHA_GREEN" --border none "✓ $label completed"
+  else
+    gum_safe style --foreground "$MOCHA_RED" --border none "✗ $label failed! Check logs."
+  fi
 }
 
-announce() {
-  printf "\n\e[1;32m🔹 %s\e[0m\n" "$1"
+section_title() {
+  echo ""
+  gum_safe style --foreground "$MOCHA_MAUVE" --bold --border none "$1"
 }
 
-step() {
-  printf "\n\e[1;34m==> %s\e[0m\n" "$1"
+sub_text() {
+  gum_safe style --foreground "$MOCHA_OVERLAY" --border none "$1"
 }
 
 # -------------------------------------
-# Optional: Check for --upgrade flag
+#  Execution
 # -------------------------------------
 
-DO_UPGRADE=false
-while [[ $# -gt 0 ]]; do
-  case $1 in
-    -u|--upgrade) DO_UPGRADE=true; shift ;;
-    -h|--help)
-      echo "Usage: $0 [--upgrade]"
-      echo "       --upgrade   Also upgrade all system and AUR packages"
-      exit 0 ;;
-    *) echo "Unknown option: $1" ; exit 2 ;;
-  esac
-done
-
-announce "Arch Linux Spring‑Clean Starting — Using AUR Helper: $AUR"
-echo "Log file saved to: $LOG_FILE"
-
-# -------------------------------------
-# 2: Optional System Upgrade
-# -------------------------------------
+show_header
 
-if $DO_UPGRADE; then
-  step "UPGRADING SYSTEM PACKAGES"
-  echo "This will update all official and AUR packages."
-  if confirm "Continue with system upgrade? [y/N]"; then
-    $AUR -Syu --ask 4
-    echo "NOTE: After upgrade, run: sudo pacdiff — to handle .pacnew files."
-  else
-    echo "Skipped system upgrade."
-  fi
+# --- Step 1 ---
+section_title "1. System Upgrade"
+if gum_safe confirm "Upgrade system packages?"; then
+  sudo -v
+  $AUR_HELPER -Syu
+else
+  sub_text "Skipped upgrade."
 fi
 
-# -------------------------------------
-# 3: Clean Pacman Cache
-# -------------------------------------
-
-step "CLEANING PACKAGE CACHE"
-current_cache=$(du -sh /var/cache/pacman/pkg | cut -f1)
-echo "Current cache size: $current_cache"
+# --- Step 2 ---
+section_title "2. Pacman Cache"
+current_pkg_cache=$(du -sh /var/cache/pacman/pkg 2>/dev/null | cut -f1)
 
-if confirm "Clean old package cache (keep last $PACCACHE_RETAIN)? [y/N]"; then
-  sudo paccache -vrk $PACCACHE_RETAIN
-  sudo paccache -ruk0
-  new_cache=$(du -sh /var/cache/pacman/pkg | cut -f1)
-  echo "New cache size: $new_cache"
+if gum_safe confirm "Clean pacman cache? (Current: $current_pkg_cache)"; then
+  run_task "Pruning package cache" "sudo paccache -vrk 2 && sudo paccache -ruk0"
 else
-  echo "Skipped cache cleanup."
+  sub_text "Skipped package cache."
 fi
 
-# -------------------------------------
-# 4: Remove Orphaned Packages
-# -------------------------------------
+# --- Step 3 ---
+section_title "3. Orphaned Packages"
+ORPHANS=$($AUR_HELPER -Qtdq)
+
+if [[ -z "$ORPHANS" ]]; then
+  gum_safe style --foreground "$MOCHA_GREEN" --border none "✓ No orphaned packages found."
+else
+  gum_safe style --foreground "$MOCHA_PEACH" --border none "Found orphaned packages:"
+  echo "$ORPHANS" | gum_safe format
 
-step "REMOVING UNUSED (ORPHANED) PACKAGES"
-mapfile -t ORPHANS < <($AUR -Qtdq)
-if ((${#ORPHANS[@]})); then
-  echo "Found ${#ORPHANS[@]} orphaned packages:"
-  printf '%s\n' "${ORPHANS[@]}"
-  if confirm "Remove these unneeded packages? [y/N]"; then
-    sudo pacman -Rns "${ORPHANS[@]}"
+  if gum_safe confirm "Remove orphaned packages?"; then
+    run_task "Removing orphaned packages" "sudo $AUR_HELPER -Rns $ORPHANS"
   else
-    echo "Skipped removing orphans."
+    sub_text "Skipped orphan removal."
   fi
-else
-  echo "No orphaned packages found. All clean!"
 fi
 
-# -------------------------------------
-# 5: Prune ~/.cache (user cache)
-# -------------------------------------
+# --- Step 4 ---
+section_title "4. User Cache"
+sub_text "Targets: thumbnails, yay, paru, pip, npm"
 
-step "CLEANING ~/.cache DIRECTORY"
-before_cache=$(du -sh ~/.cache | cut -f1)
-echo "Cache size before cleanup: $before_cache"
-
-if confirm "Delete files older than $CACHE_DAYS days from ~/.cache? [y/N]"; then
-  find ~/.cache -type f -mtime +$CACHE_DAYS -print -delete
-  find ~/.cache -type d -empty -print -delete
-  after_cache=$(du -sh ~/.cache | cut -f1)
-  echo "Cache size after cleanup: $after_cache"
+if gum_safe confirm "Clean specific cache targets?"; then
+  for target in "${CACHE_TARGETS[@]}"; do
+    [[ -d "$target" ]] && run_task "Cleaning $target" "rm -rf $target/*"
+  done
 else
-  echo "Skipped cleaning ~/.cache."
+  sub_text "Skipped user cache."
 fi
 
-# -------------------------------------
-# 6: Clean old system logs (journald)
-# -------------------------------------
-
-step "VACUUMING SYSTEM LOGS (journald)"
-before_logs=$(journalctl --disk-usage | awk '{print $NF}')
-echo "Current journal size: $before_logs"
+# --- Step 5 ---
+section_title "5. System Logs"
+current_journal=$(journalctl --disk-usage | awk '{print $NF}')
 
-if confirm "Delete logs older than $JOURNAL_RETAIN? [y/N]"; then
-  sudo journalctl --rotate
-  sudo journalctl --vacuum-time=$JOURNAL_RETAIN
-  after_logs=$(journalctl --disk-usage | awk '{print $NF}')
-  echo "Journal size after vacuum: $after_logs"
+if gum_safe confirm "Vacuum logs > 7d? (Current: $current_journal)"; then
+  run_task "Rotating logs" "sudo journalctl --rotate"
+  run_task "Vacuuming logs" "sudo journalctl --vacuum-time=7d"
 else
-  echo "Skipped journald cleanup."
+  sub_text "Skipped logs."
 fi
 
-# -------------------------------------
-# 7: Check for Failed Services
-# -------------------------------------
+# --- Step 6 ---
+section_title "6. Service Health"
+failed_count=$(systemctl list-units --state=failed --no-legend | wc -l)
 
-step "CHECKING FOR FAILED SYSTEMD SERVICES"
-if systemctl --failed --quiet; then
-  echo "✅ No failed services found."
+if (( failed_count == 0 )); then
+  gum_safe style --foreground "$MOCHA_GREEN" --border none "✓ All systems operational."
 else
-  echo "⚠️ Some services have failed:"
-  systemctl --failed --no-pager --plain
+  gum_safe style --foreground "$MOCHA_RED" --border none "⚠️  $failed_count services failed:"
+  systemctl --failed --no-pager --plain | gum_safe format
 fi
 
-# -------------------------------------
-# Finished
-# -------------------------------------
-
-announce "✅ Spring‑Clean Completed in ${SECONDS}s"
-echo "Full log saved to: $LOG_FILE"
-
-# -------------------------------------
+echo ""
+gum_safe style --padding "1" "✨ Maintenance Complete."
+gum_safe style --foreground "$MOCHA_GREEN" --bold "🎉 All tasks completed! Review the log at: $LOG_FILE"
+sub_text "Press any key to exit..."
+read -n 1
\ No newline at end of file
.wraith/scripts/firewall.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Allow nothing in, everything out
+sudo ufw default deny incoming
+sudo ufw default allow outgoing
+
+# Allow ports for LocalSend
+sudo ufw allow 53317/udp comment 'LocalSend UDP'
+sudo ufw allow 53317/tcp comment 'LocalSend TCP'
+# Alternatively, restrict LocalSend to a specific interface
+# sudo ufw allow in on eth0 to any port 53317 proto udp comment 'LocalSend UDP'
+# sudo ufw allow in on eth0 to any port 53317 proto tcp comment 'LocalSend TCP'
+
+# Allow Docker containers to use DNS on host
+# sudo ufw allow in proto udp from 172.16.0.0/12 to 172.17.0.1 port 53 comment 'allow-docker-dns'
+sudo ufw allow in proto udp from 172.17.0.0/16 to 172.17.0.1 port 53 comment 'Docker DNS'
+sudo ufw logging medium
+
+# Turn on the firewall
+sudo ufw --force enable
+sudo systemctl enable ufw
+
+if command -v ufw-docker &> /dev/null; then
+    sudo ufw-docker install
+fi
+
+sudo ufw reload
+echo "✅ UFW setup complete!"
+
+