nirish

config files for niri window manager
Log | Files | Refs | README | LICENSE

pkg-install (1693B)


      1 #!/usr/bin/env bash
      2 
      3 set -euo pipefail
      4 
      5 # Colors
      6 RED='\e[31m'
      7 GREEN='\e[32m'
      8 YELLOW='\e[33m'
      9 BLUE='\e[34m'
     10 BOLD='\e[1m'
     11 RESET='\e[0m'
     12 
     13 # Check required tools
     14 for tool in fzf pacman; do
     15   if ! command -v "$tool" >/dev/null 2>&1; then
     16     echo -e "${RED}Error: $tool is not installed${RESET}"
     17     notify-send "ERROR" "$tool is not installed."
     18     exit 1
     19   fi
     20 done
     21 
     22 # FZF configuration
     23 fzf_args=(
     24   --multi
     25   --preview 'pacman -Sii {1}'
     26   --preview-label-pos='bottom'
     27   --preview-window 'down:65%:wrap'
     28   --color 'pointer:green,marker:green'
     29   --header='Select packages to install (TAB to select multiple, ENTER to confirm)'
     30   --border
     31 )
     32 
     33 echo -e "${BLUE}${BOLD}Loading package list...${RESET}\n"
     34 
     35 # Get package selections
     36 pkg_names=$(pacman -Slq | fzf "${fzf_args[@]}" || true)
     37 
     38 # Check if user selected anything
     39 if [[ -z "$pkg_names" ]]; then
     40   echo -e "${YELLOW}No packages selected. Exiting.${RESET}"
     41   exit 0
     42 fi
     43 
     44 # Show what will be installed
     45 echo -e "${BLUE}${BOLD}Selected packages:${RESET}"
     46 echo "$pkg_names" | sed 's/^/  - /'
     47 echo
     48 
     49 # Convert to array for safe handling
     50 mapfile -t packages < <(echo "$pkg_names")
     51 
     52 # Install packages
     53 echo -e "${GREEN}${BOLD}Installing ${#packages[@]} package(s)...${RESET}\n"
     54 
     55 if sudo pacman -S --noconfirm "${packages[@]}"; then
     56   echo
     57   echo -e "${GREEN}${BOLD}✓ Successfully installed ${#packages[@]} package(s)${RESET}"
     58 else
     59   echo
     60   echo -e "${RED}${BOLD}✗ Installation failed or was incomplete${RESET}"
     61 fi
     62 
     63 echo
     64 
     65 # Keep window open
     66 if command -v gum >/dev/null 2>&1; then
     67   gum spin --spinner "globe" --title "Done! Press any key to close..." -- bash -c 'read -n 1 -s'
     68 else
     69   echo -e "${BLUE}Press any key to close...${RESET}"
     70   read -n 1 -s
     71 fi