This commit is contained in:
pika 2025-03-28 15:24:54 +01:00
parent 7fc4a62301
commit e99c6ebc55
2 changed files with 101 additions and 82 deletions

View file

@ -1,5 +1,10 @@
#!/bin/sh #!/bin/sh
# ─< Check if the given command exists silently >─────────────────────────────────────────
command_exists() {
command -v "$@" >/dev/null 2>&1
}
pkill swaync pkill swaync
# Paths and configuration # Paths and configuration
@ -7,18 +12,18 @@ SCRIPTS_DIR="$HOME/.config/hypr/.scripts"
# Logging helper # Logging helper
log_notify() { log_notify() {
level="$1" # e.g., low, normal, critical level="$1" # e.g., low, normal, critical
title="$2" title="$2"
message="$3" message="$3"
notify-send -u "$level" "$title" "$message" notify-send -u "$level" "$title" "$message"
} }
# Initialize system modules # Initialize system modules
initialize_modules() { initialize_modules() {
# ─< hyprpanel, waybar, gBar >──────────────────────────────────────────────────────────── # ─< hyprpanel, waybar, gBar >────────────────────────────────────────────────────────────
bar="hyprpanel" bar="hyprpanel"
modules=" modules="
copyq copyq
nwg-look nwg-look
swww swww
@ -27,58 +32,58 @@ initialize_modules() {
redshift redshift
" "
for module in $modules; do for module in $modules; do
if command -v "$module" >/dev/null 2>&1; then if command_exists "$module"; then
log_notify "low" "$module" "Initializing..." log_notify "low" "$module" "Initializing..."
case $module in case $module in
waybar | flameshot) waybar | flameshot)
pkill "$module" 2>/dev/null pkill "$module" 2>/dev/null
"$module" & "$module" &
;; ;;
hyprpanel) hyprpanel)
hyprpanel & hyprpanel &
;; ;;
copyq) copyq)
pkill copyq 2>/dev/null pkill copyq 2>/dev/null
copyq --start-server copyq --start-server
sleep 1 sleep 1
if ! pgrep -x copyq >/dev/null; then if ! pgrep -x copyq >/dev/null; then
log_notify "critical" "ERROR" "CopyQ failed to start. Retrying..." log_notify "critical" "ERROR" "CopyQ failed to start. Retrying..."
copyq --start-server copyq --start-server
fi fi
;; ;;
lxappearance) lxappearance)
lxappearance >/dev/null 2>&1 & lxappearance >/dev/null 2>&1 &
;; ;;
swww) swww)
swww-daemon & swww-daemon &
if ! swww query; then if ! swww query; then
swww init swww init
fi fi
;; ;;
redshift) redshift)
pkill redshift 2>/dev/null pkill redshift 2>/dev/null
sh "$SCRIPTS_DIR/redshift.sh" sh "$SCRIPTS_DIR/redshift.sh"
;; ;;
wob) wob)
fifo="/tmp/$HYPRLAND_INSTANCE_SIGNATURE.wob" fifo="/tmp/$HYPRLAND_INSTANCE_SIGNATURE.wob"
rm -f "$fifo" rm -f "$fifo"
mkfifo "$fifo" mkfifo "$fifo"
tail -f "$fifo" | wob & tail -f "$fifo" | wob &
;; ;;
esac esac
else else
log_notify "critical" "ERROR" "$module not found!" log_notify "critical" "ERROR" "$module not found!"
fi fi
sleep 0.5 sleep 0.5
done done
log_notify "normal" "INFO" "System modules initialized." log_notify "normal" "INFO" "System modules initialized."
} }
# Start polkit authentication agent # Start polkit authentication agent
initialize_polkit() { initialize_polkit() {
agents=" agents="
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
/usr/lib/polkit-kde-authentication-agent-1 /usr/lib/polkit-kde-authentication-agent-1
/usr/libexec/polkit-gnome-authentication-agent-1 /usr/libexec/polkit-gnome-authentication-agent-1
@ -87,43 +92,55 @@ initialize_polkit() {
/usr/lib/polkit-1/polkit-agent-helper-1 /usr/lib/polkit-1/polkit-agent-helper-1
" "
for agent in $agents; do for agent in $agents; do
if [ -x "$agent" ]; then if [ -x "$agent" ]; then
log_notify "normal" "INFO" "Starting Polkit agent: $(basename "$agent")" log_notify "normal" "INFO" "Starting Polkit agent: $(basename "$agent")"
"$agent" & "$agent" &
return 0 return 0
fi fi
done done
log_notify "low" "WARNING" "No Polkit authentication agent found. Please install one." log_notify "low" "WARNING" "No Polkit authentication agent found. Please install one."
return 1 return 1
} }
# Initialize XDG desktop portals # Initialize XDG desktop portals
initialize_xdg_portals() { initialize_xdg_portals() {
xdg_hyprland="/usr/lib/xdg-desktop-portal-hyprland" xdg_hyprland="/usr/lib/xdg-desktop-portal-hyprland"
xdg_portal="/usr/lib/xdg-desktop-portal" xdg_portal="/usr/lib/xdg-desktop-portal"
if [ -x "$xdg_hyprland" ]; then if [ -x "$xdg_hyprland" ]; then
killall xdg-desktop-portal-hyprland xdg-desktop-portal-wlr xdg-desktop-portal 2>/dev/null killall xdg-desktop-portal-hyprland xdg-desktop-portal-wlr xdg-desktop-portal 2>/dev/null
sleep 1 sleep 1
"$xdg_hyprland" & "$xdg_hyprland" &
sleep 1 sleep 1
"$xdg_portal" & "$xdg_portal" &
sleep 1 sleep 1
dbus-update-activation-environment --systemd --all & dbus-update-activation-environment --systemd --all &
log_notify "normal" "INFO" "XDG desktop portals initialized." log_notify "normal" "INFO" "XDG desktop portals initialized."
else else
log_notify "low" "WARNING" "xdg-desktop-portal-hyprland not found. Please install it." log_notify "low" "WARNING" "xdg-desktop-portal-hyprland not found. Please install it."
fi fi
}
envS() {
terminals="ghostty wezterm kitty"
for envTerminal in "$terminals"; do
if command_exists $envTerminal; then
export HYPR_TERMINAL="$envTerminal"
log_notify "normal" "Terminal" "..is set to $envTerminal"
break
fi
done
} }
# Main initialization function # Main initialization function
main() { main() {
sleep 0.5 sleep 0.5
initialize_xdg_portals initialize_xdg_portals
initialize_modules initialize_modules
initialize_polkit initialize_polkit
envS
} }
main main

View file

@ -36,6 +36,8 @@ env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
# ──────────────────────────────────────< windowrules >───────────────────────────────────── # ──────────────────────────────────────< windowrules >─────────────────────────────────────
windowrule = workspace special:windoof, title:^(.*[Ll]ooking [Gg]lass.*) windowrule = workspace special:windoof, title:^(.*[Ll]ooking [Gg]lass.*)
$terminal = ghostty
# ╭────────────╮ # ╭────────────╮
# │ workspaces │ # │ workspaces │
# ╰────────────╯ # ╰────────────╯
@ -48,7 +50,7 @@ workspace = 6, monitor:DP-2
workspace = 7, monitor:HDMI-A-1 workspace = 7, monitor:HDMI-A-1
workspace = 8, monitor:HDMI-A-1 workspace = 8, monitor:HDMI-A-1
workspace = 9, monitor:HDMI-A-1 workspace = 9, monitor:HDMI-A-1
workspace = special:magic, monitor:DP-2, on-created-empty:ghostty workspace = special:magic, monitor:DP-2, on-created-empty:$terminal
# workspace = 0, monitor:HDMI-1 # workspace = 0, monitor:HDMI-1
# ╭───────────────╮ # ╭───────────────╮