Browse Source

Add "gamemoderun", a wrapper bash script like "primusrun"

	This should remove a point of failure currently where users fail to set LD_PRELOAD correctly, or the path is wrong somehow.

	FWIW: The old method still works, and I've noted that in the README.
Marc Di Luzio 6 years ago
parent
commit
74e26d6f63
4 changed files with 35 additions and 4 deletions
  1. 6 2
      README.md
  2. 8 2
      data/gamemoded.8
  3. 11 0
      data/gamemoderun.in
  4. 10 0
      data/meson.build

+ 6 - 2
README.md

@@ -60,14 +60,18 @@ ninja uninstall
 
 After installing `libgamemodeauto.so.0` simply preload it into the game:
 ```bash
-LD_PRELOAD=/usr/\$LIB/libgamemodeauto.so.0 ./game
+gamemoderun ./game
 ```
 Or edit the steam launch options:
 ```bash
-LD_PRELOAD=$LD_PRELOAD:/usr/\$LIB/libgamemodeauto.so.0 %command%
+gamemoderun %command%
 ```
 Please note the backslash here in `\$LIB` is required.
 
+Note: for older versions of GameMode (1.2) use this string in place of `gamemoderun`:
+```
+LD_PRELOAD="$LD_PRELOAD:/usr/\$LIB/libgamemodeauto.so.0"
+```
 ---
 ## Configuration
 

+ 8 - 2
data/gamemoded.8

@@ -38,13 +38,19 @@ Print the version
 \fBlibgamemodeauto.so.0\fR can be pre-loaded into any program to request \fBgamemoded\fR begin or end the mode, like so:
 
 .RS 4
-LD_PRELOAD=/usr/\e$LIB/libgamemodeauto.so.0 \./game
+gamemoderun \./game
 .RE
 
 Or by setting the steam launch options for a game:
 
 .RS 4
-LD_PRELOAD=$LD_PRELOAD:/usr/\e$LIB/libgamemodeauto.so.0 %command%
+gamemoderun %command%
+.RE
+
+The library can be manually preloaded if needed:
+
+.RS 4
+LD_PRELOAD=$LD_PRELOAD:/usr/\e$LIB/libgamemodeauto.so.0 ./game
 .RE
 
 The \fBgamemode_client.h\fR header can be used by developers to build the requests into a program:

+ 11 - 0
data/gamemoderun.in

@@ -0,0 +1,11 @@
+#!/bin/bash
+# Helper script to launch games with gamemode
+
+# Path to install gamemoded auto script
+CONFIG_LIB_DIR="@GAMEMODE_LIB_DIR@/libgamemodeauto.so.0"
+
+# Set the ld library path prefixed libgamemodeauto
+export LD_LIBRARY_PATH=${CONFIG_LIB_DIR}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
+
+# Launch
+exec "$@"

+ 10 - 0
data/meson.build

@@ -1,6 +1,7 @@
 data_conf = configuration_data()
 data_conf.set('BINDIR', path_bindir)
 data_conf.set('LIBEXECDIR', path_libexecdir)
+data_conf.set('GAMEMODE_LIB_DIR', path_libdir)
 
 if with_systemd == true
     # Install systemd user unit
@@ -29,5 +30,14 @@ configure_file(
     install_dir: path_polkit_action_dir,
 )
 
+# Install the helper run script
+configure_file(
+    input: 'gamemoderun.in',
+    output: 'gamemoderun',
+    configuration: data_conf,
+    install_dir: 'bin',
+    install_mode: 'rwxr-xr-x',
+)
+
 # Install the man page
 install_man('gamemoded.8')