#!/usr/bin/env bash

set -e

SCRIPT_PATH="$HOME/.config/quickshell/modules/wlogout/scripts/helper.sh"

# 1. Run helper script if it exists
if [[ -x "$SCRIPT_PATH" ]]; then
    echo "Running helper script..."
    bash "$SCRIPT_PATH"
else
    echo "Helper script not found, skipping..."
fi

# 2. Run hyprshutdown if available
if command -v hyprshutdown >/dev/null 2>&1; then
    echo "Running hyprshutdown..."
    hyprshutdown
else
    echo "hyprshutdown not found, skipping..."
fi

# 3. Power off if systemctl exists
if command -v systemctl >/dev/null 2>&1; then
    echo "Powering off system..."
    systemctl poweroff
else
    shutdown -h now
fi