add hypr / sway startup script

This commit is contained in:
jay 2023-04-17 02:20:22 +08:00
parent c6ce0dd503
commit f69fcdf744
2 changed files with 56 additions and 0 deletions

28
root/usr/local/bin/hypr.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env sh
set -eu
export XDG_CURRENT_DESKTOP=Hyprland # xdg-desktop-portal
export XDG_SESSION_DESKTOP=Hyprland # 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=hypr --user --wait Hyprland $@
systemctl --user stop hypr-session.target
# 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

28
root/usr/local/bin/sway.sh Executable file
View File

@ -0,0 +1,28 @@
#!/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
# 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