Skip to content

Commit

Permalink
Add vulkan setup and uninstall scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
wheaney committed Oct 3, 2023
1 parent 6ad3437 commit 19c2f6c
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 28 deletions.
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: wheaney
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: wheaney
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vulkan/build/
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
# breezy-desktop
# Breezy Desktop

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/U7U8OVC0L)

## What is this?

This repo will eventually contain a collection of tools to enable virtual desktop environments for gaming and productivity on Linux using XREAL Air glasses.

As of now, only a Vulkan implementation is available, primarily for gaming but could theoretically be used for anything that uses Vulkan rendering.

## Breezy Vulkan

### Setup

#### Steam Deck via Decky Loader

This is still a work in progress... star this repo or check back later.

#### Manual installation

1. [Download the setup script](https://github.com/wheaney/breezy-desktop/releases/latest/download/breezy_vulkan_setup) and set the execute flag (e.g. from the terminal: `chmod +x ~/Downloads/breezy_vulkan_setup`)
2. Run the setup script as root (e.g. `sudo ~/Downloads/breezy_vulkan_setup`)

### Usage

Once installed, you should be able to launch any Vulkan game, plug in your glasses (at any point, not just after launching), and see a floating screen. Note that the initial centering of the screen is based on pre-calibrated values, so it may not actually start out where you're looking, or you may even see it move around for 10+ seconds after you've plugged in your glasses.

To re-center the screen, I've implemented an experimental double-tap feature: you'll want to give two decent taps on the top of the glasses. I tend to do this on the corner, right on top of the hinge. It should be a firm, sharp tap, and wait just a split second to do the second tap, as it needs to detect a slight pause in between (but it also shouldn't take more than a half a second between taps so don't wait too long).

Framerate is really important here, because individual frames are static, so if you're moving your head and the next frame hasn't rendered yet, you'll see the screen move with you for just tiny fraction of a second (e.g. 30Hz, the screen follows you for 33ms) which produces a kind of "dragging" effect. I've found 60Hz to be the best experience, though there is still some dragging that I'd like to try to resolve; I expect 120Hz would work even better if you have the firmware version to support it.

### Disabling

To disable the floating screen effect, either unplug the glasses or hit the `Home` key (you'll need to bind this to your controller on Steam Deck).

### Updating

Rerun the `breezy_vulkan_setup` script. No need to redownload this script, as it will automatically download the latest installation binary for you.

### Uninstalling

If you wish to completely remove the installation, run the following script as root: `~/bin/breezy_vulkan_uninstall`. This won't uninstall the base driver package, following the instructions at the end of the uninstallation to do this manually.
11 changes: 4 additions & 7 deletions vulkan/bin/breezy_vulkan_setup → bin/breezy_vulkan_setup
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ if [ "$(id -u)" != "0" ]; then
fi

# create temp directory
tmp_dir=$(mktemp -d -t xreal-air-XXXXXXXXXX)
tmp_dir=$(mktemp -d -t breezy-vulkan-XXXXXXXXXX)
pushd $tmp_dir > /dev/null
echo "Created temp directory: ${tmp_dir}"

if [ -z "$1" ]
then
echo "Downloaded installation is not available yet"
exit 1

# download and unzip the latest driver
echo "Downloading latest release to: ${tmp_dir}/xrealAirLinuxDriver.tar.gz"
curl -L -O https://github.com/wheaney/xrealAirLinuxDriver/releases/latest/download/xrealAirLinuxDriver.tar.gz
echo "Downloading latest release to: ${tmp_dir}/breezyVulkan.tar.gz"
curl -L -O https://github.com/wheaney/breezy-desktop/releases/latest/download/breezyVulkan.tar.gz
else
cp $1 $tmp_dir
fi
Expand All @@ -35,7 +32,7 @@ tar -xf breezyVulkan.tar.gz
pushd breezy_vulkan > /dev/null

# run the setup script that comes with this release
./setup
bin/setup

echo "Deleting temp directory: ${tmp_dir}"
rm -rf $tmp_dir
Expand Down
55 changes: 35 additions & 20 deletions bin/package_vulkan
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,55 @@ set -e
git submodule update --init --recursive

VULKAN_DIR=vulkan
VULKAN_BUILD=$VULKAN_DIR/build
if [ ! -d "$VULKAN_BUILD" ]; then
mkdir -p $VULKAN_BUILD
else
rm -rf $VULKAN_BUILD/*
fi

VULKAN_MODULES=$VULKAN_DIR/modules
PACKAGE_DIR=$VULKAN_DIR/build/breezy_vulkan
PACKAGE_DIR=$VULKAN_BUILD/breezy_vulkan
if [ ! -d "$PACKAGE_DIR" ]; then
mkdir -p $PACKAGE_DIR
else
rm -rf $PACKAGE_DIR/*
fi

# build vkBasalt
VKBASALT_MODULE_DIR=$VULKAN_MODULES/vkBasalt
pushd $VKBASALT_MODULE_DIR
./docker-build
popd
VKBASALT_BUILD_DIR=$VKBASALT_MODULE_DIR/out
if [ ! -d "$VKBASALT_BUILD_DIR" ] || [ "$1" == "--clean" ]; then
pushd $VKBASALT_MODULE_DIR
./docker-build
popd
fi

# move and rename the compiled driver to the driver directory
mkdir -p $PACKAGE_DIR/vkbasalt.64
cp $VKBASALT_BUILD_DIR/builddir/src/libvkbasalt.so $PACKAGE_DIR/vkbasalt.64/
cp $VKBASALT_BUILD_DIR/builddir/config/vkBasalt.json $PACKAGE_DIR/vkbasalt.64/

mkdir -p $PACKAGE_DIR/vkbasalt.32
cp $VKBASALT_BUILD_DIR/builddir.32/src/libvkbasalt.so $PACKAGE_DIR/vkbasalt.32/
cp $VKBASALT_BUILD_DIR/builddir.32/config/vkBasalt.json $PACKAGE_DIR/vkbasalt.32/
# copy vkBasalt binaries and configs
mkdir -p $PACKAGE_DIR/{vkBasalt.64,vkBasalt.32}
cp $VKBASALT_BUILD_DIR/builddir/src/libvkbasalt.so $PACKAGE_DIR/vkBasalt.64/
cp $VKBASALT_BUILD_DIR/builddir/config/vkBasalt.json $PACKAGE_DIR/vkBasalt.64/
cp $VKBASALT_BUILD_DIR/builddir.32/src/libvkbasalt.so $PACKAGE_DIR/vkBasalt.32/

cp $VKBASALT_MODULE_DIR/sombrero/IMUAdjust.fx $PACKAGE_DIR
# copy Sombrero FX
cp $VULKAN_MODULES/sombrero/IMUAdjust.fx $PACKAGE_DIR

# copy setup and user-relevant scripts
# copy vulkan setup scripts and configs
cp -r $VULKAN_DIR/bin $PACKAGE_DIR
cp -r $VULKAN_DIR/config $PACKAGE_DIR

# build xreal driver
XREAL_DRIVER_DIR=modules/xrealAirLinuxDriver
pushd $XREAL_DRIVER_DIR
bin/package
popd
XREAL_BINARY=$XREAL_DRIVER_DIR/build/xrealAirLinuxDriver.tar.gz
if [ ! -e "$XREAL_BINARY" ] || [ "$1" == "--clean" ]; then
pushd $XREAL_DRIVER_DIR
bin/package
popd
fi

cp $XREAL_DRIVER_DIR/build/xrealAirLinuxDriver.tar.gz $PACKAGE_DIR
# copy xreal binary and setup script
cp $XREAL_BINARY $PACKAGE_DIR
cp $XREAL_DRIVER_DIR/bin/xreal_driver_setup $PACKAGE_DIR/bin

# bundle up the driver directory
tar -zcvf breezyGaming.tar.gz $PACKAGE_DIR
# bundle everything up
tar -zcvf $VULKAN_BUILD/breezyVulkan.tar.gz --directory $VULKAN_BUILD breezy_vulkan
32 changes: 32 additions & 0 deletions vulkan/bin/breezy_vulkan_uninstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

for_install=0
if [[ -n "$1" ]] && [[ "$1" == "--for-install" ]]; then
for_install=1
fi

# we don't want the uninstall script to be able to cause a failure if being triggered by the setup script
[ "$for_install" -eq 0 ] && set -e

# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi

USER=${SUDO_USER:-$USER}
USER_HOME=$(getent passwd $USER | cut -d: -f6)

[ "$for_install" -eq 0 ] && echo "Removing vkBasalt binaries from $USER_HOME/.local/lib[32]/"
rm $USER_HOME/.local/lib/libvkbasalt.so
rm $USER_HOME/.local/lib32/libvkbasalt.so

[ "$for_install" -eq 0 ] && echo "Removing vkBasalt vulkan layer configs from $USER_HOME/.local/share/vulkan/implicit_layer.d/"
rm $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.json
rm $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.x86.json

[ "$for_install" -eq 0 ] && echo "Removing vkBasalt config at $USER_HOME/.config/vkBasalt/vkBasalt.conf"
rm $USER_HOME/.config/vkBasalt/vkBasalt.conf

[ "$for_install" -eq 0 ] && echo "SKIPPING xrealAirLinuxDriver uninstall to keep mouse/joystick driver functionality."
[ "$for_install" -eq 0 ] && echo "To manually uninstall xrealAirLinuxDriver, do: \"sudo ~/bin/xreal_driver_uninstall\""
46 changes: 46 additions & 0 deletions vulkan/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

# This script gets packaged with the release and should do the bulk of the setup work. This allows this setup to be tied
# to a specific release of the code, and guarantees it will never run along-side newer or older binaries.

USER=${SUDO_USER:-$USER}
USER_HOME=$(getent passwd $USER | cut -d: -f6)
if [ -e "$USER_HOME/bin/breezy_vulkan_uninstall" ]; then
echo "Cleaning up the previous installation"

# ` || true` will ensure that this can't cause a failure, even with `set -e`
$USER_HOME/bin/breezy_vulkan_uninstall --for-install || true
fi

echo "Copying the breezy_vulkan scripts to ${USER_HOME}/bin"
if [ ! -d "$USER_HOME/bin" ]; then
mkdir $USER_HOME/bin
fi
cp bin/breezy_vulkan_uninstall $USER_HOME/bin

echo "Installing vkBasalt; copying binaries, configs, and shader files to ${USER_HOME}/.local and ${USER_HOME}/.config"

# much of the setup below was informed by https://github.com/simons-public/steam-deck-vkbasalt-install
# copy the vkBasalt binaries and configs
mkdir -p ${USER_HOME}/.local/{lib,lib32,share/vulkan/implicit_layer.d}
mkdir -p ${USER_HOME}/.config/{vkBasalt,reshade}
cp vkBasalt.64/libvkbasalt.so $USER_HOME/.local/lib/
cp vkBasalt.32/libvkbasalt.so $USER_HOME/.local/lib32/

# there is only one vkBasalt.json file, use the 64-bit directory for both, copy and make replacements
if grep -q SteamOS /etc/os-release ; then
sed -e "s|libvkbasalt.so|${USER_HOME}/.local/lib/libvkbasalt.so|" -e "s/ENABLE_VKBASALT/SteamDeck/" vkBasalt.64/vkBasalt.json > $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.json
sed -e "s|libvkbasalt.so|${USER_HOME}/.local/lib32/libvkbasalt.so|" -e "s/ENABLE_VKBASALT/SteamDeck/" vkBasalt.64/vkBasalt.json > $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.x86.json
else
sed -e "s|libvkbasalt.so|${USER_HOME}/.local/lib/libvkbasalt.so|" vkBasalt.64/vkBasalt.json > $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.json
sed -e "s|libvkbasalt.so|${USER_HOME}/.local/lib32/libvkbasalt.so|" vkBasalt.64/vkBasalt.json > $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.x86.json
fi

# copy the vkBasalt.conf file and make replacements
sed -e "s|/path/to/reshade-shaders|${USER_HOME}/.config/reshade|" -e "s|/path/to/sombrero|${USER_HOME}/.config/reshade/Shaders/IMUAdjust.fx|" config/vkBasalt.conf > $USER_HOME/.config/vkBasalt/vkBasalt.conf

# set up the XREAL driver using the local binary
echo "Installing xrealAirLinuxDriver"
echo "BEGIN - xreal_driver_setup"
bin/xreal_driver_setup $(pwd)/xrealAirLinuxDriver.tar.gz
echo "END - xreal_driver_setup"
12 changes: 12 additions & 0 deletions vulkan/config/vkBasalt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
effects = sombrero

sombrero = /path/to/sombrero
reshadeTexturePath = "/path/to/reshade-shaders/Textures"
reshadeIncludePath = "/path/to/reshade-shaders/Shaders"
depthCapture = off

#toggleKey toggles the effects on/off
toggleKey = Home

#enableOnLaunch sets if the effects are enabled when started
enableOnLaunch = True

0 comments on commit 19c2f6c

Please sign in to comment.