|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +pipewire=( |
| 4 | + pipewire |
| 5 | + wireplumber |
| 6 | + pipewire-audio |
| 7 | + pipewire-alsa |
| 8 | + pipewire-pulse |
| 9 | +) |
| 10 | + |
| 11 | +############## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ############## |
| 12 | +# Set some colors for output messages |
| 13 | +OK=$(tput setaf 2)[OK]$(tput sgr0) |
| 14 | +ERROR=$(tput setaf 1)[ERROR]$(tput sgr0) |
| 15 | +NOTE=$(tput setaf 3)[NOTE]$(tput sgr0) |
| 16 | +WARN=$(tput setaf 166)[WARN]$(tput sgr0) |
| 17 | +CAT=$(tput setaf 6)[ACTION]$(tput sgr0) |
| 18 | +ORANGE=$(tput setaf 166) |
| 19 | +YELLOW=$(tput setaf 3) |
| 20 | +RESET=$(tput sgr0) |
| 21 | + |
| 22 | +# Set the name of the log file to include the current date and time |
| 23 | +LOG="install-$(date +%d-%H%M%S)_bluetooth.log" |
| 24 | + |
| 25 | +ISAUR=$(command -v yay || command -v paru) |
| 26 | + |
| 27 | +# Set the script to exit on error |
| 28 | +set -e |
| 29 | + |
| 30 | +# Function for installing packages |
| 31 | +install_package() { |
| 32 | + # Checking if the package is already installed |
| 33 | + if $ISAUR -Q "$1" &>>/dev/null; then |
| 34 | + echo -e "${OK} $1 is already installed. Skipping..." |
| 35 | + else |
| 36 | + # Package not installed |
| 37 | + echo -e "${NOTE} Installing $1 ..." |
| 38 | + $ISAUR -S --noconfirm "$1" 2>&1 | tee -a "$LOG" |
| 39 | + # Making sure the package is installed |
| 40 | + if $ISAUR -Q "$1" &>>/dev/null; then |
| 41 | + echo -e "\e[1A\e[K${OK} $1 was installed." |
| 42 | + else |
| 43 | + # Something is missing, exiting to review the log |
| 44 | + echo -e "\e[1A\e[K${ERROR} $1 failed to install. Please check the install.log. You may need to install manually! Sorry I have tried :(" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + fi |
| 48 | +} |
| 49 | + |
| 50 | +# Removal of pulseaudio |
| 51 | +printf "${YELLOW}Removing pulseaudio stuff...${RESET}\n" |
| 52 | +for pulseaudio in pulseaudio pulseaudio-alsa pulseaudio-bluetooth; do |
| 53 | + sudo pacman -R --noconfirm "$pulseaudio" 2>/dev/null | tee -a "$LOG" || true |
| 54 | +done |
| 55 | + |
| 56 | +# Disabling pulseaudio to avoid conflicts |
| 57 | +systemctl --user disable --now pulseaudio.socket pulseaudio.service 2>&1 | tee -a "$LOG" |
| 58 | + |
| 59 | +# Pipewire |
| 60 | +printf "${NOTE} Installing Pipewire Packages...\n" |
| 61 | +for PIPEWIRE in "${pipewire[@]}"; do |
| 62 | + install_package "$PIPEWIRE" 2>&1 | tee -a "$LOG" |
| 63 | + [ $? -ne 0 ] && { echo -e "\e[1A\e[K${ERROR} - $PIPEWIRE install had failed. Please check the install.log"; exit 1; } |
| 64 | +done |
| 65 | + |
| 66 | +printf "Activating Pipewire Services...\n" |
| 67 | +systemctl --user enable --now pipewire.socket pipewire-pulse.socket wireplumber.service 2>&1 | tee -a "$LOG" |
| 68 | +systemctl --user enable --now pipewire.service 2>&1 | tee -a "$LOG" |
| 69 | + |
| 70 | +clear |
0 commit comments