Skip to content

Instantly share code, notes, and snippets.

@jenrik
Created January 31, 2019 22:55
Show Gist options
  • Save jenrik/f25946e9a023187fe4b391099853a3a7 to your computer and use it in GitHub Desktop.
Save jenrik/f25946e9a023187fe4b391099853a3a7 to your computer and use it in GitHub Desktop.
Guide to using bumblebee inside a flatpak

WORK IN PROGRESS, NOT FULLY TESTED YET

Setup flatpak

  1. Install bumblebee
  2. set KeepUnusedXServer to true in /etc/bumblebee.conf
  3. Acquire a copy of primus libgl.so either from your package manager or by compiling from source
  4. Copy the primus libgl.so to a folder a empty folder inside the flatpak
  5. Acquire a copy of the primusrun script either from your package manager or from https://github.com/amonakov/primus/blob/master/primusrun
  6. Copy the primusrun script to your home directory inside the flatpak
  7. In primusrun change export PRIMUS_libGLa to find to the folder with the libgl.so library for you GPU (NOT the primus libgl.so)
  8. In primusrun change export PRIMUS_libGLd to find to the folder with the libgl.so library for you integrated graphics (NOT the primus libgl.so)
  9. In primusrun change PRIMUS_libGL to the path of the primus libgl.so library
  10. compile flatpak 1.2.0 with the below patch flatpak-bumblebee.path

note: When modifying primusrun the paths has to the paths inside the flatpak

Setup a steam game for GPU acceleration

This will inform steam to run your game with the prumisrun wrapper that enable GPU acceleration

  1. right click the steam game in you library that you wan't to have accelerated
  2. click set launch options
  3. paste /home/jenrik/primusrun %command% in to the dialog box, and replace jenrik with your linux username

Running a game with GPU acceleration

TESTED

  1. run primusrun glxgears to start bumblebee/ the secondary X server
  2. run flatpak run com.valvesoftware.Steam and replace flatpak with the full path to your patched version of flatpak
  3. run your previously configured game
  4. ???
  5. PROFIT!!!

Running a abitrary flatpak with GPU acceleration

  1. run primusrun glxgears to start bumblebee/ the secondary X server
  2. run flatpak run --command=bash com.example.Flatpak and replace flatpak with the full path to your patched version of flatpak
  3. inside the flatpak run /home/$USER/primusrun <command>
From 72c8f65a20b3b4320e90418dcf5b0a71a3decade Mon Sep 17 00:00:00 2001
---
common/flatpak-run.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/common/flatpak-run.c b/common/flatpak-run.c
index eef48557..0f6ba533 100644
--- a/common/flatpak-run.c
+++ b/common/flatpak-run.c
@@ -191,6 +191,9 @@ flatpak_run_add_x11_args (FlatpakBwrap *bwrap,
flatpak_bwrap_add_args (bwrap,
"--ro-bind", x11_socket, "/tmp/.X11-unix/X99",
NULL);
+ flatpak_bwrap_add_args (bwrap,
+ "--ro-bind", "/tmp/.X11-unix/X8", "/tmp/.X11-unix/X8",
+ NULL);
flatpak_bwrap_set_env (bwrap, "DISPLAY", ":99.0", TRUE);
#ifdef ENABLE_XAUTH
--
2.20.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment