hypr/scripts/init

123 lines
2.7 KiB
Bash
Executable file

#!/usr/bin/env bash
SCRIPTS="$HOME/.config/hypr/scripts"
# ─< Check if the given command exists silently >─────────────────────────────────────────
command-exists() {
command -v "$@" >/dev/null 2>&1
}
setup-wm-modules() {
bash -c "$SCRIPTS/bar"
notify-send -u "low" "Bar" "Bar setup done"
sleep 0.5
bash -c "$SCRIPTS/wallpaper"
notify-send -u "low" "SWWW" "Wallpaper setup done"
sleep 0.5
local modules
modules=(
"copyq"
"nwg-look"
"lxappearance"
"wob"
"redshift"
)
for module in "${modules[@]}"; do
if command-exists $module; then
case $module in
copyq)
if ! pgrep copyq; then
copyq --start-server
fi
notify-send -u "low" "$module" "Started server"
;;
lxappearance)
if ! pgrep lxappearance; then
lxappearance >/dev/null 2>&1 &
fi
notify-send -u "low" "$module" "Starting.."
;;
'nwg-look')
nwg-look -a >/dev/null 2>&1 &
notify-send -u "low" "$module" "Starting.."
;;
redshift)
. "$SCRIPTS/redshift.sh"
;;
wob)
local fifo="/tmp/$HYPRLAND_INSTANCE_SIGNATURE.wob"
notify-send -u "low" "$module" "Creating fifo.."
rm -f "$fifo"
mkfifo "$fifo"
tail -f "$fifo" | wob &
;;
esac
fi
sleep 0.15
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
# local polkit="$(basename $agent)"
notify-send -u "normal" "Polkit" "Starting Polkit agent: $(basename $agent)"
"$agent" &
fi
done
}
# 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 0.5
"$xdg_hyprland" &
sleep 0.5
"$xdg_portal" &
sleep 0.5
dbus-update-activation-environment --systemd --all &
notify-send -u "normal" "xdg-portal" "XDG desktop portals initialized."
else
notify-send -u "low" "WARNING" "xdg-desktop-portal-hyprland not found. Please install it."
fi
}
main() {
setup-wm-modules
init-polkit
init-xdg-portal
}
main