Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Flatpak release incomplete, autostart, resolution change and permissions broken #1352

Closed
3 tasks done
3sv opened this issue Jun 4, 2023 · 7 comments
Closed
3 tasks done
Labels

Comments

@3sv
Copy link

3sv commented Jun 4, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your issue described in the documentation?

  • I have read the documentation

Is your issue present in the nightly release?

  • This issue is present in the nightly release

Describe the Bug

With the Flatpak release, auto-start is not possible by default, and permissions are unclear.
Documentation mentions that is preferred to install as root, but then systemd user service runs as normal user.

The example start line is "sudo -i PULSE_SERVER=unix:$(pactl info | awk '/Server String/{print$3}') flatpak run dev.lizardbyte.sunshine" requiring manually starting it and entering password every time.

Additionally the default application for normal and high quality are not working either from the flatpak version.

Expected Behavior

Easy waty to start/stop and use the flatpak release. (Seems to be the best option for most distributions, tested on Fedora 37 myself)

Additional Context

As a test to improve the situation, I created the following improvements, but not there yet completely.

Created /usr/local/bin/sunshine:

#!/bin/bash

if [ -n "$1" ]; then
        /usr/bin/flatpak kill dev.lizardbyte.sunshine
else
    	PULSE_SERVER=unix:$(pactl info | awk '/Server String/{print$3}') flatpak run dev.lizardbyte.sunshine
fi

Changed ~/.config/systemd/user/sunshine.service to:

[Unit]
Description=Sunshine is a self-hosted game stream host for Moonlight.
PartOf=graphical-session.target
StartLimitIntervalSec=500
StartLimitBurst=20
Wants=default.target
After=default.target

[Service]
ExecStart=/usr/bin/sudo /usr/local/bin/sunshine
NoNewPrivileges=false
Type=simple
Restart=on-failure
RestartSec=10s
ExecStop=/usr/bin/sudo /usr/local/bin/sunshine --stop


[Install]
WantedBy=default.target

Added these lines to visudo:
USERNAME ALL= NOPASSWD: /usr/local/bin/sunshine

Tested also with graphical-session.target instead of default.target, but both don't give auto-start after enabling:
systemctl --user enable sunshine

Manually executing start/stop works fine now as user without the need to enter password:

 systemctl --user start sunshine
 and 
 systemctl --user stop sunshine 

works fine with these changes now.

Don't understand why its still not auto-starting upon user login? What I'm missing here?

For the resolution change, I would like to have 2 applications, 1 offering a 4K stream, and 1 offering a 2K stream with wayland on gnome.

I created the following scripts that allow changing the resolution of the system unattended:

sudo dnf install ydotool
sudo systemctl --user enable --now ydotool

/home/dries/Apps/Scripts/2k.sh

#!/bin/bash

/home/dries/.cargo/bin/gnome-randr modify -p --mode [email protected] --scale 1 HDMI-3 && sleep 1 && ydotool key 28:1 28:0

/home/dries/Apps/Scripts/4k.sh

#!/bin/bash

/home/dries/.cargo/bin/gnome-randr modify -p --mode [email protected] --scale 2 HDMI-3 && sleep 1 && ydotool key 28:1 28:0

However I still fail to execute these script from within the flatpak sandbox.
I changed the settings with Flatseal to give access to these scripts:
Screenshot from 2023-06-04 11-47-39

But somehow this isn't enough to start these scripts from within sunshine:
Screenshot from 2023-06-04 11-58-12

Any ideas what I'm missing here to get it started from within sunshine flatpak?

Additionally, can my attempts to improve the flatpak installation be added to the flatpak installer somehow? Or can an alternative be added that would result in the same improved user experience that would allow for auto-start from userspace but running with sudo/root privileges as the actual user? Could the scripts for resolution change be integrated somehow?

As a sidenote: I discoceverd this project because my son is gaming, and really like the project. In such a way that I'm trying to use it for every day general remote desktop, as it is the best remote desktop solution with hardware acceleration support and delivering an amazing capable desktop as if you would be working locally! despite other generic remote desktop solutions were typical the hardware acceleration is missing, and such high resolution and low latencies are not reachable at all.

Host Operating System

Linux

Operating System Version

Linux, Fedora 37 Flatpak

Architecture

64 bit

Sunshine commit or version

0.20.0

Package

Linux - flatpak

GPU Type

Nvidia

GPU Model

amdgpu,nouveau

GPU Driver/Mesa Version

23.0.3

Capture Method (Linux Only)

KVM

Config

fps = [30,60]
resolutions = [
    1920x1080,
    3840x2160
]

Apps

{
    "env": {
        "PATH": "$(PATH):$(HOME)\/.local\/bin"
    },
    "apps": [
        {
            "name": "Desktop",
            "image-path": "desktop.png",
            "prep-cmd": [
                {
                    "do": "\/home\/dries\/Apps\/Scripts\/4k.sh",
                    "undo": ""
                },
                {
                    "do": "",
                    "undo": ""
                },
                {
                    "do": "",
                    "undo": ""
                }
            ],
            "exclude-global-prep-cmd": "false",
            "working-dir": ""
        },
        {
            "name": "Low Res Desktop",
            "image-path": "desktop.png",
            "prep-cmd": [
                {
                    "do": "\/home\/dries\/Apps\/Scripts\/2k.sh",
                    "undo": ""
                }
            ],
            "exclude-global-prep-cmd": "false",
            "working-dir": ""
        },
        {
            "name": "Steam Big Picture",
            "detached": [
                "flatpak-spawn --host setsid steam steam:\/\/open\/bigpicture"
            ],
            "image-path": "steam.png"
        }
    ]
}

Relevant log output

[2023:06:04:11:56:40]: Info: Sunshine version: 0.20.0
[2023:06:04:11:56:40]: Error: Couldn't load cuda: -1
[2023:06:04:11:56:40]: Warning: Couldn't expose some properties for card: /dev/dri/card0
[2023:06:04:11:56:40]: Error: Environment variable WAYLAND_DISPLAY has not been defined
[2023:06:04:11:56:40]: Info: Detecting monitors
[2023:06:04:11:56:40]: Info: Detected monitor 0: XWAYLAND0, connected: true
[2023:06:04:11:56:40]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2023:06:04:11:56:40]: Info: Trying encoder [nvenc]
[2023:06:04:11:56:40]: Info: Screencasting with KMS
[2023:06:04:11:56:40]: Info: Found monitor for DRM screencasting
[2023:06:04:11:56:40]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:56:40]: Info: Color range: [JPEG]
[2023:06:04:11:56:40]: Error: Failed to create a CUDA device: Operation not permitted
[2023:06:04:11:56:40]: Info: Screencasting with KMS
[2023:06:04:11:56:40]: Info: Found monitor for DRM screencasting
[2023:06:04:11:56:40]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:56:40]: Info: Color range: [JPEG]
[2023:06:04:11:56:40]: Error: Failed to create a CUDA device: Operation not permitted
[2023:06:04:11:56:40]: Info: Screencasting with KMS
[2023:06:04:11:56:40]: Info: Found monitor for DRM screencasting
[2023:06:04:11:56:40]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:56:40]: Info: Color range: [JPEG]
[2023:06:04:11:56:40]: Error: Failed to create a CUDA device: Operation not permitted
[2023:06:04:11:56:40]: Info: Screencasting with KMS
[2023:06:04:11:56:40]: Info: Found monitor for DRM screencasting
[2023:06:04:11:56:40]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:56:40]: Info: Color range: [JPEG]
[2023:06:04:11:56:40]: Error: Failed to create a CUDA device: Operation not permitted
[2023:06:04:11:56:40]: Info: Encoder [nvenc] failed
[2023:06:04:11:56:40]: Info: Trying encoder [vaapi]
[2023:06:04:11:56:40]: Info: Screencasting with KMS
[2023:06:04:11:56:40]: Info: Found monitor for DRM screencasting
[2023:06:04:11:56:40]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:56:40]: Info: Color range: [JPEG]
[2023:06:04:11:56:40]: Info: Screencasting with KMS
[2023:06:04:11:56:40]: Info: Found monitor for DRM screencasting
[2023:06:04:11:56:40]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:56:40]: Info: Color range: [JPEG]
[2023:06:04:11:56:40]: Info: Screencasting with KMS
[2023:06:04:11:56:40]: Info: Found monitor for DRM screencasting
[2023:06:04:11:56:40]: Info: SDR color coding [Rec. 709]
[2023:06:04:11:56:40]: Info: Color range: [JPEG]
[2023:06:04:11:56:40]: Warning: vaapi: hevc missing sps->vui parameters
[2023:06:04:11:56:40]: Info: 
[2023:06:04:11:56:40]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2023:06:04:11:56:40]: Info: 
[2023:06:04:11:56:40]: Info: Found encoder vaapi: [h264_vaapi, hevc_vaapi]
[2023:06:04:11:56:40]: Info: Configuration UI available at [https://localhost:47990]
[2023:06:04:11:56:40]: Info: Adding avahi service Sunshine
[2023:06:04:11:56:41]: Info: Avahi service Sunshine successfully established.
[2023:06:04:11:56:49]: Info: Web UI: [127.0.0.1] -- not authorized
[2023:06:04:11:57:15]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2023:06:04:11:57:15]: Info: Trying encoder [nvenc]
[2023:06:04:11:57:15]: Info: Screencasting with KMS
[2023:06:04:11:57:15]: Info: Found monitor for DRM screencasting
[2023:06:04:11:57:15]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:57:15]: Info: Color range: [JPEG]
[2023:06:04:11:57:15]: Error: Failed to create a CUDA device: Operation not permitted
[2023:06:04:11:57:15]: Info: Screencasting with KMS
[2023:06:04:11:57:15]: Info: Found monitor for DRM screencasting
[2023:06:04:11:57:15]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:57:15]: Info: Color range: [JPEG]
[2023:06:04:11:57:15]: Error: Failed to create a CUDA device: Operation not permitted
[2023:06:04:11:57:15]: Info: Encoder [nvenc] failed
[2023:06:04:11:57:15]: Info: Trying encoder [vaapi]
[2023:06:04:11:57:15]: Info: Screencasting with KMS
[2023:06:04:11:57:15]: Info: Found monitor for DRM screencasting
[2023:06:04:11:57:15]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:57:15]: Info: Color range: [JPEG]
[2023:06:04:11:57:15]: Info: Screencasting with KMS
[2023:06:04:11:57:15]: Info: Found monitor for DRM screencasting
[2023:06:04:11:57:15]: Info: SDR color coding [Rec. 601]
[2023:06:04:11:57:15]: Info: Color range: [JPEG]
[2023:06:04:11:57:15]: Info: Screencasting with KMS
[2023:06:04:11:57:15]: Info: Found monitor for DRM screencasting
[2023:06:04:11:57:15]: Info: SDR color coding [Rec. 709]
[2023:06:04:11:57:15]: Info: Color range: [JPEG]
[2023:06:04:11:57:15]: Warning: vaapi: hevc missing sps->vui parameters
[2023:06:04:11:57:15]: Info: 
[2023:06:04:11:57:15]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2023:06:04:11:57:15]: Info: 
[2023:06:04:11:57:15]: Info: Found encoder vaapi: [h264_vaapi, hevc_vaapi]
[2023:06:04:11:57:15]: Info: Executing Do Cmd: [/home/dries/Apps/Scripts/4k.sh]
[2023:06:04:11:57:15]: Error: Couldn't run [/home/dries/Apps/Scripts/4k.sh]: System: No such file or directory
@paju1986
Copy link

paju1986 commented Jul 7, 2023

same issues here, there is no way of autostart the flatpak on wayland, it needs sudo.

@pacjo
Copy link

pacjo commented Jul 7, 2023

It's not the best practice from security standpoint, but you can echo your password into sudo command like this:

echo "your password" | sudo -S -i PULSE_SERVER [...]

you have to add -S to sudo, otherwise it won't work

This is the way I got autostart working, but that doesn't really matter for me until #93 is fixed.

@ReenigneArcher
Copy link
Member

Since linux generally saves your command history, that is really not a good idea.

Better to just make it so you don't need a password for specific commands. https://askubuntu.com/a/159009

@pacjo
Copy link

pacjo commented Jul 11, 2023

@ReenigneArcher
Oh. Where does it save the history? I'm aware of .bash_history and similar, but I didn't know a "global" history existed too. I don't have history of this command in either .bash_history or .zsh_history

@LizardByte-bot
Copy link
Member

LizardByte-bot commented Oct 9, 2023

👋 @3sv , It seems this issue hasn't had any activity in the past 90 days. If it's still something you'd like addressed, please let us know by leaving a comment. Otherwise, to help keep our backlog tidy, we'll be closing this issue in 10 days. Thanks!

@LizardByte-bot LizardByte-bot added stale and removed stale labels Oct 9, 2023
@LizardByte-bot
Copy link
Member

It seems this issue hasn't had any activity in the past 90 days. If it's still something you'd like addressed, please let us know by leaving a comment. Otherwise, to help keep our backlog tidy, we'll be closing this issue in 10 days. Thanks!

@LizardByte-bot
Copy link
Member

This issue was closed because it has been stalled for 10 days with no activity.

@LizardByte-bot LizardByte-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants