From e99c6ebc5552250af08b8ff67cb17bb6853436ad Mon Sep 17 00:00:00 2001 From: pika Date: Fri, 28 Mar 2025 15:24:54 +0100 Subject: [PATCH] wip --- .scripts/init.sh | 179 ++++++++++++++++++++++++++--------------------- hyprland.conf | 4 +- 2 files changed, 101 insertions(+), 82 deletions(-) diff --git a/.scripts/init.sh b/.scripts/init.sh index ad044a1..98fb5e2 100755 --- a/.scripts/init.sh +++ b/.scripts/init.sh @@ -1,5 +1,10 @@ #!/bin/sh +# ─< Check if the given command exists silently >───────────────────────────────────────── +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + pkill swaync # Paths and configuration @@ -7,18 +12,18 @@ SCRIPTS_DIR="$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" + level="$1" # e.g., low, normal, critical + title="$2" + message="$3" + notify-send -u "$level" "$title" "$message" } # Initialize system modules initialize_modules() { - # ─< hyprpanel, waybar, gBar >──────────────────────────────────────────────────────────── - bar="hyprpanel" + # ─< hyprpanel, waybar, gBar >──────────────────────────────────────────────────────────── + bar="hyprpanel" - modules=" + modules=" copyq nwg-look swww @@ -27,58 +32,58 @@ initialize_modules() { redshift " - for module in $modules; do - if command -v "$module" >/dev/null 2>&1; then - log_notify "low" "$module" "Initializing..." - case $module in - waybar | flameshot) - pkill "$module" 2>/dev/null - "$module" & - ;; - hyprpanel) - hyprpanel & - ;; - 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 & - ;; - swww) - swww-daemon & - if ! swww query; then - swww init - fi - ;; - redshift) - pkill redshift 2>/dev/null - sh "$SCRIPTS_DIR/redshift.sh" - ;; - wob) - fifo="/tmp/$HYPRLAND_INSTANCE_SIGNATURE.wob" - rm -f "$fifo" - mkfifo "$fifo" - tail -f "$fifo" | wob & - ;; - esac - else - log_notify "critical" "ERROR" "$module not found!" - fi - sleep 0.5 - done + for module in $modules; do + if command_exists "$module"; then + log_notify "low" "$module" "Initializing..." + case $module in + waybar | flameshot) + pkill "$module" 2>/dev/null + "$module" & + ;; + hyprpanel) + hyprpanel & + ;; + 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 & + ;; + swww) + swww-daemon & + if ! swww query; then + swww init + fi + ;; + redshift) + pkill redshift 2>/dev/null + sh "$SCRIPTS_DIR/redshift.sh" + ;; + wob) + fifo="/tmp/$HYPRLAND_INSTANCE_SIGNATURE.wob" + rm -f "$fifo" + mkfifo "$fifo" + tail -f "$fifo" | wob & + ;; + esac + else + log_notify "critical" "ERROR" "$module not found!" + fi + sleep 0.5 + done - log_notify "normal" "INFO" "System modules initialized." + log_notify "normal" "INFO" "System modules initialized." } # Start polkit authentication agent initialize_polkit() { - agents=" + agents=" /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 /usr/lib/polkit-kde-authentication-agent-1 /usr/libexec/polkit-gnome-authentication-agent-1 @@ -87,43 +92,55 @@ initialize_polkit() { /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 + 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 + log_notify "low" "WARNING" "No Polkit authentication agent found. Please install one." + return 1 } # Initialize XDG desktop portals initialize_xdg_portals() { - xdg_hyprland="/usr/lib/xdg-desktop-portal-hyprland" - xdg_portal="/usr/lib/xdg-desktop-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 + 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 +} + +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() { - sleep 0.5 - initialize_xdg_portals - initialize_modules - initialize_polkit + sleep 0.5 + initialize_xdg_portals + initialize_modules + initialize_polkit + envS } main diff --git a/hyprland.conf b/hyprland.conf index 56ae815..168ffda 100644 --- a/hyprland.conf +++ b/hyprland.conf @@ -36,6 +36,8 @@ env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1 # ──────────────────────────────────────< windowrules >───────────────────────────────────── windowrule = workspace special:windoof, title:^(.*[Ll]ooking [Gg]lass.*) +$terminal = ghostty + # ╭────────────╮ # │ workspaces │ # ╰────────────╯ @@ -48,7 +50,7 @@ workspace = 6, monitor:DP-2 workspace = 7, monitor:HDMI-A-1 workspace = 8, 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 # ╭───────────────╮