restructure some scripts + make new init script

This commit is contained in:
pika 2025-06-22 11:10:47 +02:00
parent a0d20383c3
commit ff563f2e0d
5 changed files with 197 additions and 124 deletions

View file

@ -24,28 +24,24 @@ barsetup() {
proc-kill-if "$bar"
# case "$bar" in
# hyprpanel)
# pkill hyprpanel
# hyprpanel &
# ;;
# gBar)
# pkill gBar
# gBar bar 0 &
# ;;
# waybar)
# pkill waybar
# waybar &
# ;;
# quickshell)
# pkill qs
# qs &
# ;;
# *)
# pkill $bar
# $bar &
# ;;
# esac
case "$bar" in
hyprpanel)
hyprpanel &
;;
gBar)
gBar bar 0 &
;;
waybar)
waybar &
;;
quickshell)
proc-kill-if "qs"
qs &
;;
*)
$bar &
;;
esac
}
if barsetup "$@"; then

View file

@ -1,41 +1,22 @@
#!/usr/bin/env bash
SCRIPTS="$HOME/.config/hypr/scripts"
# ─< 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
setup-wm-modules() {
bash -c "$SCRIPTS/bar"
log_notify low "Bar" "Initializing.."
# fi
notify-send -u "low" "Bar" "Bar setup done"
bash "$SCRIPTS/wallpaper"
log_notify low "Wallpaper" "Initializing.."
sleep 0.5
bash -c "$SCRIPTS/wallpaper"
notify-send -u "low" "SWWW" "Wallpaper setup done"
sleep 0.5
local modules
@ -49,40 +30,42 @@ setup-desktop() {
for module in "${modules[@]}"; do
if command-exists $module; then
log_notify low "$module" "Initializing.."
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.."
;;
# handled in $SCRIPTS/bar
# swww)
# swww-daemon &
# if ! swww query; then
# swww init
# fi
# ;;
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
}
@ -99,14 +82,12 @@ init-polkit() {
for agent in "${agents[@]}"; do
if [ -x "$agent" ]; then
log_notify "normal" "INFO" "Starting Polkit agent: $(basename "$agent")"
# local polkit="$(basename $agent)"
notify-send -u "normal" "Polkit" "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
@ -116,28 +97,25 @@ init-xdg-portal() {
if [ -x "$xdg_hyprland" ]; then
killall xdg-desktop-portal-hyprland xdg-desktop-portal-wlr xdg-desktop-portal 2>/dev/null
sleep 1
sleep 0.5
"$xdg_hyprland" &
sleep 1
sleep 0.5
"$xdg_portal" &
sleep 1
sleep 0.5
dbus-update-activation-environment --systemd --all &
log_notify "normal" "INFO" "XDG desktop portals initialized."
notify-send -u "normal" "xdg-portal" "XDG desktop portals initialized."
else
log_notify "low" "WARNING" "xdg-desktop-portal-hyprland not found. Please install it."
notify-send -u "low" "WARNING" "xdg-desktop-portal-hyprland not found. Please install it."
fi
}
main() {
kill-all
sleep 0.3
setup-desktop
setup-wm-modules
if [ -x "/usr/lib/hyprpolkitagent" ]; then
systemctl --user start hyprpolkitagent
else
init-polkit
fi
init-polkit
init-xdg-portal
}

145
scripts/init.bak Executable file
View file

@ -0,0 +1,145 @@
#!/bin/sh
# ─< 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)
if ! pgrep copyq; then
copyq --start-server
fi
;;
lxappearance)
if ! pgrep lxappearance; then
lxappearance >/dev/null 2>&1 &
fi
;;
'nwg-look')
nwg-look -a >/dev/null 2>&1 &
;;
# handled in $SCRIPTS/bar
# swww)
# swww-daemon &
# if ! swww query; then
# swww init
# fi
# ;;
redshift)
. "$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

0
scripts/init.sh.bak Normal file → Executable file
View file

View file

@ -1,46 +0,0 @@
#!/usr/bin/env bash
# ─< Check if the given command exists silently >─────────────────────────────────────────
command-exists() {
command -v "$@" >/dev/null 2>&1
}
check-env() {
local dir bin
bin=quickshell
dir="$HOME/.config/quickshell"
if command-exists $bin; then
return 0
else
return 69
fi
if [ -d "${dir}" ]; then
return 0
else
return 69
fi
}
check-env
init-quickshell() {
local modules
local dir="$HOME/.config/quickshell"
modules=(
"activate-linux"
)
for mod in "${modules[@]}"; do
module="${dir}/${mod}.qml"
if [ -f "$module" ]; then
quickshell -p "$module" &
fi
done
}
init-quickshell