Last active
September 27, 2021 16:29
-
-
Save acrosby/7752382 to your computer and use it in GitHub Desktop.
Python alias script for retrying "optirun" if fallback fails.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import subprocess, sys, shlex | |
#command = shlex.split(sys.argv[1]) | |
command = "optirun " + sys.argv[1] | |
test = True | |
c = 0 | |
while test: | |
print "Running", command | |
call = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
out, err = call.communicate() | |
returncode = call.returncode | |
if returncode == 0: | |
test = False | |
print out | |
elif returncode == 1: | |
if "deleted by window manager" in err: | |
break | |
else: | |
test = True | |
print out, err | |
else: | |
print out, err | |
break | |
print "Return Code", returncode | |
if c > 5: | |
break | |
else: | |
c += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment