17.04 Display scaling reverting to 1 after resume from suspend?

For anyone else being frustrated by this bug, here's a quick perl script to watch for changes in the scale_factor value and reset to whatever the value is when the script was first run:

#!/usr/bin/perl -w
use strict;

my $dconf_line = `dconf read /com/ubuntu/user-interface/scale-factor`;
my ($scale_factor) = $dconf_line =~ m/DP1\': (\d+)/;

if ($scale_factor) {
    print STDOUT "Current value of scale_factor: $scale_factor ...\n\n";
} else {
    die "Error: cannot find scale_factor value in dconf\n(value of /com/ubuntu/user-interface/scale-factor was $dconf_line\n\n";
}

open(my $fh, "-|", "dconf watch /com/ubuntu/user-interface/scale-factor");

while (<$fh>) {
    if (m/DP1\': (?!$scale_factor)/) {
        `dconf write /com/ubuntu/user-interface/scale-factor "{'DP1': $scale_factor}"`;
        my $date = `date`;
        print STDOUT "$date -- scaling factor adjusted\n\n";
    }
}

Just leave the script running, and it'll catch and reset any attempts to change away from the value.

Works for me on 17.04 with unity, but it's possible that with the switch to gnome in 17.10 the value is stored in a different dconf registry key -- if so, just replace all instances of the key location in the script with the appropriate one and it should work.

Hope this helps ...