Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
wayland: how to auto-login and auto-launch application?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
roarinelk
Guru
Guru


Joined: 04 Mar 2004
Posts: 513

PostPosted: Thu May 07, 2020 7:21 pm    Post subject: wayland: how to auto-login and auto-launch application? Reply with quote

Hello,

As the topic says: I have a box which runs kodi, and at the moment it uses sddm (used to use lightdm but that broke for some unknown reason) to auto-login the kodi-user on boot and simply runs kodi on X11 as the sole application.
I tried to achieve the same with wayland, but I am stuck.

At the moment I need to log in on a graphical tty (pty's like ssh don't work), start weston by hand, launch the weston shell
and run kodi-wayland from within that shell. I tried bashrc but that didn't work.

Can anyone guide me to an automatic solution for that?

Thanks!
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 2127
Location: Frankfurt, Germany

PostPosted: Thu May 07, 2020 8:01 pm    Post subject: Reply with quote

I can show you a part of the solution.

I log in to a TTY console. After, that I run a script called "start_weston". It starts Weston and additionally a couple of applications:
Code:
#! /bin/bash

# start xeyes in X11 mode
( sleep 1.3; DISPLAY=":0" /usr/bin/xeyes -geometry 111x76-10+0 ) >/dev/null 2>&1 &

# start xload in X11 mode
( sleep 1.5; DISPLAY=":0" /usr/bin/xload -bg gold -fg red -geometry 111x76-10+110 ) >/dev/null 2>&1 &

# start a Weston terminal in Wayland mode
( sleep 1.7; /usr/bin/weston-terminal ) >/dev/null 2>&1 &

# start Weston
/usr/bin/weston-launch -- --log=/tmp/weston.log

Probably not the most elegant method, but it works :)
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 2696
Location: Canada

PostPosted: Fri May 08, 2020 4:13 am    Post subject: Reply with quote

I was under impression that sddm can launch wayland session ?
Back to top
View user's profile Send private message
roarinelk
Guru
Guru


Joined: 04 Mar 2004
Posts: 513

PostPosted: Fri May 08, 2020 10:36 am    Post subject: Reply with quote

dmpogo wrote:
I was under impression that sddm can launch wayland session ?


Ultimately I want to get rid of sddm (or any other display manager) as well, as I don't
really need it (and its comparatively large dependencies).
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 2127
Location: Frankfurt, Germany

PostPosted: Fri May 08, 2020 2:01 pm    Post subject: Reply with quote

  1. Install the 'start_weston' script I showed above in ~/bin. Modify it so that it will start kodi. Make sure it works when you call it manually after you logged in.

  2. Call the script from ~/.bash_profile or ~/.profile. That would start Weston and Kodi directly after you log in. 'bashrc' was the right idea, but unfortunately the wrong configuration file.

  3. If you want Weston and Kodi to be started automatically during system bootup, you could either write a service that calls 'start_weston' or add a script to '/etc/local.d' that calls 'start_weston'.

    The latter is easier, but you can't control at what point during the system bootup your script will be called. Add a script 'weston_kodi' to '/etc/local.d' and make it executable:

    Code:
    #! /bin/bash
    /bin/su - myuser -c bin/start_weston &

    Make sure to replace 'myuser' with the name of the user you are actually using to run Weston and Kodi - and where you installed 'start_weston'. Make sure to remove the calls to 'start_weston' you added to ~/.bash_profile, ~/.profile or bashrc before you do this!

    Writing a service gives you more control and is probably the preferred method. Unfortunately, the way of writing a service depends on the init system you use: Systemd, OpenRC, ...


EDIT: I just tested what I wrote above. (2) works, (3) doesn't work. weston-launch aborts with the error message below if it wasn't stared from a TTY.
Code:
weston: weston-launch must be run from a virtual terminal

It's not sufficient to start Weston and Kodi during system bootup. Weston must be started with a seat / TTY assigned to it - and that's the real challenge. I don't know how to do that. Sorry!
Back to top
View user's profile Send private message
roarinelk
Guru
Guru


Joined: 04 Mar 2004
Posts: 513

PostPosted: Fri May 08, 2020 4:12 pm    Post subject: Reply with quote

mike155 wrote:

EDIT: I just tested what I wrote above. (2) works, (3) doesn't work. weston-launch aborts with the error message below if it wasn't stared from a TTY.
Code:
weston: weston-launch must be run from a virtual terminal

It's not sufficient to start Weston and Kodi during system bootup. Weston must be started with a seat / TTY assigned to it - and that's the real challenge. I don't know how to do that. Sorry!


Servus mike,

I found the "cage" wayland compositor, which runs a single wayland application
in fullscreen and some example systemd services files to attach a service to a tty.
I cobbled this together, it's yet untested though:
Code:

[Unit]
Description=kodi-wayland via Cage compositor
After=getty.target
Conflicts=getty@tty1.service

[Service]
#setze zuerst XDG_RUNTIME_DIR  auf /run/user/`id -u kodi` , evtl in einem shellskript?
User=kodi
Group=users
Type=simple
# cage scheint aber zu fork()en, ohne ein pidfile zu erzeugen
ExecStart=/usr/local/bin/cage /usr/bin/kodi-wayland
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
Restart=always
RestartSec=10s
#RemainAfterExit=yes ## for Type=oneshot

[Install]
WantedBy=graphical.target
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 2127
Location: Frankfurt, Germany

PostPosted: Fri May 08, 2020 5:40 pm    Post subject: Reply with quote

Thanks, roarinelk!

I modified the service file you posted so that it works with Weston. See: https://alan-mushi.github.io/2014/10/26/execute-an-interactive-script-at-boot-with-systemd.html

  1. File: /etc/systemd/system/weston_kodi.service
    Code:
    [Unit]
    Description=kodi-wayland via Weston compositor
    After=getty.target
    Conflicts=getty@tty1.service

    [Service]
    # Uncomment the lines below to run Weston/Kodi as user 'myuser' (recommended)
    User=myuser
    Group=users
    # Uncomment the lines below to run Weston/Kodi as user 'root'
    # User=root
    # Group=root
    ExecStart=/usr/local/bin/start_weston_kodi.sh
    StandardInput=tty
    TTYPath=/dev/tty1
    TTYReset=yes
    TTYVHangup=yes

    # Start Weston/Kodi only once
    Type=oneshot

    # Uncomment the lines below to restart Weston/Kodi after it terminated or crashed
    # Type=simple
    # Restart=always
    # RestartSec=30s

    [Install]
    WantedBy=graphical.target

  2. File: /usr/local/bin/start_weston_kodi.sh, must have mode=0755
    Code:
    #! /bin/bash

    # On some machines, it might be necessary to wait a couple of
    # seconds until system bootup has finished
    # sleep 2

    # Build the environment. Read ~/.bash_profile, ~/.profile, /etc/profile...
    # Add additional environment variables
    source ~/.bash_profile

              TEMP_BASE_DIR="/tmp/temp-${USER}"
    export   XDG_CACHE_HOME="${TEMP_BASE_DIR}/cache"
    export  XDG_RUNTIME_DIR="${TEMP_BASE_DIR}/runtime"
    export XDG_SESSION_TYPE="wayland"
    export  QT_QPA_PLATFORM="wayland-egl"

    # export   LIBVA_DRIVERS_PATH=/usr/lib64/va/drivers
    # export    LIBVA_DRIVER_NAME=i965
    # export QT_QPA_PLATFORMTHEME="qt5ct"

    # switch to temporary directory
    cd /tmp

    # start applications, add a delay so that applications will be started
    # after Weston is up and running

    ( sleep 1.5; DISPLAY=":0" /usr/bin/xeyes -geometry 111x76-10+0 ) >/dev/null 2>&1 &

    ( sleep 1.7; DISPLAY=":0" /usr/bin/xload -bg gold -fg red -geometry 111x76-10+110 ) >/dev/null 2>&1 &

    ( sleep 2; /usr/bin/weston-terminal ) &

    # start Weston
    /usr/bin/weston-launch -- --log=/tmp/weston.log

I tested it and it works. :)
Back to top
View user's profile Send private message
roarinelk
Guru
Guru


Joined: 04 Mar 2004
Posts: 513

PostPosted: Mon May 11, 2020 7:01 pm    Post subject: Reply with quote

@mike155: Thanks. I copied yours as far as possible, but it doesn't work yet.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 2127
Location: Frankfurt, Germany

PostPosted: Tue May 12, 2020 12:59 am    Post subject: Reply with quote

roarinelk wrote:
@mike155: Thanks. I copied yours as far as possible, but it doesn't work yet.

Hmm... What's the problem? What doesn't work?
Back to top
View user's profile Send private message
roarinelk
Guru
Guru


Joined: 04 Mar 2004
Posts: 513

PostPosted: Fri May 15, 2020 11:13 am    Post subject: Reply with quote

mike155 wrote:
roarinelk wrote:
@mike155: Thanks. I copied yours as far as possible, but it doesn't work yet.

Hmm... What's the problem? What doesn't work?


My script works when I run it from a login shell on any tty. But starting it with systemd service
doesn't work, looks like wlroots is looking for a greeter, something is still missing, either in the
environment or somewhere else, but that is probably wlroots related.
Back to top
View user's profile Send private message
roarinelk
Guru
Guru


Joined: 04 Mar 2004
Posts: 513

PostPosted: Fri May 15, 2020 11:47 am    Post subject: Reply with quote

Bah, finally got it working. All I apparently need is a forum post to focus my brain.

So, I created a new systemd service, based on getty@.service, which does autologin
of the kodi user on tty1.
Then edit the .bash_profile of kodi user and at the end add a check for the tty we're
running on, if it's tty1 then start the kodi startup script, otherwise do nothing, so
I can still login via ssh.

works perfectly.
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1778
Location: KUUSANKOSKI, Finland

PostPosted: Fri May 15, 2020 12:10 pm    Post subject: Reply with quote

There's also cage.
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...
Back to top
View user's profile Send private message
roarinelk
Guru
Guru


Joined: 04 Mar 2004
Posts: 513

PostPosted: Fri May 15, 2020 5:08 pm    Post subject: Reply with quote

Zucca wrote:
There's also cage.


Yeah, that's what I was trying to autostart as a user on bootup, without any display manager.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum