sway: /etc/profile is never sourced when launching sway from GDM
Hi,
I found that when launching Sway from GDM on Archlinux, the /etc/profile file never gets sourced. I’m not sure if this counts as a bug, as the behaviour is the same for other wayland sessions that I tried, like Weston (but not Gnome, for some reason), and its only a problem when launching from a graphical login manager, as otherwise the profile is sourced already (e.g. when logging into a TTY). My sway version:
sway version 1.0-beta.1-157-g994c35e3 (Nov 6 2018, branch 'master')
To verify, you could do something like edit /etc/profile and add export MY_VARIABLE=1 to that file. Then login via GDM with Sway, launch a terminal and check to see if MY_VARIABLE is set. In my tests, it is not.
I have been able to solve this by changing the Exec=sway line in sway.desktop to Exec=bash -l -c sway. This launches a login shell (which sources the profile) and then runs sway inside of the shell. This is enough for my purposes, but I’m not sure if this is the correct way to fix this (or even if this warrants fixing) … at any rate I figured I would report it.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 15 (6 by maintainers)
Links to this issue
Commits related to this issue
- feat: add sway-shell.desktop Due this issue: https://github.com/swaywm/sway/issues/3109 — committed to sparkfabrik/archlinux-ansible-provisioner by paolomainardi 8 months ago
This happens because GDM doesn’t start a shell. This is normal behaviour, and we can’t do anything about it.
Why do you need to source
/etc/profile?Is there any plan to support this officially in any way? Starting out interacting with a new WM by having to manually edit the .desktop file installed by the package manager isn’t the greatest experience. Or is the correct solution to use another login manager - if so, which one?
I feel like this should be supported in some sense because as I understand it,
~/.profileis the standard way to set env vars for all login environments, not just shells. I use it mainly to modify my PATH so that any/all programs installed in~/.local/binwill be available to launch, and I thought this was fairly standard. Not a super drop in replacement fori3if I can’t even launch my app launcher because it’s no longer in my path.Apologies if this is a bit ranting - I appreciate sway existing, and I don’t mean to rag on this one thing. Just a bit annoying to try a new thing & immediately run into a closed issue where the solution is modifying system files installed by sway.
This is a display manager bug. Users logging in via fbcon get their profile sourced, the same should happen when running from a display manager.
FWIW, display managers aren’t officially supported by Sway because of bugs like this.
This shouldn’t matter, because when you run
execin the sway config, a shell is used so the profile is sourced.I thought this
environment.dbased “solution” might be useful in this context. It avoids*profile*altogether: https://github.com/swaywm/sway/issues/5160#issuecomment-645487492I moved all reasonable environment definitions (
PATH(s),EDITOR, etc) in~/.config/environment.d/*.conffiles.Is there any working example? I tried:
Without success.
I am using:
Desktop file:
/usr/local/bin/sway-in-shell:sway-in-shellis more or less a carbon copy of the equivalent GNOME file.