From 721391371fcd8b2ba2fc4b209add30d416270bdb Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Tue, 10 Oct 2023 10:31:43 +0200 Subject: [PATCH] fix xdg-desktop-portol for sway --- .chezmoitemplates/zprofile_linux.tmpl | 33 +++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/.chezmoitemplates/zprofile_linux.tmpl b/.chezmoitemplates/zprofile_linux.tmpl index cd3962a..9155c4b 100644 --- a/.chezmoitemplates/zprofile_linux.tmpl +++ b/.chezmoitemplates/zprofile_linux.tmpl @@ -1,3 +1,15 @@ +__dotfiles_wayland_teardown() { + # true: as long as we try it's okay + #systemctl --user stop sway-session.target || true + + # this teardown makes it easier to switch between compositors + unset DISPLAY SWAYSOCK WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_DESKTOP XDG_SESSION_TYPE + 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 +} + if [[ -z $DISPLAY && $(tty) == /dev/tty1 && $XDG_SESSION_TYPE == tty ]]; then # Lade die Bootparameter in den Variablen for wort in $(cat /proc/cmdline) @@ -34,9 +46,8 @@ if [[ -z $DISPLAY && $(tty) == /dev/tty1 && $XDG_SESSION_TYPE == tty ]]; then export PATH="$PATH:/home/${USER}/.local/bin/" export PATH="$PATH:/home/${USER}/go/bin/" - export PATH="$PATH:/home/${USER}/.local/share/flatpak/exports/bin/" - export XDG_DATA_DIRS="/usr/share/:/usr/local/share/:/var/lib/flatpak/exports/share/:/home/${USER}/.local/share/flatpak/exports/share/" + export XDG_DATA_DIRS="/usr/share/:/usr/local/share/" # Added by Toolbox App export PATH="$PATH:/home/${USER}/.local/share/JetBrains/Toolbox/scripts" @@ -57,6 +68,8 @@ if [[ -z $DISPLAY && $(tty) == /dev/tty1 && $XDG_SESSION_TYPE == tty ]]; then elif [ "${autostartdesktop}" = "gnome" ]; then MOZ_ENABLE_WAYLAND=1 QT_QPA_PLATFORM=wayland XDG_SESSION_TYPE=wayland exec dbus-run-session gnome-session else + __dotfiles_wayland_teardown + export QT_QPA_PLATFORM=wayland export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" export GDK_BACKEND=wayland @@ -77,6 +90,22 @@ if [[ -z $DISPLAY && $(tty) == /dev/tty1 && $XDG_SESSION_TYPE == tty ]]; then export PAN_MESA_DEBUG=gl3 #Fix alacritty not starting export MOZ_ENABLE_WAYLAND=1 # Fix firefox not starting + 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 + # true: ignore errors here so we always do the teardown afterwards + # shellcheck disable=SC2068 + systemd-run --quiet --unit=sway --user --wait sway $@ || true + + __dotfiles_wayland_teardown + #export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:~/.local/lib/ #XDG_CURRENT_DESKTOP=sway dbus-run-session sway