From 19c2f6c2b86d1fd0c4088fb2c98db894cc95c4f4 Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Tue, 3 Oct 2023 11:40:43 -0700 Subject: [PATCH] Add vulkan setup and uninstall scripts --- .github/FUNDING.yml | 13 ++++++ .gitignore | 1 + README.md | 43 ++++++++++++++++++- {vulkan/bin => bin}/breezy_vulkan_setup | 11 ++--- bin/package_vulkan | 55 ++++++++++++++++--------- vulkan/bin/breezy_vulkan_uninstall | 32 ++++++++++++++ vulkan/bin/setup | 46 +++++++++++++++++++++ vulkan/config/vkBasalt.conf | 12 ++++++ 8 files changed, 185 insertions(+), 28 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .gitignore rename {vulkan/bin => bin}/breezy_vulkan_setup (71%) mode change 100644 => 100755 create mode 100755 vulkan/bin/breezy_vulkan_uninstall create mode 100755 vulkan/bin/setup create mode 100644 vulkan/config/vkBasalt.conf diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..f61fc4e --- /dev/null +++ b/.github/FUNDING.yml @@ -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'] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..abf7936 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vulkan/build/ diff --git a/README.md b/README.md index 97122d5..60d1b88 100644 --- a/README.md +++ b/README.md @@ -1 +1,42 @@ -# breezy-desktop \ No newline at end of file +# 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. \ No newline at end of file diff --git a/vulkan/bin/breezy_vulkan_setup b/bin/breezy_vulkan_setup old mode 100644 new mode 100755 similarity index 71% rename from vulkan/bin/breezy_vulkan_setup rename to bin/breezy_vulkan_setup index c2acbfa..dfdcc6d --- a/vulkan/bin/breezy_vulkan_setup +++ b/bin/breezy_vulkan_setup @@ -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 @@ -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 diff --git a/bin/package_vulkan b/bin/package_vulkan index e630981..dd66e76 100755 --- a/bin/package_vulkan +++ b/bin/package_vulkan @@ -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/ +# 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/ -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 Sombrero FX +cp $VULKAN_MODULES/sombrero/IMUAdjust.fx $PACKAGE_DIR -cp $VKBASALT_MODULE_DIR/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 \ No newline at end of file +# bundle everything up +tar -zcvf $VULKAN_BUILD/breezyVulkan.tar.gz --directory $VULKAN_BUILD breezy_vulkan \ No newline at end of file diff --git a/vulkan/bin/breezy_vulkan_uninstall b/vulkan/bin/breezy_vulkan_uninstall new file mode 100755 index 0000000..9c838b2 --- /dev/null +++ b/vulkan/bin/breezy_vulkan_uninstall @@ -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\"" \ No newline at end of file diff --git a/vulkan/bin/setup b/vulkan/bin/setup new file mode 100755 index 0000000..444e8a6 --- /dev/null +++ b/vulkan/bin/setup @@ -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" \ No newline at end of file diff --git a/vulkan/config/vkBasalt.conf b/vulkan/config/vkBasalt.conf new file mode 100644 index 0000000..1402899 --- /dev/null +++ b/vulkan/config/vkBasalt.conf @@ -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