complexlogic / flex-launcher

A customizable HTPC application launcher for Windows and Linux
https://complexlogic.github.io/flex-launcher/
The Unlicense
227 stars 13 forks source link

Autostart on GNOME 3.38.5 cannot be focused #5

Closed iainsaxonhome closed 2 years ago

iainsaxonhome commented 2 years ago

Thanks for creating this launcher, its exactly what I've been looking for :) .

I'm trying to get flex-launcher to autostart on Ubuntu 21.04 and the app does start however I am unable to switch to the app, it doesn't respond to inputs and it remains at the top of the window stack preventing other programs from showing other than alt+tab or hot corners.

I think its being started but the GNOME window manager or desktop environment is loaded afterwards. This issue seems similar to having to run feh and conky in the right order to get the expected background behaviour working but that's not what I'm trying to achieve here.

Is there something I need to add to the autostart .desktop file to make flex-launcher run in the foreground?

Background I'm looking for an alternative OS for my HTPC so am considering a simple Ubuntu Server 21.04 install (needed for the libsdl2 version dependency that flex-launcher has that older Ubuntu releases lack) with xorg, flex-launcher and flatpak. Jellyfin and SteamLink are installed via Flatpak and launched via Flex Launcher. GNOME launches without a password and I want Flex Launcher to start and be ready to receive input.

complexlogic commented 2 years ago

Thanks for the report. It is my understanding that Ubuntu 21.04 defaults to Wayland session, except for systems with NVIDIA graphics. Could you confirm that your GNOME desktop is running via Wayland?

iainsaxonhome commented 2 years ago

According to the Settings app -> About it is Wayland and I'm seeing lots of Wayland references in the /usr/share and htop.

Although I'm running an Nvidia GPU on the host system the guest probably isn't aware of this as I haven't altered any video settings yet.

complexlogic commented 2 years ago

OK. I was able to reproduce your issue. The root of the problem is that SDL still tries to use X11 by default for Linux. If the Wayland compositor has an XWayland connection available, SDL will try to use that instead of native Wayland. In regard to the window focus issue, I'm guessing there is some bug with GNOME/Mutter's XWayland implementation. You can use the environment variable SDL_VIDEODRIVER=wayland to force SDL to choose native Wayland over XWayland. Here is a desktop file that you can use for autostart:

[Desktop Entry]
Version=1.5
Type=Application
Name=Flex Launcher
GenericName=Application Launcher
Comment=Customizable HTPC Application Launcher
TryExec=flex-launcher
Exec=env SDL_VIDEODRIVER=wayland flex-launcher
Icon=flex-launcher
Categories=Video;AudioVideo;

Setting that fixes the focus issue for me.

However, running Flex Launcher in Wayland, you will likely encounter a different bug. When launching a program, you get stuck in an infinite loop where the program restarts immediately after you exit it. I believe this is due to a bug in SDL's Wayland implementation. It seems that SDL is sending erroneous repeat key presses, which causes the loop. I can add a workaround to ignore the repeated keypresses in the launcher, but I was hoping to report this to the SDL devs first to get it fixed at the source.

I think the best option for the time being is just to run Xorg, unless you really need Wayland for some reason. In my opinion, Wayland in it's current state provides little benefit for a simple device such as an HTPC. You can switch to Xorg by opening the file at /etc/gdm/custom.conf and uncommenting the line

WaylandEnable=false
iainsaxonhome commented 2 years ago

Thank you very much :) . I'll try this as soon as I get a chance!

iainsaxonhome commented 2 years ago

Sorry for the delay. Using Xorg worked and resolved the issue :) .

Closing issue ;) .