refactor(hypr): overhaul some scripts to use systemd-run
This commit is contained in:
parent
2a180b9cd7
commit
529e913d40
@ -4,14 +4,13 @@ source = ~/.config/hypr/wm/bindings.conf
|
|||||||
source = ~/.config/hypr/wm/appearance.conf
|
source = ~/.config/hypr/wm/appearance.conf
|
||||||
source = ~/.config/hypr/wm/monitors.conf
|
source = ~/.config/hypr/wm/monitors.conf
|
||||||
source = ~/.config/hypr/wm/window-rules.conf
|
source = ~/.config/hypr/wm/window-rules.conf
|
||||||
exec-once = ~/.config/hypr/scripts/launchers/events-monitor.bash
|
|
||||||
exec-once = ~/.config/hypr/scripts/launchers/launch-swww.bash
|
|
||||||
exec-once = mako --history 1
|
exec-once = mako --history 1
|
||||||
exec-once = udiskie --tray
|
exec-once = udiskie --tray
|
||||||
exec-once = blueman-applet
|
exec-once = blueman-applet
|
||||||
exec-once = slimbookbattery --minimize
|
exec-once = slimbookbattery --minimize
|
||||||
exec = clight-gui --tray
|
exec = clight-gui --tray
|
||||||
exec = systemd-run --user -u wallpaper-manager ~/.config/hypr/scripts/init-wallpapers.bash || systemctl --user restart wallpaper-manager
|
exec = systemd-run --user --unit=events-monitor ~/.config/hypr/scripts/launchers/events-monitor.bash || systemctl --user restart events-monitor
|
||||||
|
exec = systemd-run --user --unit=wallpapers ~/.config/hypr/scripts/launchers/launch-swww.bash || systemctl --user restart wallpapers
|
||||||
exec-once = xwaylandvideobridge
|
exec-once = xwaylandvideobridge
|
||||||
exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP PATH
|
exec-once = systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP PATH
|
||||||
exec-once = /usr/lib/polkit-kde-authentication-agent-1
|
exec-once = /usr/lib/polkit-kde-authentication-agent-1
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
log() {
|
||||||
|
local monitor="${1}"
|
||||||
|
local msg="${2}"
|
||||||
|
printf "%s: %s\n" "${monitor}" "${msg}"
|
||||||
|
}
|
||||||
|
|
||||||
monitor-dir() {
|
monitor-dir() {
|
||||||
local event="${1}"
|
local event="${1}"
|
||||||
local directory="${2}"
|
local directory="${2}"
|
||||||
@ -20,8 +26,10 @@ monitor-ssid() {
|
|||||||
ssid="$(printf "%s" "${ssid}" | xargs)"
|
ssid="$(printf "%s" "${ssid}" | xargs)"
|
||||||
if [[ "${ssid}" != "${previous_ssid}" ]]; then
|
if [[ "${ssid}" != "${previous_ssid}" ]]; then
|
||||||
if [[ -z "${ssid// /}" ]]; then
|
if [[ -z "${ssid// /}" ]]; then
|
||||||
|
log "SSID" "Wifi Disconnected"
|
||||||
notify-send "${notify_title}" "Wifi Disconnected" -a "${notify_app}"
|
notify-send "${notify_title}" "Wifi Disconnected" -a "${notify_app}"
|
||||||
else
|
else
|
||||||
|
log "SSID" "Wifi Connected to ${ssid}"
|
||||||
notify-send "${notify_title}" "Wifi Connected to ${ssid}" -a "${notify_app}"
|
notify-send "${notify_title}" "Wifi Connected to ${ssid}" -a "${notify_app}"
|
||||||
fi
|
fi
|
||||||
previous_ssid="${ssid}"
|
previous_ssid="${ssid}"
|
||||||
@ -39,14 +47,22 @@ monitor-laptop-lid() {
|
|||||||
case "${laptop_lid_state}" in
|
case "${laptop_lid_state}" in
|
||||||
"CLOSED")
|
"CLOSED")
|
||||||
if hyprctl monitors -j | jq -er '.[] | select(.name=="eDP-1") | .name' >/dev/null; then
|
if hyprctl monitors -j | jq -er '.[] | select(.name=="eDP-1") | .name' >/dev/null; then
|
||||||
hyprctl keyword monitor "eDP-1, disable" >/dev/null && printf "Disabled laptop screen as the laptop was shut\n"
|
printf "Laptop screen was shut, attempting to disable it...\n"
|
||||||
|
if hyprctl keyword monitor "eDP-1, disable"; then
|
||||||
|
local msg="Laptop screen successfully disabled"
|
||||||
|
log "Laptop Clamshell" "${msg}"
|
||||||
|
notify-send "Laptop Clamshell Error" "${msg}" -a "Laptop Clamshell"
|
||||||
|
else
|
||||||
|
local msg="Received an error when disabling the laptop screen in clamshell mode!\n"
|
||||||
|
log "Laptop Clamshell" "${msg}"
|
||||||
|
notify-send "Laptop Clamshell Error" "${msg}" -a "Laptop Clamshell"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
kill -9 "$(pgrep -f "${BASH_SOURCE[0]}" | grep -v "${$}")"
|
|
||||||
monitor-ssid &
|
monitor-ssid &
|
||||||
monitor-laptop-lid &
|
monitor-laptop-lid &
|
||||||
wait
|
wait
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
log() {
|
log() {
|
||||||
printf "%s\n" "${*}"
|
printf "%s\n" "${*}"
|
||||||
systemd-cat -t init-wallpapers -p info echo "${*}"
|
systemd-cat -t wallpaper -p info echo "${*}"
|
||||||
}
|
}
|
||||||
|
|
||||||
get-monitor-wallpaper() {
|
get-monitor-wallpaper() {
|
||||||
@ -23,8 +23,11 @@ set-wallpaper() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set-wallpapers() {
|
set-wallpapers() {
|
||||||
|
log "Setting wallpapers"
|
||||||
### Set default wallpaper ###
|
### Set default wallpaper ###
|
||||||
local default_wallpaper="${HOME}/.dot_files/dots/.local/share/wallpapers/Nebula.jpg"
|
local wallpapers_dir
|
||||||
|
wallpapers_dir="$(realpath "${XDG_DATA_HOME}/wallpapers")"
|
||||||
|
local default_wallpaper="${wallpapers_dir}/Nebula.jpg"
|
||||||
|
|
||||||
# Monitors to not set a default for, to be set later down the script
|
# Monitors to not set a default for, to be set later down the script
|
||||||
local excluded_monitors=("eDP-1")
|
local excluded_monitors=("eDP-1")
|
||||||
@ -38,16 +41,18 @@ set-wallpapers() {
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if "${set_mon_wallpaper}"; then
|
if ${set_mon_wallpaper}; then
|
||||||
set-wallpaper "${monitor}" "${default_wallpaper}"
|
set-wallpaper "${monitor}" "${default_wallpaper}"
|
||||||
fi
|
fi
|
||||||
done < <(hyprctl monitors -j | jq -r '.[].name')
|
done < <(hyprctl monitors -j | jq -r '.[].name')
|
||||||
|
|
||||||
### Set any non defaults ###
|
### Set any non defaults ###
|
||||||
set-wallpaper "eDP-1" "${HOME}/.dot_files/dots/.local/share/wallpapers/Industrial-Shaded.png"
|
set-wallpaper "eDP-1" "${wallpapers_dir}/Industrial-Shaded.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
log "Killing existing swww daemon if an swww daemon is running"
|
||||||
|
swww kill >/dev/null || true
|
||||||
until swww init; do
|
until swww init; do
|
||||||
sleep .1
|
sleep .1
|
||||||
done
|
done
|
||||||
@ -55,7 +60,9 @@ init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
log "Starting up swww!"
|
||||||
init
|
init
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
while IFS= read -r line
|
while IFS= read -r line
|
||||||
do
|
do
|
||||||
@ -65,7 +72,6 @@ main() {
|
|||||||
sleep .1
|
sleep .1
|
||||||
done < <(swww query)
|
done < <(swww query)
|
||||||
sleep .5
|
sleep .5
|
||||||
init
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user