From 49d6627ee144695572be92f4a82b40ce51ec6623 Mon Sep 17 00:00:00 2001 From: Ezri Brimhall Date: Thu, 7 Aug 2025 12:15:28 -0600 Subject: [PATCH] updates --- .config/alacritty/alacritty.toml | 2 +- .config/sway/config | 2 +- .config/systemd/user/sway-session-pre.target | 6 ++ .../systemd/user/sway-session-shutdown.target | 4 + .config/systemd/user/sway-session.target | 8 +- .config/zsh/alias.zsh | 2 + .emacs.d/settings.org | 2 +- .local/bin/sway-session-manager.sh | 100 ++++++++++++++++++ 8 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 .config/systemd/user/sway-session-pre.target create mode 100644 .config/systemd/user/sway-session-shutdown.target create mode 100755 .local/bin/sway-session-manager.sh diff --git a/.config/alacritty/alacritty.toml b/.config/alacritty/alacritty.toml index e093224..1f8b535 100644 --- a/.config/alacritty/alacritty.toml +++ b/.config/alacritty/alacritty.toml @@ -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"]} diff --git a/.config/sway/config b/.config/sway/config index 83110bd..16468d3 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -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 # diff --git a/.config/systemd/user/sway-session-pre.target b/.config/systemd/user/sway-session-pre.target new file mode 100644 index 0000000..cfe639e --- /dev/null +++ b/.config/systemd/user/sway-session-pre.target @@ -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 diff --git a/.config/systemd/user/sway-session-shutdown.target b/.config/systemd/user/sway-session-shutdown.target new file mode 100644 index 0000000..0f6e657 --- /dev/null +++ b/.config/systemd/user/sway-session-shutdown.target @@ -0,0 +1,4 @@ +[Unit] +Description=Cleanup tasks for Sway compositor sessions that run after the compositor shuts down +RefuseManualStart=yes +StopWhenUnneeded=yes diff --git a/.config/systemd/user/sway-session.target b/.config/systemd/user/sway-session.target index a6dadf9..72757c5 100644 --- a/.config/systemd/user/sway-session.target +++ b/.config/systemd/user/sway-session.target @@ -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 diff --git a/.config/zsh/alias.zsh b/.config/zsh/alias.zsh index 171abf8..b0925bd 100644 --- a/.config/zsh/alias.zsh +++ b/.config/zsh/alias.zsh @@ -124,3 +124,5 @@ function mkcd { [[ -e $1 ]] || mkdir -p $1 cd $1 } + +alias ppctl='/usr/bin/python3 /usr/bin/powerprofilesctl' diff --git a/.emacs.d/settings.org b/.emacs.d/settings.org index d5facbb..9a1ffa5 100644 --- a/.emacs.d/settings.org +++ b/.emacs.d/settings.org @@ -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 diff --git a/.local/bin/sway-session-manager.sh b/.local/bin/sway-session-manager.sh new file mode 100755 index 0000000..858537a --- /dev/null +++ b/.local/bin/sway-session-manager.sh @@ -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 < [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