Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move settings to xprofile and don't overwrite existing settings. #182

Merged
merged 11 commits into from
Jan 8, 2021
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
system76-driver (20.04.23~~alpha) focal; urgency=low

* Move serw12 ForceFullCompositionPipeline from profile to xprofile
* Daily WIP for 20.04.23

-- Jacob Kauffmann <jacob@system76.com> Tue, 05 Jan 2021 15:18:59 -0700

system76-driver (20.04.22) focal; urgency=low

* Add darp7
Expand Down
2 changes: 1 addition & 1 deletion system76driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import logging


__version__ = '20.04.22'
__version__ = '20.04.23'

datadir = path.join(path.dirname(path.abspath(__file__)), 'data')
log = logging.getLogger(__name__)
Expand Down
42 changes: 37 additions & 5 deletions system76driver/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,15 +1424,47 @@ def describe(self):
return _('Enable ForceFullCompositionPipeline in the NVIDIA driver')

def __init__(self, etcdir='/etc'):
self.filename = path.join(etcdir, 'profile.d', 's76-nvidia-fullcomp.sh')
self.oldfilename = path.join(etcdir, 'profile.d', 's76-nvidia-fullcomp.sh')
self.filename = path.join(etcdir, 'xprofile')

def read(self):
return open(self.filename, 'r').read()

def get_isneeded(self):
return not os.path.exists(self.filename)
if os.path.exists(self.oldfilename):
return True
elif not os.path.exists(self.filename):
return True
elif not "ForceFullCompositionPipeline" in self.read():
return True
else:
return False

def perform(self):
content = '# Added by system76-driver.\n'
content += '# Force a full composition pipeline to prevent stuttering.\n'
content += 'nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }"\n'
if os.path.exists(self.oldfilename):
try:
os.remove(self.oldfilename)
except:
pass
if os.path.exists(self.filename):
if "ForceFullCompositionPipeline" in self.read():
return
content = self.read_and_backup()
content += '\n# Added by system76-driver.\n'
else:
content = '# Added by system76-driver.\n'
content += '# Force a full composition pipeline to prevent stuttering.\n\n'
content += '# Get the current display settings.\n'
content += 'oldmode=$(echo $(nvidia-settings -q CurrentMetaMode) | sed -e \'s/.*:: //g\')\n\n'
jacobgkau marked this conversation as resolved.
Show resolved Hide resolved
content += '# If there were no old settings, then apply a default setting;\n'
content += '# otherwise, add ForceFullCompositionPipeline to the old settings.\n'
content += 'if [ -z "$oldmode" ]\n'
content += 'then\n'
content += ' newmode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On}"\n'
content += 'else\n'
content += ' newmode=$(echo $oldmode | sed \'s/}/, ForceFullCompositionPipeline=On}/g\')\nfi\n\n'
jacobgkau marked this conversation as resolved.
Show resolved Hide resolved
content += '# Apply the new display settings.\n'
content += 'nvidia-settings --assign CurrentMetaMode="$newmode"\n'
self.atomic_write(content)

class nvidia_dynamic_power_one(FileAction):
Expand Down