Feat: moved all the startup script to systemd services

This commit is contained in:
2026-05-31 15:20:26 +05:30
parent a61cc65725
commit 6695e8192b
18 changed files with 148 additions and 41 deletions
+37 -19
View File
@@ -1,7 +1,7 @@
#!/bin/sh
notify() {
notify-send -e -i "$icon_dir/$1" -h "string:x-canonical-private-synchronous:${0##*/}" "$2" -u "${3:-normal}"
notify-send -e -t 5000 -i "${icon_dir}${1}" -h "string:x-canonical-private-synchronous:${0##*/}" "$2" -u "${3:-normal}"
}
print_sleep() {
@@ -9,36 +9,54 @@ print_sleep() {
sleep "$1"
}
switch_to_ac_mode() {
charge_icon=$(printf "%03d" "$((charge / 10))0")
hyprctl keyword monitor 'eDP-1',preferred,auto,1.5,bitdepth,10
hyprctl keyword decoration:blur:enabled true
hyprctl keyword decoration:shadow:enabled true
notify "battery-$charge_icon-charging.svg" "AC Mode ($charge%, Charging)"
exit 0
}
switch_to_battery_mode() {
charge_icon=$(printf "%03d" "$((charge / 10))0")
hyprctl keyword monitor 'eDP-1',$battery_resolution,auto,1.5,bitdepth,10
hyprctl keyword decoration:blur:enabled false
hyprctl keyword decoration:shadow:enabled false
notify "battery-$charge_icon.svg" "Battery Mode ($charge%, Discharging)"
exit 0
}
#declaration
dir="/sys/class/power_supply/"
battery="BAT0" #change accordingly
dir="/sys/class/power_supply/$battery/"
battery_dir="${dir}${battery}/"
icon_dir="/usr/share/icons/Papirus-Dark/22x22/panel/" #change accordingly
i=0
status="normal"
charge=$(cat "$dir"/capacity)
power_status=$(cat "$dir"/status)
charge=$(cat "$battery_dir"/capacity)
battery_resolution="2880x1800@48" # widthxheight@refresh_rate
case "$1" in
ac)
notify "battery-$(( charge / 10))0-charging.svg" "Power: AC Mode ($charge % $power_status)"
hyprctl keyword decoration:blur:enabled true
hyprctl keyword decoration:shadow:enabled true
exit 0
;;
ac)
switch_to_ac_mode
;;
battery)
notify "battery-$(( charge / 10))0.svg" "Power: Battery Mode ($charge % $power_status)"
hyprctl keyword decoration:blur:enabled false
hyprctl keyword decoration:shadow:enabled false
exit 0
;;
battery)
switch_to_battery_mode
;;
check)
if [ "$(cat "$dir/ADP1/online")" -eq 0 ]; then
switch_to_battery_mode
fi
exit 0
;;
*) ;;
*) ;;
esac
#infinite loop
while charge=$(cat "$dir"/capacity); do
if [ "$(cat "$dir"/status)" = "Charging" ]; then
while charge=$(cat "$battery_dir"/capacity); do
if [ "$(cat "$battery_dir"/status)" = "Charging" ]; then
i=300 #default polling time, it's 5 minutes
else
case $charge in
+18 -7
View File
@@ -4,7 +4,7 @@ monitorv2 {
mode = preferred
position = auto
scale = 1.5
vrr = 2
vrr = 1
bitdepth = 10
}
@@ -294,10 +294,21 @@ workspace = special, on-created-empty:[float] foot
#startup applications
exec-once = systemctl --user import-environment DBUS_SESSION_BUS_ADDRESS WAYLAND_DISPLAY XDG_SESSION_TYPE XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP QT_QPA_PLATFORMTHEME GTK_THEME
exec-once = dbus-update-activation-environment --systemd --all
exec-once = hypridle
exec-once = ssh-agent
# misc
exec-once = systemctl --user start ssh-agent
exec-once = systemctl --user start ntfy_sub
exec-once = systemctl --user start workspace
# hypr ecosystem
exec-once = systemctl --user start hyprpolkitagent
exec-once = swaybg -i $HOME/.config/wall/1.png -m fill
exec-once = $hypr_dir/workspace focus
exec-once = $hypr_dir/battery
exec-once = $hypr_dir/themes
exec-once = systemctl --user start hypridle
# power
exec-once = systemctl --user start power-mode@check
exec-once = systemctl --user start monitor-battery
# UI
exec-once = systemctl --user start theme
exec-once = systemctl --user start set-background@1.png
-1
View File
@@ -48,7 +48,6 @@ input-field {
check_color = rgb(204, 136, 34)
fail_color = rgb(204, 34, 34)
fail_text = <i>$FAIL <b>($ATTEMPTS)</b></i>
fail_transition = 300
capslock_color = -1
numlock_color = -1
bothlock_color = -1
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Executable
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
notify () {
notify-send -i "$icon_path" -e -h "string:x-canonical-private-synchronous:${0##*/}" "[$1] ${2}" "$3"
}
env_file="${XDG_CONFIG_HOME:-$HOME/.config}/.env"
. "$env_file"
ntfy_creds load
token="$(printf 'Basic %s' "$(printf ':%s' "$NTFY_TOKEN" | base64)" | base64 | tr -d '=')"
icon_path="$(dirname "$0")/ntfy.png"
trap "ntfy_creds unload" EXIT
trap "ntfy_creds unload; exit 1" INT HUP
websocat --no-close "wss://${NTFY_URL#https://}/$NTFY_TOPIC_LISTEN/ws?auth=$token" | while IFS= read -r line; do
title=$(printf '%s' "$line" | sed -nE 's|.*,"title":"([^"]*)",.*|\1|p')
topic=$(printf '%s' "$line" | sed -nE 's|.*,"topic":"([^"]*)",?.*|\1|p')
message=$(printf '%s' "$line" | sed -nE 's|.*,"message":"([^"]*)",.*|\1|p')
printf '%s' "$line" | grep -q '"open"' && notify "NTFY" "Listening" "$topic"
[ -z "$message" ] || notify "$topic" "${title:-NO TITLE}" "$message"
done
+1 -1
View File
@@ -19,7 +19,7 @@ load() {
ip r
# start sunshine
sunshine > /dev/null
sunshine >/dev/null
}
unload() {
+1 -1
View File
@@ -46,7 +46,7 @@ case $1 in
;;
focus)
#shows the workspace number as notification whenever u switch workspaces and also handles the dual monitor setup on the fly(perfect for laptop users)
socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do
socat -u "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" - | while read -r line; do
printf "%s" "$line" | grep -qE "monitoraddedv2.*HEADLESS" && continue
printf "%s" "$line" | grep -q "monitoraddedv2" && handle_it "$line"
#recent workspace switcher