From a3f30cf228384bf3de12858dbfb5bad340397339 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 24 Feb 2025 16:59:02 +0100 Subject: [PATCH] services: Add desktop environment programs as user services Added a runit-managed kanshi, swaybg, waybar, wl-paste and wlsunset service. --- desktop/.config/river/init | 57 +++++++++++++++++++----------------- services/sv/kanshi/log/run | 3 ++ services/sv/kanshi/run | 6 ++++ services/sv/swaybg/log/run | 3 ++ services/sv/swaybg/run | 6 ++++ services/sv/waybar/log/run | 3 ++ services/sv/waybar/run | 6 ++++ services/sv/wl-paste/log/run | 3 ++ services/sv/wl-paste/run | 8 +++++ services/sv/wlsunset/log/run | 3 ++ services/sv/wlsunset/run | 16 ++++++++++ 11 files changed, 87 insertions(+), 27 deletions(-) create mode 100755 services/sv/kanshi/log/run create mode 100755 services/sv/kanshi/run create mode 100755 services/sv/swaybg/log/run create mode 100755 services/sv/swaybg/run create mode 100755 services/sv/waybar/log/run create mode 100755 services/sv/waybar/run create mode 100755 services/sv/wl-paste/log/run create mode 100755 services/sv/wl-paste/run create mode 100755 services/sv/wlsunset/log/run create mode 100755 services/sv/wlsunset/run diff --git a/desktop/.config/river/init b/desktop/.config/river/init index 2fe5be3..8cd7000 100755 --- a/desktop/.config/river/init +++ b/desktop/.config/river/init @@ -303,39 +303,43 @@ done setxkbmap -option "compose:menu" -# start dynamic display configuration -should_start kanshi && riverctl spawn kanshi +# We are not in voidlinux, so no nice turnstile user services will take care of us +# have to start everything manually here. +if ! cat /etc/*-release | grep -q '^NAME=.*Void'; then + # start dynamic display configuration + should_start kanshi && riverctl spawn kanshi -# set a nice wallpaper -if exist swaybg; then - killall swaybg - riverctl spawn "swaybg \ + # set a nice wallpaper + if command -v swaybg >/dev/null 2>&1; then + killall swaybg + riverctl spawn "swaybg \ -o 'LG Electronics W2442 0x000574E1' -i pictures/wall_l.jpg \ -o 'LG Electronics W2442 0x000574FD' -i pictures/wall_r.jpg \ " -elif exist swww; then - riverctl spawn "swww-daemon" - outputs=$(swww query | cut -d':' -f1) - if [ "$(echo "$outputs" | grep -c -e '^DP')" -eq 2 ] && [ -e "$HOME/pictures/wall_r.jpg" ]; then - swww img -o "$(echo "$outputs" | head -n1)" "$HOME/pictures/wall_l.jpg" - swww img -o "$(echo "$outputs" | tail -n1)" "$HOME/pictures/wall_r.jpg" - elif [ -e "$HOME/pictures/wall.jpg" ]; then - swww img "$HOME/pictures/wall.jpg" + elif command -v swww >/dev/null 2>&1; then + riverctl spawn "swww-daemon" + outputs=$(swww query | cut -d':' -f1) + if [ "$(echo "$outputs" | grep -c -e '^DP')" -eq 2 ] && [ -e "$HOME/pictures/wall_r.jpg" ]; then + swww img -o "$(echo "$outputs" | head -n1)" "$HOME/pictures/wall_l.jpg" + swww img -o "$(echo "$outputs" | tail -n1)" "$HOME/pictures/wall_r.jpg" + elif [ -e "$HOME/pictures/wall.jpg" ]; then + swww img "$HOME/pictures/wall.jpg" + fi fi -fi -# start status bar -should_start waybar && riverctl spawn waybar - -# start redshift-like sundown warming using current location or standard values -if should_start wlsunset; then - loc=$(curl ipinfo.io | grep -e '"loc": ' | sed -e 's/^.*"loc": "\(.*\)",$/\1/') - if [ -n "$loc" ]; then - riverctl spawn "wlsunset -l \"$(echo "$loc" | cut -d, -f1)\" -L \"$(echo "$loc" | cut -d, -f2)\"" - else - riverctl spawn "wlsunset -S \"09:00\" -s \"21:00\" -d \"3600\"" + should_start waybar && riverctl spawn waybar + # + # start redshift-like sundown warming using current location or standard values + if should_start wlsunset; then + loc=$(curl ipinfo.io | grep -e '"loc": ' | sed -e 's/^.*"loc": "\(.*\)",$/\1/') + if [ -n "$loc" ]; then + riverctl spawn "wlsunset -l \"$(echo "$loc" | cut -d, -f1)\" -L \"$(echo "$loc" | cut -d, -f2)\"" + else + riverctl spawn "wlsunset -S \"09:00\" -s \"21:00\" -d \"3600\"" + fi + unset loc fi - unset loc + fi # start screen idle locking/dimming/sleep tool @@ -347,7 +351,6 @@ should_start swayidle && riverctl spawn "swayidle \ after-resume \"wlopm --on '*'\" \ before-sleep \"pidof waylock || lockscreen\" &" -should_start wl-paste && riverctl spawn "wl-paste -t text --watch clipman store" # bash ~/.config/bin/gtktheme # setting our gtk variables # killall polkit-gnome-authentication-agent-1 # /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 & diff --git a/services/sv/kanshi/log/run b/services/sv/kanshi/log/run new file mode 100755 index 0000000..a990425 --- /dev/null +++ b/services/sv/kanshi/log/run @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec vlogger -t kanshi -p daemon diff --git a/services/sv/kanshi/run b/services/sv/kanshi/run new file mode 100755 index 0000000..678f984 --- /dev/null +++ b/services/sv/kanshi/run @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -r ./conf ] && . ./conf + +exec 2>&1 +exec chpst -e "$TURNSTILE_ENV_DIR" kanshi diff --git a/services/sv/swaybg/log/run b/services/sv/swaybg/log/run new file mode 100755 index 0000000..6bd23ce --- /dev/null +++ b/services/sv/swaybg/log/run @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec vlogger -t swaybg -p daemon diff --git a/services/sv/swaybg/run b/services/sv/swaybg/run new file mode 100755 index 0000000..15d96b1 --- /dev/null +++ b/services/sv/swaybg/run @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -r ./conf ] && . ./conf + +exec 2>&1 +exec chpst -e "$TURNSTILE_ENV_DIR" swaybg -o "LG Electronics W2442 0x000574E1" -i "$HOME/pictures/wall_l.jpg" -o "LG Electronics W2442 0x000574FD" -i "$HOME/pictures/wall_r.jpg" diff --git a/services/sv/waybar/log/run b/services/sv/waybar/log/run new file mode 100755 index 0000000..1ff5833 --- /dev/null +++ b/services/sv/waybar/log/run @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec vlogger -t waybar -p daemon diff --git a/services/sv/waybar/run b/services/sv/waybar/run new file mode 100755 index 0000000..31b6db6 --- /dev/null +++ b/services/sv/waybar/run @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -r ./conf ] && . ./conf + +exec 2>&1 +exec chpst -e "$TURNSTILE_ENV_DIR" waybar diff --git a/services/sv/wl-paste/log/run b/services/sv/wl-paste/log/run new file mode 100755 index 0000000..2b14950 --- /dev/null +++ b/services/sv/wl-paste/log/run @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec vlogger -t wl-paste -p daemon diff --git a/services/sv/wl-paste/run b/services/sv/wl-paste/run new file mode 100755 index 0000000..c37dd4f --- /dev/null +++ b/services/sv/wl-paste/run @@ -0,0 +1,8 @@ +#!/bin/sh + +[ -r ./conf ] && . ./conf + +echo "Service wl-paste starting..." + +exec 2>&1 +exec chpst -e "$TURNSTILE_ENV_DIR" wl-paste -t text --watch clipman store diff --git a/services/sv/wlsunset/log/run b/services/sv/wlsunset/log/run new file mode 100755 index 0000000..ce79f49 --- /dev/null +++ b/services/sv/wlsunset/log/run @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec vlogger -t wlsunset -p daemon diff --git a/services/sv/wlsunset/run b/services/sv/wlsunset/run new file mode 100755 index 0000000..a35f6b0 --- /dev/null +++ b/services/sv/wlsunset/run @@ -0,0 +1,16 @@ +#!/bin/sh + +[ -r ./conf ] && . ./conf + +TIME_OPTS='-S \"09:00\" -s \"21:00\" -d \"3600\"' +if command -v curl >/dev/null 2>&1; then + loc=$(curl -s ipinfo.io | grep -e '"loc": ' | sed -e 's/^.*"loc": "\(.*\)",$/\1/') + if [ -n "$loc" ]; then + lat="$(echo "$loc" | cut -d, -f1)" + long="$(echo "$loc" | cut -d, -f2)" + TIME_OPTS="-l \"$lat\" -L \"$long\"" + fi +fi + +exec 2>&1 +exec chpst -e "$TURNSTILE_ENV_DIR" wlsunset $TIME_OPTS "$@"