Add fix_screen_tearing.pl

This commit is contained in:
Ivan Malison 2016-09-12 20:00:38 -07:00
parent 6e8cae42c5
commit 645ae18a05
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -0,0 +1,28 @@
#!/usr/bin/perl
# Quickly set ForceFullCompositionPipeline with nvidia-settings for all currently connected screens, useful for gamers seeing screen tear issues
use strict;
use warnings;
# Grab xrandr output for parsing
my $xrandrOutput = `xrandr`;
# Filter all currently selected modes
my @modes = $xrandrOutput =~ /.*\sconnected.*/g;
die "Output didn't match expected format\n" if ( scalar @modes lt 1 );
my @newModes = ();
foreach my $mode ( @modes )
{
# Filter the current modes and add to list in right format
my @details = $mode =~ /(.*)\sconnected.*?(\d[^\s]+).*/g;
die "Output didn't match expected format\n" if ( scalar @details lt 2 );
push( @newModes, join( ":", @details ) );
}
# Construct the new mode command
my $newModeCommand = "nvidia-settings --assign CurrentMetaMode='";
$newModeCommand .= "$_ { ForceFullCompositionPipeline = On }, " foreach ( @newModes );
$newModeCommand .= "'";
# Print and set our new mode
print "running \"$newModeCommand\"\n";
system( $newModeCommand );