148 lines
3.7 KiB
Bash
Executable file
148 lines
3.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
|
command-exists() {
|
|
command -v "$@" >/dev/null 2>&1
|
|
}
|
|
|
|
kill-all() {
|
|
# ─< Kill already running processes >─────────────────────────────────────────────────────
|
|
hyprpanel="gjs" # since hyprpanel has so many different wordings, making it clear that this is currently the hyprpanel service name
|
|
_ps=(swaync gBar rofi fuzzel wofi swaync waybar $hyprpanel)
|
|
for _prs in "${_ps[@]}"; do
|
|
if pidof "${_prs}" >/dev/null; then
|
|
pkill "${_prs}"
|
|
fi
|
|
done
|
|
}
|
|
|
|
SCRIPTS="$HOME/.config/hypr/.scripts"
|
|
|
|
# Logging helper
|
|
log_notify() {
|
|
level="$1" # e.g., low, normal, critical
|
|
title="$2"
|
|
message="$3"
|
|
notify-send -u "$level" "$title" "$message"
|
|
}
|
|
|
|
setup-desktop() {
|
|
# if command-exists qs; then
|
|
# qs
|
|
# else
|
|
bash -c "$SCRIPTS/bar"
|
|
log_notify low "Bar" "Initializing.."
|
|
# fi
|
|
|
|
bash "$SCRIPTS/wallpaper"
|
|
log_notify low "Wallpaper" "Initializing.."
|
|
|
|
local modules
|
|
|
|
modules=(
|
|
"copyq"
|
|
"nwg-look"
|
|
"lxappearance"
|
|
"wob"
|
|
"redshift"
|
|
)
|
|
|
|
for module in "${modules[@]}"; do
|
|
if command-exists $module; then
|
|
log_notify low "$module" "Initializing.."
|
|
|
|
case $module in
|
|
copyq)
|
|
# pkill copyq 2>/dev/null
|
|
copyq --start-server
|
|
# sleep 1
|
|
# if ! pgrep -x copyq >/dev/null; then
|
|
# # log_notify "critical" "ERROR" "CopyQ failed to start. Retrying..."
|
|
# copyq --start-server
|
|
# fi
|
|
;;
|
|
lxappearance)
|
|
lxappearance >/dev/null 2>&1 &
|
|
;;
|
|
'nwg-look')
|
|
nwg-look -a >/dev/null 2>&1 &
|
|
;;
|
|
# handled in $SCRIPTS/bar
|
|
# swww)
|
|
# swww-daemon &
|
|
# if ! swww query; then
|
|
# swww init
|
|
# fi
|
|
# ;;
|
|
redshift)
|
|
pkill redshift 2>/dev/null
|
|
bash -c "$SCRIPTS/redshift.sh"
|
|
;;
|
|
wob)
|
|
local fifo="/tmp/$HYPRLAND_INSTANCE_SIGNATURE.wob"
|
|
rm -f "$fifo"
|
|
mkfifo "$fifo"
|
|
tail -f "$fifo" | wob &
|
|
;;
|
|
esac
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Start polkit authentication agent
|
|
init-polkit() {
|
|
agents="
|
|
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
|
|
/usr/lib/polkit-kde-authentication-agent-1
|
|
/usr/libexec/polkit-gnome-authentication-agent-1
|
|
/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1
|
|
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
|
|
/usr/lib/polkit-1/polkit-agent-helper-1
|
|
"
|
|
|
|
for agent in $agents; do
|
|
if [ -x "$agent" ]; then
|
|
log_notify "normal" "INFO" "Starting Polkit agent: $(basename "$agent")"
|
|
"$agent" &
|
|
return 0
|
|
fi
|
|
done
|
|
|
|
log_notify "low" "WARNING" "No Polkit authentication agent found. Please install one."
|
|
return 1
|
|
}
|
|
|
|
# Initialize XDG desktop portals
|
|
init-xdg-portal() {
|
|
xdg_hyprland="/usr/lib/xdg-desktop-portal-hyprland"
|
|
xdg_portal="/usr/lib/xdg-desktop-portal"
|
|
|
|
if [ -x "$xdg_hyprland" ]; then
|
|
killall xdg-desktop-portal-hyprland xdg-desktop-portal-wlr xdg-desktop-portal 2>/dev/null
|
|
sleep 1
|
|
"$xdg_hyprland" &
|
|
sleep 1
|
|
"$xdg_portal" &
|
|
sleep 1
|
|
dbus-update-activation-environment --systemd --all &
|
|
log_notify "normal" "INFO" "XDG desktop portals initialized."
|
|
else
|
|
log_notify "low" "WARNING" "xdg-desktop-portal-hyprland not found. Please install it."
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
kill-all
|
|
sleep 0.3
|
|
setup-desktop
|
|
|
|
if [ -x "/usr/lib/hyprpolkitagent" ]; then
|
|
systemctl --user start hyprpolkitagent
|
|
else
|
|
init-polkit
|
|
fi
|
|
|
|
init-xdg-portal
|
|
}
|
|
|
|
main
|