From 74e26d6f632fbbe3c2a16d82a251ac6830575032 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Tue, 5 Feb 2019 21:13:16 +0000 Subject: [PATCH] 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. --- README.md | 8 ++++++-- data/gamemoded.8 | 10 ++++++++-- data/gamemoderun.in | 11 +++++++++++ data/meson.build | 10 ++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 data/gamemoderun.in diff --git a/README.md b/README.md index 708549f..76bfd49 100644 --- a/README.md +++ b/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 diff --git a/data/gamemoded.8 b/data/gamemoded.8 index a861ae0..82a7c58 100644 --- a/data/gamemoded.8 +++ b/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: diff --git a/data/gamemoderun.in b/data/gamemoderun.in new file mode 100644 index 0000000..7106349 --- /dev/null +++ b/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 "$@" diff --git a/data/meson.build b/data/meson.build index 98a5174..9636cc2 100644 --- a/data/meson.build +++ b/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')