From 645ae18a05504033864c06c28c8c265a7a3b7391 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 12 Sep 2016 20:00:38 -0700 Subject: [PATCH] Add fix_screen_tearing.pl --- dotfiles/lib/bin/fix_screen_tearing.pl | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 dotfiles/lib/bin/fix_screen_tearing.pl diff --git a/dotfiles/lib/bin/fix_screen_tearing.pl b/dotfiles/lib/bin/fix_screen_tearing.pl new file mode 100755 index 00000000..5f6a9aa8 --- /dev/null +++ b/dotfiles/lib/bin/fix_screen_tearing.pl @@ -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 );