diff options
| author | srdusr <trevorgray@srdusr.com> | 2025-09-24 05:01:20 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2025-09-24 05:01:20 +0200 |
| commit | 553cb2204b0bf27afe13c6332f5679bbd47172a0 (patch) | |
| tree | 75c86ff018122a682e0afd7a0e2a0228a63e44bd /unix/utils/sext | |
| parent | b20e4e004be74884cc72c57a3128e36fd5177d7a (diff) | |
| download | dotfiles-553cb2204b0bf27afe13c6332f5679bbd47172a0.tar.gz dotfiles-553cb2204b0bf27afe13c6332f5679bbd47172a0.zip | |
Update/Overhaul
Diffstat (limited to 'unix/utils/sext')
| -rwxr-xr-x | unix/utils/sext | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/unix/utils/sext b/unix/utils/sext new file mode 100755 index 0000000..b120929 --- /dev/null +++ b/unix/utils/sext @@ -0,0 +1,47 @@ +#!/bin/bash + +#Sext (Shutdown Exit) +# List of package managers to check for +package_managers=("emerge" "apt" "dnf" "pacman" "zypper") + +# Set how often to check (in seconds) +check_interval=30 + +# Check if any package manager is running +is_package_manager_running() { + for pm in "${package_managers[@]}"; do + if pgrep -x "$pm" >/dev/null; then + return 0 # Return 0 (true) if any package manager is running + fi + done + return 1 # Return 1 (false) if no package manager is running +} + +# Safely shutdown the system +safe_shutdown() { + # Try using shutdown without sudo first + if shutdown -h now; then + echo "Shutdown initiated successfully using 'shutdown'." + # If shutdown fails, try using poweroff + elif poweroff; then + echo "Shutdown initiated successfully using 'poweroff'." + # If poweroff fails, try using sudo poweroff + elif sudo poweroff; then + echo "Shutdown initiated successfully with 'sudo poweroff'." + # If both shutdown and poweroff fail, try with sudo shutdown + elif sudo shutdown -h now; then + echo "Shutdown initiated successfully with 'sudo shutdown'." + else + echo "Shutdown command failed. Please check your system configuration." + fi +} + +# Loop until no package manager process is running +while is_package_manager_running; do + echo "Package manager is still running. Checking again in $check_interval seconds..." + sleep "$check_interval" +done + +# Once the process completes, initiate a safe shutdown +echo "Package manager has finished. Attempting to shutdown..." +safe_shutdown |
