A command-line tool to enable switchable graphics for certain commands.
You won't need to type DRI_PRIME=1 steam
again.
Write the following to the configuration file ~/.config/switchable/config.json
.
{
"match": [ "steam" ]
}
And then just run a command that matches.
steam
And it will automatically use your discrete GPU.
- bash
- bash-preexec
- Perl and CPAN modules
- Install bash-preexec to
~/.bash-preexec.sh
(the default) - Add the executable to your PATH
- Add
eval "$( switchable init )"
to your .bashrc
We first look at ~/.config/switchable/config.json
, and if that doesn't exist, we try ~/.switchable/config.json
.
The file is a JSON object with the following format. Note that it does allow comments. See JSON::PP docs for more details about the allowed JSON syntax.
{
"driver": 1, // Default value for DRI_PRIME
"preexec": "/path/to/bash/preexec", // Path to bash-preexec
// if it's not in its default location
"match": [ // Regexes to match commands against
"steam",
"echo"
],
"alias": [ // Commands to alias
"glxgears"
]
}
Having switchable
being called for each command adds around 140ms to each command you type. However, it isn't run when nothing is typed.
TODO add comparison video.
switchable run
doesn't work with aliases such as ll
.
Project documentation is in docs/
, start from the index.
We mostly test either specific functions in Perl, or the general output of commands (not the behaviour). In short, it's a bit pointless.
Requirements:
- Test::More for Perl
- bats for Bash
Run the following commands to start the tests.
# In the project root
prove -l
bats -t t
- Arch Wiki page about PRIME, used for switchable graphics
- Wikipedia page about GPU switching
This software is copyright (c) 2019 by Tilwa Qendov.
This is free software, licensed under the Artistic License 2.0 (GPL Compatible)