This commit is contained in:
Ezri Brimhall 2025-08-07 12:15:28 -06:00
parent e80d9d797c
commit 49d6627ee1
Signed by: ezri
GPG Key ID: 058A78E5680C6F24
8 changed files with 120 additions and 6 deletions

View File

@ -66,4 +66,4 @@ opacity = 0.8
title = "Terminal"
[terminal]
shell = { program = "/usr/bin/systemd-run", args = [ "--user", "--scope", "--slice=shells.slice", "--property=PartOf=alacritty.service", "--property=After=alacritty.service", "--slice-inherit", "-S", "-q"]}
#shell = { program = "/usr/bin/systemd-run", args = [ "--user", "--scope", "--slice=app-shell.slice", "--property=PartOf=alacritty.service", "--property=After=alacritty.service", "-S", "-q"]}

View File

@ -260,7 +260,7 @@ include input.conf
# Service Management #
### ###
exec ~/.local/lib/voidshell/sway-systemd-start.sh
exec exec ~/.local/bin/sway-session-manager.sh setup
### ###
# Generic Local Configuration #

View File

@ -0,0 +1,6 @@
[Unit]
Description=Sway session services which should run early before the graphical session is brought up
Documentation=man:systemd.special(7)
Requires=basic.target
RefuseManualStart=yes
StopWhenUnneeded=yes

View File

@ -0,0 +1,4 @@
[Unit]
Description=Cleanup tasks for Sway compositor sessions that run after the compositor shuts down
RefuseManualStart=yes
StopWhenUnneeded=yes

View File

@ -1,6 +1,8 @@
[Unit]
Description=Sway compositor session
Documentation=man:systemd.special
Documentation=man:systemd.special(7)
BindsTo=graphical-session.target
Wants=graphical-session-pre.target
After=graphical-session-pre.target
Wants=sway-session-pre.target
After=sway-session-pre.target
RefuseManualStart=yes
StopWhenUnneeded=yes

View File

@ -124,3 +124,5 @@ function mkcd {
[[ -e $1 ]] || mkdir -p $1
cd $1
}
alias ppctl='/usr/bin/python3 /usr/bin/powerprofilesctl'

View File

@ -150,7 +150,7 @@ Indent using tabs, render with tab-width of 2.
(defun irc-setup ()
(if irc-configured (message "IRC configured.") (do-irc-setup)))
(add-hook 'after-make-frame-functions 'irc-setup)
;; (add-hook 'after-make-frame-functions 'irc-setup)
(irc-setup)
#+END_SRC

View File

@ -0,0 +1,100 @@
#!/usr/bin/env zsh
export XDG_CURRENT_DESKTOP=sway
export XDG_SESSION_DESKTOP="${XDG_SESSION_DESKTOP:-sway}"
export XDG_SESSION_TYPE=wayland
VARIABLES="DESKTOP_SESSION XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE"
VARIABLES="${VARIABLES} DISPLAY I3SOCK SWAYSOCK WAYLAND_DISPLAY"
VARIABLES="${VARIABLES} XCURSOR_THEME XCURSOR_SIZE"
SESSION_TARGET="sway-session.target"
SESSION_SHUTDOWN_TARGET="sway-session-shutdown.target"
SWAY_UNIT="sway.scope"
print_usage() {
cat <<EOF
Usage: $0 <setup|cleanup> [ARGS]
--help Show this help message and exit.
--add-env=NAME, -E NAME
Add an variable to the environment imported into
systemd and purged on exit.
setup Perform sway session systemd setup. This will fail
if the command is not run as a child of 'sway' (via
an 'exec' or 'exec_always' directive or command).
cleanup Meant to be called by the service manager as a part
of sway-session-shutdown.target.
EOF
}
while [ $# -gt 0 ]; do
case "$1" in
--help)
print_usage
exit 0 ;;
--add-env=?*)
VARIABLES="${VARIABLES} ${1#*=}" ;;
--add-env | -E)
shift
VARIABLES="${VARIABLES} ${1}" ;;
cleanup)
TASK=cleanup ;;
setup)
TASK=setup ;;
-*)
echo "Unexpected option: $1" >&2
print_usage
exit 1 ;;
*)
break ;;
esac
shift
done
function setup() {
# Get process stack
ppid=$(ps -o ppid= $$ | sed 's/ //g')
ppcomm=$(ps -o comm= $ppid)
if [[ $ppcomm == 'sh' ]]; then
# sway exec command (a shell) forked before exec, get its parent
ppid=$(ps -o ppid= $ppid | sed 's/ //g')
ppcomm=$(ps -o comm= $ppid)
fi
if ! [[ $ppcomm == 'sway' ]]; then
echo "Error: attempting to run setup while not invoked by sway!"
exit 2
fi
# Reset failed units
systemctl --user reset-failed
# Import environment
echo $VARIABLES | xargs -- systemctl --user import-environment
echo $VARIABLES | xargs -- dbus-update-activation-environment
# Load scope unit
busctl --user call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager StartTransientUnit 'ssa(sv)a(sa(sv))' \
"$SWAY_UNIT" \
fail \
7 \
PIDs au 1 $ppid \
Slice s session.slice \
Wants as 1 $SESSION_TARGET \
Before as 1 $SESSION_TARGET \
PropagatesStopTo as 1 $SESSION_TARGET \
OnSuccess as 1 $SESSION_SHUTDOWN_TARGET \
OnFailure as 1 $SESSION_SHUTDOWN_TARGET \
0
}
function cleanup() {
systemctl --user unset-environment $VARIABLES
}
case $TASK in
setup)
setup ;;
cleanup)
cleanup ;;
esac