Skip to content

Commit

Permalink
wiki updates for flatpak stuff (#2401)
Browse files Browse the repository at this point in the history
* wiki updates for flatpak stuff

* explain difference between native and flatpak steam more clearly

* give examples of using hybrid graphics with other fixes

* notes about wlx-overlay-s testing

---------

Co-authored-by: failboat78 <[email protected]>
  • Loading branch information
failboat78 and failboat78 authored Sep 24, 2024
1 parent 1cbb133 commit 4d0d0ce
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 150 deletions.
95 changes: 1 addition & 94 deletions alvr/xtask/flatpak/README.md
Original file line number Diff line number Diff line change
@@ -1,94 +1 @@
# ALVR Launcher Flatpak

This is an experimental Flatpak for ALVR Launcher! It is **only** compatible with the Flatpak version of Steam! For all non-Flatpak Steam users, use the non-flatpak launcher that is already provided.

## Installation

Currently, no precompiled builds are available. However, building from source does not take very long, and just requires the usage of the terminal.

1. Install the Flatpak dependencies

```
flatpak install flathub org.flatpak.Builder org.freedesktop.Sdk//23.08
```

2. Clone and enter this repository

```
git clone https://github.com/alvr-org/ALVR.git
cd ALVR
```

3. Build and install the flatpak via the provided script

```
cd alvr/xtask/flatpak
./build_and_install.sh
```

## Usage

Because this is an extension we can't write our xdg shortcut into steams folder - it is read-only.
Thus the launcher has to be run manually, or the shortcut installed manually.
A convenience script ("setup_xdg_shortcut.sh") to copy the shortcut and icon is provided in same directory as above. Note you may need to logoff or otherwise refresh desktop to get the icon to appear.

To launch manually, run the following command used in the shortcut:

```
flatpak run --command=alvr_launcher com.valvesoftware.Steam
```

## Caveats

Flatpak graphics drivers must match host drivers. This is especially problematic with Nvidia GPU. Remember to always do flatpak update after any major system update. You may then see new graphics packages being downloaded - it should automatically select the appropriate version.

Launching SteamVR from the dashboard will always launch a new instance of Steam. To avoid this, register the ALVR driver with Steam from the dashboard. However, the dashboard will not appear if SteamVR is launched from Steam. If any configuration needs to be made, launch the dashboard like the above. If the visibility of the Steam client does not matter, then simply launch SteamVR from the dashboard. Otherwise, launch SteamVR from inside of Steam after the driver is registered.

From launcher - file browser does not work yet. APK install feature requires additional setup for keys.

Certain fixes may need to be manually applied - similar to the non-flatpak version of alvr. At this time this means fix for vrmonitor.sh and optionally sudo set cap to stop steamvr complaining. Even with a working setup steamvr may will print errors and have buggy windows - the same as non-flatpak version.

Fix for flatpak steamvr setup error set cap: https://github.com/flathub/com.valvesoftware.Steam/issues/898
```
sudo setcap CAP_SYS_NICE+ep ~/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common/SteamVR/bin/linux64/vrcompositor-launcher
```

Fix for flatpak steamvr "vrmonitor.sh" issue:
Path is slightly different vs native steam, but fix is same - add to steamvr launch options:
```
~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command%
```
### failed to create pipewire errors
Use flatseal to add permission in "otherfiles" section for: xdg-run/pipewire-0


### SteamVR does not seem to like HDR being enabled with nvidia gpu
At the time of writing using a desktop environment with hdr enabled seems to break steamvr when using nvidia. The symptom is steamvr not rendering and showing a popup saying "update your graphics drivers". To fix this disable hdr.
This is not reported to be an issue with amd graphics cards.


### ADB doesnt't work in flatpak:
First need to setup adb on host, and enable usb debugging on device. Verify that devices shows up when you run "adb devices" and is authorised.
Script assumes that user has AndroidStudio installed with keys in default location ($HOME/.android/adbkey.pub) - change if necessary
Convenience script is provided: run_with_adb_keys.sh
```
export ADB_VENDOR_KEYS=~/.android/adbkey.pub
flatpak override --user --filesystem=~/.android com.valvesoftware.Steam.Utility.alvr
flatpak run --env=ADB_VENDOR_KEYS=$ADB_VENDOR_KEYS --command=alvr_launcher com.valvesoftware.Steam
```

If you get error saying "no devices" exist then check "adb devices" on host. Unplug/replug device and check again. If still stuck reboot then test again (seriously).

### Wayland variable causes steamvr error:
Make sure the QT_QPA_PLATFORM var allows x11 option - or steamvr freaks out. Launch from terminal to see errors.
This can be a problem if you have modified this variable globally to force usage of wayland for some program like GameScope.
You can fix this by setting the variable passed to steamvr

Example custom launch options for steamvr - including both QT_QPA_PLATFORM and vrmonitor fixes:
```
QT_QPA_PLATFORM=xcb ~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command%
```

## Additional notes

Previously this flatpak had a portable build environment for ALVR - but now the launcher exists this was not necessary. A portable build environment is a useful thing - so use git history to resurrect if needed!
Content of this file was moved to the appropiate wiki page: https://github.com/alvr-org/ALVR/wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak
2 changes: 2 additions & 0 deletions wiki/Building-From-Source.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ If you are on Linux, install these additional packages:

* **Arch**

Note: At time of writing Arch gcc is too new to be compatible with nvcc. This means there is no neat way to compile an nvidia compatible build. Recommended workarounds are to build in some kind of containerised environment. This has been done successfully with both nixos and flatpak - but are not documented yet.

```bash
sudo pacman -S clang curl nasm pkgconf yasm vulkan-headers libva-mesa-driver unzip ffmpeg libpipewire
```
Expand Down
134 changes: 78 additions & 56 deletions wiki/Installing-ALVR-and-using-SteamVR-on-Linux-through-Flatpak.md
Original file line number Diff line number Diff line change
@@ -1,117 +1,139 @@
## Disclaimer

1. This is not a fully-featured version of ALVR! It lacks Nvidia support and has bugs related to Flatpak sandboxing
1. Flatpak suppport is experimental - but it does seem to work. Some manual steps are needed!

2. Nvidia GPUs are currently not supported (but might be supported with [this PR](https://github.com/alvr-org/ALVR/pull/2207))
2. Native Linux SteamVR utility applications such as OpenVRAS are not supported nor tested, use at your own risk

3. Native Linux SteamVR utility applications such as OpenVRAS are not supported nor tested, use at your own risk
3. Firewall configuration does not work

4. Firewall configuration does not work
4. Any scripts that affect the host will run within the sandbox

5. Any scripts that affect the host will run within the sandbox
5. Sometimes, a new instance of Steam will launch when launching the dashboard. To fix this, close both ALVR and Steam then launch Steam. As soon as Steam opens to the storefront, launch the ALVR dashboard.

6. Sometimes, a new instance of Steam will launch when launching the dashboard. To fix this, close both ALVR and Steam then launch Steam. As soon as Steam opens to the storefront, launch the ALVR dashboard.

7. The ALVR Dashboard is not available in the Applications menu. To run the dashboard, run the following command to run `alvr_dashboard` in the Steam Flatpak environment:
6. User must setup xdg shortcut themselves - see below. Without an xdg entry the launcher has to be run from terminal.

```sh
flatpak run --command=alvr_dashboard com.valvesoftware.Steam
flatpak run --command=alvr_launcher com.valvesoftware.Steam
```

8. This only works with the Steam Flatpak. For non-Flatpak Steam, use the launcher or tar.gz
8. This does seem to work with both steam flatpak and native steam - it calls via xdg-open. But it is not recommended to have both versions of steam installed as this creates ambiguity.

## Dependencies

First, flatpak must be installed from your distro's repositories. Refer to [this page](https://flatpak.org/setup/) to find the instructions for your distro.

Once Flatpak is installed, the flatpak dependencies must also be installed. They are:

* Rust
* LLVM
* Freedesktop SDK
* Steam
## Setup

These can be installed like so:
Flatpak steam needs extra step compared to native steam. After installing SteamVR, run the following command:

```sh
flatpak install flathub org.freedesktop.Sdk//23.08 \
org.freedesktop.Sdk.Extension.llvm16//23.08 \
org.freedesktop.Sdk.Extension.rust-stable//23.08 \
com.valvesoftware.Steam
sudo setcap CAP_SYS_NICE+eip ~/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common/SteamVR/bin/linux64/vrcompositor-launcher
```

AMD users may need to install the appropriate Mesa codec extensions as well:

```sh
flatpak install flathub org.freedesktop.Platform.GL.default//23.08-extra \
org.freedesktop.Platform.GL32.default//23.08-extra
```
This command is normally run by SteamVR, but due to the lack of sudo access within the Flatpak sandbox, it must be run outside of the Flatpak sandbox. After running the command, run SteamVR once then close it.

## Setup
### steamvr custom launch options
At the time of writing steamvr needs special options to work on linux - this applies to both the flatpak version and native. The flatpak uses a slightly different path is the only difference. Paths below assume steam has been installed in the "normal" location - if your steam is in a different place then adjust paths as appropriate.

Install SteamVR via the Steam Flatpak. After installing SteamVR, run the following command:
For flatpak steam
```
~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command%
```

```sh
sudo setcap CAP_SYS_NICE+eip ~/.var/app/com.valvesoftware.Steam/data/Steam/steamapps/common/SteamVR/bin/linux64/vrcompositor-launcher
For native steam
```
~/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command%
```

This command is normally run by SteamVR, but due to the lack of sudo access within the Flatpak sandbox, it must be run outside of the Flatpak sandbox. After running the command, run SteamVR once then close it.
### failed to create pipewire errors
Use flatseal to add permissions to steam - in Filesystem section - "otherfiles" - add new entry with content: "xdg-run/pipewire-0"
Should see some other permissions there "xdg-music:ro", "xdg-pictures:ro" and maybe more for other integration (like discord).
TODO: add nice picture of what exactly this looks like, or shell command to do it

## Install

Download `com.valvesoftware.Steam.Utility.alvr.flatpak` file from one of the latest [nightly](https://github.com/alvr-org/ALVR-nightly/releases) that contains flatpak bundle and install like so:

```sh
flatpak --user install --bundle com.valvesoftware.Steam.Utility.alvr.flatpak
flatpak install --user com.valvesoftware.Steam.Utility.alvr.flatpak
```

Use apk for headset from the same nightly.

## Build and Install

Alternatively, if the file is not available or a newer version is needed, the flatpak can be built from source and installed.
## Notes

First, the dependencies from above must be fulfilled. Then, install `flatpak-builder` like so:
### Running the launcher

It's recommended that user sets up an xdg shortcut - but the launcher can also be run from terminal via the following command:
```sh
flatpak install flathub org.flatpak.Builder
flatpak run --command=alvr_launcher com.valvesoftware.Steam
```

Once the dependencies are fulfilled, clone and enter the repository.
An icon and desktop file named `com.valvesoftware.Steam.Utility.alvr.desktop` is supplied within the `alvr/xtask/flatpak` directory. Move this to where other desktop files are located on your system in order to run the dashboard without the terminal.

```sh
git clone https://github.com/alvr-org/ALVR.git
cd ALVR
```
# systemwide shortcut
# sudo cp com.valvesoftware.Steam.Utility.alvr.desktop /var/lib/flatpak/exports/share/applications/

Once inside the repository, simply run the following command to build and install the Flatpak.
# users local folder
cp com.valvesoftware.Steam.Utility.alvr.desktop $HOME/.local/share/flatpak/exports/share/applications/

```sh
flatpak run org.flatpak.Builder --user --install --force-clean .flatpak-build-dir alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json
# install icon as well
xdg-icon-resource install --size 256 alvr_icon.png application-alvr-launcher
```

If ALVR is not cloned under the home directory, permission to access the directory may need to be given to the build command. An example of this is given below.
The shortcut may not appear until desktop session is refreshed (e.g. log off then back on)

```sh
flatpak run --filesystem="$(pwd)" org.flatpak.Builder --user --install --force-clean .flatpak-build-dir alvr/xtask/flatpak/com.valvesoftware.Steam.Utility.alvr.json
### EXPERIMENTAL - APK install via flatpak launcher
First need to setup adb on host, and enable usb debugging on device. Verify that devices shows up when you run "adb devices" and is authorised.
Script assumes that user has AndroidStudio installed with keys in default location ($HOME/.android/adbkey.pub) - change if necessary
Convenience script is provided in git: run_with_adb_keys.sh
It's likely one the keys are exposed to the flatpak in the default location it will work without needing more changes.
```
export ADB_VENDOR_KEYS=~/.android/adbkey.pub
flatpak override --user --filesystem=~/.android com.valvesoftware.Steam.Utility.alvr
flatpak run --env=ADB_VENDOR_KEYS=$ADB_VENDOR_KEYS --command=alvr_launcher com.valvesoftware.Steam
```

## Notes
### Wayland variable causes steamvr error:
Make sure the QT_QPA_PLATFORM var allows x11 option - or steamvr freaks out. Launch from terminal to see errors.
This can be a problem if you have modified this variable globally to force usage of wayland for some program like GameScope.
You can fix this by setting the variable passed to steamvr
Example custom launch options for steamvr - including both QT_QPA_PLATFORM and vrmonitor fixes:

### Running the dashboard
```
QT_QPA_PLATFORM=xcb ~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command%
```

To run the ALVR Dashboard, run the following command:
### Hybrid graphics
If using desktop it's recommended to disable igpu - makes things simpler.
If using laptop then must pass extra options to ensure dgpu is used. These options are in addition to the others already mentioned.

```sh
flatpak run --command=alvr_dashboard com.valvesoftware.Steam
#### Amd/Intel integrated gpu + Amd/Intel discrete gpu
Put DRI_PRIME=1 %command% into SteamVR's commandline options and in those of all VR games you intend to play with ALVR.
```
DRI_PRIME=1 QT_QPA_PLATFORM=xcb ~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command%
```

A desktop file named `com.valvesoftware.Steam.Utility.alvr.desktop` is supplied within the `alvr/xtask/flatpak` directory. Move this to where other desktop files are located on your system in order to run the dashboard without the terminal.
#### Amd/Intel integrated gpu + Nvidia discrete gpu
Put __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia %command% into SteamVR's commandline options and in those of all VR games you intend to play with ALVR. Again - in addition to other options.
```
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia QT_QPA_PLATFORM=xcb ~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/SteamVR/bin/vrmonitor.sh %command%
```

### Other Applications

The support for other applications that are not launched via Steam is non-existent due to the Flatpak sandbox.

Various SteamVR utilities such as [WlxOverlay](https://github.com/galister/WlxOverlay) and [OpenVR-AdvancedSettings](https://github.com/OpenVR-Advanced-Settings/OpenVR-AdvancedSettings) cannot run within the Flatpak sandbox due to their usage of AppImage. However, unpacking the supplied AppImage or building the utilities from source and running their binaries from within the sandbox similiarly to `alvr_dashboard` could work, but there is no guarantee that they will work properly.

(at time of writing it does work properly)
Download wlx-overlay-s appimage.
Make it executable (chmod +x Wlx-Overlay-xxx.Appimage).
Extract it (./Wlx-Overlay-xxx.Appimage --app-image-extract)
Use flatseal or terminal to expose a folder to the steam flatpak (e.g. ~/test, should be in same section as the pipewire fix from above)
Copy the extracted files into the exposed folder.
Test it from terminal: flatpak run --command=bash com.valvesoftware.Steam (cd ~/test/squasroot-fs && ./Apprun)
To make a desktop shortcut, use a command like flatpak run --command=~/test/squashroot-fs/Apprun com.valvesoftware.Steam



Some applications such as [Godot](https://godotengine.org) support OpenXR. However, unless they are launched within the Steam Flatpak sandbox, they will not work with the Steam Flatpak. See [here](https://github.com/flathub/com.valvesoftware.Steam/issues/1010) for more details.

0 comments on commit 4d0d0ce

Please sign in to comment.