sway: start a session with systemd

* bind waybar to sway.session
* edit zprofile and sway config play nice with systemd
This commit is contained in:
surtur 2021-06-11 23:35:09 +02:00
parent 6647a8f096
commit ef2e74ed8d
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
6 changed files with 47 additions and 7 deletions

View File

@ -58,7 +58,6 @@ exec_always --no-startup-id
}
exec --no-startup-id {
waybar
nm-applet --indicator
lxpolkit
dbus-update-activation-environment DISPLAY XAUTHORITY
@ -473,8 +472,7 @@ bindsym
--locked XF86AudioPrev exec playerctl previous
}
bar {
swaybar_command waybar.sh
}
include /etc/sway/config.d/*
# Export environment to systemd and start services.
exec "systemctl --user import-environment; systemctl --user start sway-session.target"

View File

@ -0,0 +1,6 @@
[Unit]
Description=sway compositor session
Documentation=man:systemd.special(7)
BindsTo=graphical-session.target
Wants=graphical-session-pre.target
After=graphical-session-pre.target

View File

@ -0,0 +1 @@
/home/vis/.config/systemd/user/waybar.service

View File

@ -0,0 +1,16 @@
[Unit]
Description=sway - SirCmpwn's Wayland window manager
# as per https://github.com/swaywm/sway/wiki/Systemd-integration#running-sway-itself-as-a---user-service
Documentation=man:sway(5)
BindsTo=graphical-session.target
Wants=graphical-session-pre.target
After=graphical-session-pre.target
[Service]
Type=simple
EnvironmentFile=-%h/.config/sway/env
ExecStartPre=-source %h/.zprofile
ExecStart=/usr/bin/sway
Restart=on-failure
RestartSec=2
TimeoutStopSec=10

View File

@ -0,0 +1,16 @@
# ~/.config/systemd/user/waybar.service or /etc/systemd/user/waybar.service
[Unit]
Description=Highly customizable Wayland bar for Sway and Wlroots based compositors.
Documentation=https://github.com/Alexays/Waybar/wiki/
#PartOf=graphical-session.target
PartOf=sway-session.target
After=sway-session.target
[Service]
ExecStart=/usr/bin/waybar
# Upstreamed in https://github.com/Alexays/Waybar/pull/1036
ExecReload=kill -SIGUSR2 $MAINPID
Restart=on-failure
[Install]
WantedBy=sway-session.target

View File

@ -58,11 +58,14 @@ if [[ -z $DISPLAY ]]; then
export SDL_VIDEODRIVER=wayland
export NO_AT_BRIDGE=1
export TDESKTOP_USE_PORTAL=1
export XDG_SESSION_TYPE=wayland
if [[ $(tty) == /dev/tty1 ]]; then
export XDG_CURRENT_DESKTOP=sway
exec sway
elif [[ "$(tty)" == "/dev/tty2" ]] && ! ps -e | grep -qw sway
MOZ_ENABLE_WAYLAND=1 QT_QPA_PLATFORM=wayland XDG_SESSION_TYPE=wayland exec dbus-run-session gnome-session
exec systemd-cat --identifier=sway sway
elif [[ $(tty) == /dev/tty2 ]]; then
export MOZ_ENABLE_WAYLAND=1
export XDG_SESSION_TYPE=wayland
exec systemd-cat --identifier=gnome-session gnome
fi
fi