diff options
Diffstat (limited to 'config/hypr/scripts/Polkit-Diag.sh')
| -rwxr-xr-x | config/hypr/scripts/Polkit-Diag.sh | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/config/hypr/scripts/Polkit-Diag.sh b/config/hypr/scripts/Polkit-Diag.sh index 0f32b640..aa4e69a8 100755 --- a/config/hypr/scripts/Polkit-Diag.sh +++ b/config/hypr/scripts/Polkit-Diag.sh @@ -50,20 +50,20 @@ setup_output() { else local outdir outdir=$(dirname "$OUTFILE") - + # Check and create directory if it doesn't exist if [[ ! -d "$outdir" ]]; then echo "Directory $outdir does not exist. Creating..." mkdir -p "$outdir" fi - + # Backup existing file if [[ -f "$OUTFILE" ]]; then local backup_file="${OUTFILE}.bak.$(date +%Y%m%d%H%M%S)" echo "Existing output file found. Backing up to: $backup_file" mv "$OUTFILE" "$backup_file" fi - + echo "Diagnostics will be saved to: $OUTFILE" exec 3> "$OUTFILE" fi @@ -74,7 +74,7 @@ apply_override() { local msg="\n=== Systemd Override for hyprpolkitagent ===" [[ $DRY_RUN -eq 0 ]] && echo -e "$msg" >&3 echo -e "$msg" - + local out if systemctl --user is-enabled hyprpolkitagent.service >/dev/null 2>&1; then msg="[STATUS] hyprpolkitagent.service is currently enabled." @@ -94,10 +94,10 @@ apply_override() { msg="[CONFIRM] Force override requested. Overwriting existing override..." [[ $DRY_RUN -eq 0 ]] && echo "$msg" >&3; echo "$msg" fi - + msg="[ACTION] Installing override to $OVERRIDE_FILE..." [[ $DRY_RUN -eq 0 ]] && echo "$msg" >&3; echo "$msg" - + if [[ $DRY_RUN -eq 0 ]]; then # Capture dir creation if out=$(mkdir -p "$OVERRIDE_DIR" 2>&1); then @@ -106,7 +106,7 @@ apply_override() { msg=" [ERROR] Failed to create directory $OVERRIDE_DIR.\n Details: $out" fi echo -e "$msg" >&3; echo -e "$msg" - + # Capture file write if out=$(echo "$OVERRIDE_CONTENT" > "$OVERRIDE_FILE" 2>&1); then msg=" [OK] Successfully wrote override file." @@ -114,7 +114,7 @@ apply_override() { msg=" [ERROR] Failed to write override file.\n Details: $out" fi echo -e "$msg" >&3; echo -e "$msg" - + # Capture daemon-reload if out=$(systemctl --user daemon-reload 2>&1); then msg=" [OK] Systemd daemon reloaded." @@ -122,12 +122,12 @@ apply_override() { msg=" [ERROR] Failed to reload systemd daemon.\n Details: $out" fi echo -e "$msg" >&3; echo -e "$msg" - + # Capture restart if systemctl --user is-active --quiet hyprpolkitagent.service; then msg="[ACTION] Restarting hyprpolkitagent.service..." [[ $DRY_RUN -eq 0 ]] && echo "$msg" >&3; echo "$msg" - + if out=$(systemctl --user restart hyprpolkitagent.service 2>&1); then msg=" [OK] Service restarted successfully." else @@ -153,31 +153,31 @@ gather_general_info() { echo "Date: $(date)" >&3 echo -e "\n--- Kernel ---" >&3 uname -a >&3 - + echo -e "\n--- OS Release ---" >&3 cat /etc/os-release >&3 - + echo -e "\n=======================================" >&3 echo -e " Polkit Service Status" >&3 echo -e "=======================================" >&3 - + echo -e "\n--- System Polkit Service ---" >&3 systemctl status polkit.service --no-pager >&3 2>&1 || true - + echo -e "\n--- User Hyprpolkitagent Service ---" >&3 systemctl --user status hyprpolkitagent.service --no-pager >&3 2>&1 || true - + echo -e "\n--- Running Polkit Processes ---" >&3 local polkit_procs polkit_procs=$(ps aux | grep -i '[p]olkit') if [[ -n "$polkit_procs" ]]; then echo "$polkit_procs" >&3 - + # Check for conflicting agents local kde_agent_running=0 local gnome_agent_running=0 local hypr_agent_running=0 - + if echo "$polkit_procs" | grep -q "polkit-kde-authentication-agent-1"; then kde_agent_running=1 fi @@ -187,7 +187,7 @@ gather_general_info() { if echo "$polkit_procs" | grep -q "hyprpolkitagent"; then hypr_agent_running=1 fi - + if [[ $hypr_agent_running -eq 1 && ($kde_agent_running -eq 1 || $gnome_agent_running -eq 1) ]]; then echo -e "\n[!] CONFLICT DETECTED: Multiple polkit agents are running!" >&3 echo " Hyprpolkitagent is running alongside another desktop environment's agent." >&3 @@ -205,14 +205,14 @@ gather_general_info() { else echo "No polkit processes found running." >&3 fi - + echo -e "\n=======================================" >&3 echo -e " Recent Logs" >&3 echo -e "=======================================" >&3 - + echo -e "\n--- Journalctl (polkit.service) [Last 50 entries, warnings/errors] ---" >&3 journalctl -u polkit.service -n 50 --no-pager -p 4 >&3 2>&1 || echo "Could not fetch system polkit logs." >&3 - + echo -e "\n--- Journalctl (hyprpolkitagent.service) [Last 50 entries] ---" >&3 journalctl --user -u hyprpolkitagent.service -n 50 --no-pager >&3 2>&1 || echo "Could not fetch user hyprpolkitagent logs." >&3 } @@ -223,7 +223,7 @@ check_packages() { local install_msg="$2" shift 2 local pkgs=("$@") - + local missing_pkgs=() for pkg in "${pkgs[@]}"; do local out @@ -235,7 +235,7 @@ check_packages() { missing_pkgs+=("$pkg") fi done - + if [[ ${#missing_pkgs[@]} -gt 0 ]]; then echo -e "\nWARNING: The following packages are missing:" >&3 for mpkg in "${missing_pkgs[@]}"; do @@ -251,7 +251,7 @@ check_source_binaries() { shift local bins=("$@") local found_any=0 - + echo -e "\n--- Source Builds (${bin_dir}) ---" >&3 for bin in "${bins[@]}"; do if [[ -x "${bin_dir}/${bin}" ]]; then @@ -261,7 +261,7 @@ check_source_binaries() { echo "[MISSING] ${bin_dir}/${bin}" >&3 fi done - + return $found_any } @@ -269,7 +269,7 @@ gather_arch_info() { echo -e "\n=======================================" >&3 echo -e " Package Info (Arch Linux)" >&3 echo -e "=======================================" >&3 - + # Essential packages required for polkit & related UI local pkgs=( "qt5-declarative" @@ -278,19 +278,19 @@ gather_arch_info() { "hyprpolkitagent" "polkit" ) - + local aur_pkgs=( "xfce-polkit" ) - + local missing_any=0 - + echo -e "\n--- Official Repositories ---" >&3 check_packages "pacman -Q" "Install official packages by running: sudo pacman -S" "${pkgs[@]}" || missing_any=1 - + echo -e "\n--- AUR ---" >&3 check_packages "pacman -Q" "Install AUR packages by running: yay -S" "${aur_pkgs[@]}" || missing_any=1 - + if [[ $missing_any -eq 0 ]]; then echo -e "\nSUCCESS: All expected packages are installed." >&3 fi @@ -299,7 +299,7 @@ gather_ubuntu_info() { echo -e "\n=======================================" >&3 echo -e " Package Info (Ubuntu/PPA)" >&3 echo -e "=======================================" >&3 - + # Essential packages required for polkit & related UI local pkgs=( "qml-module-qtqml" @@ -313,22 +313,22 @@ gather_ubuntu_info() { "hyprpolkitagent" "polkit" ) - + local extra_pkgs=( "xfce-polkit" "polkit-kde-agent-1" "mate-polkit" ) - + local missing_any=0 - + echo -e "\n--- Official Repositories / PPA ---" >&3 check_packages "dpkg -s" "Install packages by running: sudo apt install" "${pkgs[@]}" || missing_any=1 - + echo -e "\n--- Extra/Alternative ---" >&3 check_packages "dpkg -s" "Install extra packages by running: sudo apt install" "${extra_pkgs[@]}" || missing_any=1 echo "[INFO] lxqt-polkit (optional) — large dependency set." >&3 - + if [[ $missing_any -eq 0 ]]; then echo -e "\nSUCCESS: All expected packages are installed." >&3 fi @@ -337,16 +337,16 @@ gather_debian_info() { echo -e "\n=======================================" >&3 echo -e " Package Info (Debian/Ubuntu)" >&3 echo -e "=======================================" >&3 - + local source_bins=( "hyprpolkitagent" ) - + local source_found=0 if check_source_binaries "/usr/local/bin" "${source_bins[@]}"; then source_found=1 fi - + # Essential packages required for polkit & related UI local pkgs=( "qml-module-qtqml" @@ -359,16 +359,16 @@ gather_debian_info() { "qml6-module-qtquick-controls" "polkit" ) - + local extra_pkgs=( "xfce4-polkit" "lxqt-policykit" "polkit-kde-agent-1" "mate-polkit" ) - + local missing_any=0 - + echo -e "\n--- Official Repositories ---" >&3 if [[ $source_found -eq 0 ]]; then pkgs+=("hyprpolkitagent") @@ -376,10 +376,10 @@ gather_debian_info() { echo "[INFO] hyprpolkitagent found in /usr/local/bin (source build). Skipping dpkg check for it." >&3 fi check_packages "dpkg -s" "Install packages by running: sudo apt install" "${pkgs[@]}" || missing_any=1 - + echo -e "\n--- Extra/Alternative ---" >&3 check_packages "dpkg -s" "Install extra packages by running: sudo apt install" "${extra_pkgs[@]}" || missing_any=1 - + if [[ $missing_any -eq 0 ]]; then echo -e "\nSUCCESS: All expected packages are installed." >&3 fi @@ -389,7 +389,7 @@ gather_fedora_info() { echo -e "\n=======================================" >&3 echo -e " Package Info (Fedora)" >&3 echo -e "=======================================" >&3 - + # Essential packages required for polkit & related UI local pkgs=( "qt5-qtdeclarative" @@ -398,19 +398,19 @@ gather_fedora_info() { "hyprpolkitagent" "polkit" ) - + local extra_pkgs=( "xfce-polkit" ) - + local missing_any=0 - + echo -e "\n--- Official Repositories ---" >&3 check_packages "rpm -q" "Install packages by running: sudo dnf install" "${pkgs[@]}" || missing_any=1 - + echo -e "\n--- Extra/Alternative ---" >&3 check_packages "rpm -q" "Install extra packages by running: sudo dnf install" "${extra_pkgs[@]}" || missing_any=1 - + if [[ $missing_any -eq 0 ]]; then echo -e "\nSUCCESS: All expected packages are installed." >&3 fi |
