commit 4b1a75d974307d69e9a981a29851ad8a50f1007a parent 2ae51f91d9fa1bd357b39f9b180e8bac4eec6677 Author: Chris Bracken <chris@bracken.jp> Date: Fri, 15 Oct 2021 14:55:52 -0700 sway: make launch script cross-platform Eliminates the assumption on the path of the underlying sway binary, and only launches with systemd support on systemd-enabled systems. Diffstat:
M | .local/bin/sway | | | 16 | +++++++++++++++- |
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/.local/bin/sway b/.local/bin/sway @@ -7,4 +7,18 @@ if [ -f $SWAY_CONFIG_HOME/env ]; then . "$SWAY_CONFIG_HOME/env" fi -exec systemd-cat --identifier sway dbus-run-session -- /usr/bin/sway "$@" +# locate sway binary +for p in /usr/local/bin/sway /usr/bin/sway; do + [ -e "$p" ] && SWAY=/usr/local/bin/sway +done +if [ -z "$SWAY" ]; then + echo "ERROR: unable to locate sway installation" >&2 + exit 1 +fi + +if [ -e "$(which systemd-cat)" ]; then + # If on a systemd-enabled system, connect session output to the journal. + exec systemd-cat --identifier sway dbus-run-session -- /usr/bin/sway "$@" +else + dbus-run-session -- "$SWAY" "$@" +fi