Raspberry Pi autologin in Sway

I’m running Raspberry Pi with Sway. The problem I’m trying to solve is to run automatically Sway and autologin with my user and ultimately run wayvnc at the startup.

I understood how to run wayvnc and in general startup programs at the Sway bootstrap. What it is not clear to me how to solve the autologin thing for Sway. Of course, I’ve already run all the research of the case to setup greetd in autologin but I could not pull a rabbit out of the hat.

The use case here is that I could reboot wherever I am the Raspberry PI and have it once it is up Sway running with wayvnc and be able to get into it via VNC.

This is something I already do. I miss the automated part of the autologin

You might just skip the greetd login dialog. This has been put in place cause the default Sway setup would show you a terminal login prompt…

…as such disable greetd, take care of the auto login working on CLI level and start Sway WM via your .bash_profile…

That should do it IMHO.

Here is a link to an early state of Sway profile running w/o greetd: overlays/sway/etc/skel/.bash_profile · 3ba75d0024c872f4ae7ac415b036798a9f9f8044 · manjaro-arm / applications / arm-profiles · GitLab

I use sway on my laptop and start sway as a user service.
See my user systemd services ~freed00m/dotfiles: .config/systemd/user/ - sourcehut git
There is sway session target and pretarget with the service.

Then I disable all the graphical logging manager and use getty text login manager.
Automatic login to virtual console

It will drop you to text shell and then systemd kicks in with Sway service.

wayvnc could be started in sway config or create a wayvnc --user service :slight_smile:

P.S. I remember issues in raspberry pi 1 that it would not initialize display if no display was connected to it physically.
Maybe it’s non issue now :slight_smile:

1 Like

just thought i would add what i did.
sudo nano /etc/greetd/config.toml
at the bottom put:
command = "sway"
user = "your user name"

1 Like

i’m adding the tty method, this will auto log you in cli & start sway.

  1. sudo systemctl edit getty@tty1

  2. after line 3 copy/paste, replace ‘user’ with your user name:
    ExecStart=-/usr/bin/agetty --autologin user --noclear %I $TERM

  3. add to your ~/.bash_profile
    if [ -z $DISPLAY ] && [ “$(tty)” = “/dev/tty1” ]; then
    exec sway

1 Like

Fairly new to sway here. Thanks for this post.

sway makes desktops seem boring, careful you don’t get carried away with tweaking it.
always back up the file before you edit it.

it’s to late for me, i’ve got it bad, just can’t stop messing with it.
today i messed with colors.