dotfiles/root/usr/local/bin/sway-dbus.sh

31 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eu
export XDG_CURRENT_DESKTOP=sway # xdg-desktop-portal
export XDG_SESSION_DESKTOP=sway # systemd
export XDG_SESSION_TYPE=wayland # xdg/systemd
#if command -v dbus-update-activation-environment >/dev/null; then
# dbus-update-activation-environment XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE
#fi
# without this, systemd starts xdg-desktop-portal without these environment variables,
# and the xdg-desktop-portal does not start xdg-desktop-portal-wrl as expected
# https://github.com/emersion/xdg-desktop-portal-wlr/issues/39#issuecomment-638752975
#systemctl --user import-environment XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE
# use systemd-run here, because systemd units inherit variables from ~/.config/environment.d
# shellcheck disable=SC2068
#systemd-run --quiet --unit=sway --user --wait sway $@
#systemctl --user stop sway-session.target
#systemctl --user unset-environment DISPLAY SWAYSOCK WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE
#if command -v dbus-update-activation-environment >/dev/null; then
# dbus-update-activation-environment XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE
#fi
#dbus-launch --exit-with-session sway
dbus-run-session sway
# this teardown makes it easier to switch between compositors
unset DISPLAY SWAYSOCK WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE