# Gaming

- [Gaming](#gaming)
  - [Discord](#discord)
  - [Steam](#steam)
    - [autostart](#autostart)
    - [mangohud](#mangohud)
    - [Streaming](#streaming)
    - [FSR](#fsr)
  - [ProtonUp-QT](#protonup-qt)
  - [VSCode](#vscode)
  - [XWayland](#xwayland)
  - [Wine](#wine)
  - [Spotify](#spotify)
  - [VLC](#vlc)
  - [Remote Desktop](#remote-desktop)
  - [Bitwarden](#bitwarden)
  - [OBS](#obs)
  - [Xbox Controller](#xbox-controller)
  - [Mangohud](#mangohud-1)
  - [ffmpeg](#ffmpeg)
    - [Intel 11th gen](#intel-11th-gen)
    - [AMD 7900xtx](#amd-7900xtx)
  - [Minecraft](#minecraft)
    - [Launcher](#launcher)
    - [MultiMC](#multimc)

## Discord

```bash
mv ~/Downloads/Discord ~/Applications/Discord
```

```conf
[Desktop Entry]
Name=Discord
Exec=/home/ducoterra/Applications/Discord/Discord
Icon=/home/ducoterra/Applications/Discord/discord.png
Type=Application
```

## Steam

<https://wiki.archlinux.org/title/Official_repositories#multilib>

Edit /etc/pacman.conf

```conf
[multilib]
Include = /etc/pacman.d/mirrorlist
```

```bash
pacman -S steam
```

When prompted use vulkan-radeon on AMD and vulkan-intel on intel.

### autostart

```bash
ln -s ~/.local/share/applications/steam-native.desktop ~/.config/autostart/
```

### mangohud

Start steam with mangohud

```bash
pacman -S mangohud lib32-mangohud
cp /usr/share/applications/steam-native.desktop ~/.local/share/applications/steam.desktop
```

Edit ~/.local/share/applications/steam.desktop:

```conf
Exec=/usr/bin/mangohud /usr/bin/steam-native %U
```

### Streaming

Works great from Arch hosts to Arch guests with a little configuration.

1. wifi

    Your wifi should be isolated to the fastest band you have available at the widest channel width on
    the least populated channel. BSS Transition and Fast Roaming are the only settings I enable since
    they do make a difference for video calls and streaming while moving from room to room but don't
    cause interference or connectivity issues like the other settings.

    ![unifi wifi config](media/unifi_wifi_config.png)

2. host

    Your host settings don't matter too much since you'll be limited to Steam's compatibility with
    Arch's mesa drivers, the current kernel version, and whether Mercury is retrograde. Steam does a
    pretty good job automatically selecting the correct libraries and capture mechanism. Here are
    the settings I use:

    ![steam host settings](media/steam_host_settings.png)

3. Client

    Here's where things start to matter. As of kernel `6.7.6-arch1-2`, `mesa 1:24.0.2-1`,
    `libva 2.20.0-1`, `mesa-vdpau 1:24.0.2-1`, and `libvdpau 1.5-2` hardware decoding works on Arch
    with AMD integrated graphics on both my framework (Ryzen 7 7840U w/ Radeon 780M Graphics) and my
    Steam Deck.

    In the steam advanced client settings select "Enhanced 4k" to start. Do not change
    the Resolution limit. Decoding at the native resolution of your screen will always perform
    better than using a non-native resolution. In my testing even lower resolutions result in
    20-30ms of additional delay over native. Framerate limit should stay at automatic. This will try
    to match the streaming framerate to your display's refresh rate. You can set this to 60 if
    things are lagging too much. Bandwidth limit can be adjusted up and down to fit your wifi's
    limitations if you are experience frame drops and stuttering. If you experience issues like
    crashing on launch, blank screen or strange artifacts disable hardware decoding. HEVC and low
    latency networking have never caused me issues. Here are my settings:

    ![steam client settings](media/steam_client_settings.png)

    And to show what a properly configured client can do, here's Crab Champions streamed to my
    laptop at 2k, 99fps. Note the streaming latency is ~10ms and the dark blue (encode time), light
    blue (network transmit time), and red (decode time) lines are extremely close together.

    ![enhanced 4k framework](media/enhanced_4k_framework.png)

    My Steam Deck performs about the same but with a lower (~7ms) streaming latency. This is
    expected because the steam deck streams at 1280x720 which means faster encode and transmit.

    If the red line is far above the blue lines it means your decoding (software or hardware) is
    struggling to keep up. Either it's not decoding at native resolution (likely transforming the
    decoded frame to match the display resolution) or your cpu/gpu is doing something else.

    If the light blue line is far above the dark blue line your wifi is slow. Increase channel
    width, increase transmit power, ensure devices are connected to 5 or 6Ghz, and ensure your
    device has the latest drivers.

    If the dark blue line is far above the x axis of the graph your host is struggling to encode
    fast enough. Likely the host's cpu/gpu is doing something else or it's an old computer

### FSR

<https://linux-gaming.kwindu.eu/index.php?title=FSR_-_FidelityFX_Super_Resolution>

> This sharpens the image. 4 is an example value. 0 is maximum sharpness, higher values mean less sharpening. 5 is the maximum value. The default is 2

```bash
WINE_FULLSCREEN_FSR=1 WINE_FULLSCREEN_FSR_STRENGTH=2
```

## ProtonUp-QT

<https://davidotek.github.io/protonup-qt/>

```bash
mv ~/Downloads/ProtonUp-Qt*.AppImage ~/Applications/ProtonUp-Qt.AppImage
chmod +x ~/Applications/*.AppImage
```

```conf
[Desktop Entry]
Name=ProtonUp-Qt
Exec=/home/ducoterra/Applications/ProtonUp-Qt.AppImage
Icon=/home/ducoterra/.icons/ProtonUp-Qt.png
Type=Application
```

## VSCode

For the open source version of code install `code`:

```bash
pacman -S code
```

## XWayland

Provides compatibility with X server applications (like wine)

```bash
pacman -S xorg-xwayland
```

## Wine

```bash
pacman -S wine
```

## Spotify

```bash
pacman -S spotify-launcher
```

## VLC

```bash
pacman -S vlc
```

## Remote Desktop

```bash
pacman -S remmina freerdp
```

## Bitwarden

<https://bitwarden.com/download/>

```bash
mv ~/Downloads/Bitwarden*.AppImage ~/Applications/Bitwarden.AppImage
chmod +x ~/Applications/*.AppImage
```

```conf
[Desktop Entry]
Name=Bitwarden
Exec=/home/ducoterra/Applications/Bitwarden.AppImage
Icon=/home/ducoterra/.icons/bitwarden.png
Type=Application
```

## OBS

```bash
pacman -S obs-studio qt6-wayland
yay -S obs-vkcapture-git
```

Add "Game Capture" to your scene.

Start your games with `env OBS_VKCAPTURE=1 %command%`

## Xbox Controller

1. Install bluetooth packages

  ```bash
  pacman -S bluez bluez-plugins bluez-utils
  ```

2. Edit the bluetooth conf and set the controller to bredr

  /etc/bluetooth/main.conf

  ```conf
  ControllerMode = bredr
  ```

3. Now reset the bluetooth service

  ```bash
  systemctl restart bluetooth
  ```

4. Connect your controller
5. Comment out the line in the bluetooth conf you just edited
6. Restart the bluetooth service

## Mangohud

<https://github.com/flightlessmango/MangoHud#arch-based-distributions>

```bash
sudo pacman -S mangohud lib32-mangohud
```

```bash
mkdir ~/.config/MangoHud
cp /usr/share/doc/mangohud/MangoHud.conf.example ~/.config/MangoHud/MangoHud.conf
```

Edit `~/.config/MangoHud/MangoHud.conf` and tweak as you see fit.

Then add `mangohud env MANGOHUD_CONFIGFILE=/home/ducoterra/.config/MangoHud/MangoHud.conf %command%` to your steam launch.

## ffmpeg

<https://wiki.archlinux.org/title/FFmpeg>

### Intel 11th gen

```bash
pacman -S ffmpeg libmfx intel-media-sdk

ffmpeg \
-hwaccel qsv \
-c:v hevc_qsv \
-hwaccel_output_format qsv \
-i input.mkv \
-c:v hevc_qsv \
-global_quality 25 \
output.mp4
```

### AMD 7900xtx

<https://wiki.archlinux.org/title/FFmpeg#VA-API>

```bash
sudo pacman -S ffpmeg mesa libva-mesa-driver

reboot

ffmpeg \
-hwaccel vaapi \
-vaapi_device /dev/dri/renderD128 \
-hwaccel_output_format vaapi \
-i input.mp4 \
-c:v hevc_vaapi \
-rc_mode 1 \
-qp 25 \
output.mp4

ffmpeg \
-hwaccel vaapi \
-vaapi_device /dev/dri/renderD128 \
-hwaccel_output_format vaapi \
-i input.mp4 \
-c:v h264_vaapi \
-b:v 0 \
-maxrate 100M \
output.mp4
```

## Minecraft

### Launcher

<https://wiki.archlinux.org/title/minecraft>

```bash
yay -S minecraft-launcher
```

### MultiMC

MultiMC allows you to maintain and run multiple installations of minecraft with handy
shortcuts for installing mod loaders and many more features. It's super easy to install
on arch.

<https://github.com/MultiMC/multimc-pkgbuild>

```bash
mkdir /tmp/multimc
cd /tmp/multimc
git clone https://github.com/MultiMC/multimc-pkgbuild.git
cd multimc-pkgbuild
makepkg -si
```
