Skip to content

Instantly share code, notes, and snippets.

@TechnoSparks
Created April 29, 2018 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TechnoSparks/16c335a1df2da99d1efd3c6b6260b31b to your computer and use it in GitHub Desktop.
Save TechnoSparks/16c335a1df2da99d1efd3c6b6260b31b to your computer and use it in GitHub Desktop.
Script to define your own defaults when launching applications under bumblebee
#!/bin/bash
USAGE="How to use:
runvidia [OPTION] <command>
Available OPTIONs:
--vsync Sets vsync to turn ON, program-overridable
--vsync-force-off Force vsync to OFF, regardless program's preferences
--primussync NUM Changes primus_sync env var.
Defaults to NUM=1, which \"synchronizing primus' display
thread with the application's rendering thread\"
NUM=2 , \"display the latest rendered frame, trading frame
rate for reduced visual latency\"
--optirun Uses \"optirun\" instead of \"primusrun\", however
\"-b primus\" is still supplied to optirun
-h , --help Print this help message
Anything not an option will be parsed as arguments to the subprogram!"
if [ ! "$1" ]; then
echo "Parameters required!"
echo "$USAGE"
exit 1
fi
# Set defaults
vblank_mode=1
PRIMUS_SYNC=1
optirun=0
# Handle switches
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--vsync)
vblank_mode=2
shift
;;
--vsync-force-off)
vblank_mode=0
shift
;;
--primussync)
PRIMUS_SYNC="$2"
shift 2
;;
--optirun)
optirun=1
shift
;;
-h|--help)
echo "$USAGE";
shift
exit 1
;;
*) # unknown option
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
# Perform operations
echo "vblank_mode = ${vblank_mode}"
echo "PRIMUS_SYNC = ${PRIMUS_SYNC}"
if [ "$optirun" == "0" ]; then
echo "primusrun evoked"
vblank_mode=${vblank_mode} PRIMUS_SYNC=${PRIMUS_SYNC} primusrun "$@"
elif [ "$optirun" == "1" ]; then
echo "optirun evoked"
vblank_mode=${vblank_mode} PRIMUS_SYNC=${PRIMUS_SYNC} optirun -b primus "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment