Skip to content

Commit

Permalink
Fix ordering in the 4th configuration
Browse files Browse the repository at this point in the history
Also stop throwing warnings with AMDGPU where no explicit configuration
was created.
  • Loading branch information
Code7R committed Oct 7, 2023
1 parent ec8f8f2 commit 9980833
Showing 1 changed file with 37 additions and 14 deletions.
51 changes: 37 additions & 14 deletions contrib/icewm-menu-xrandr
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ $xrandr.=" --verbose";
sub strip_tfield
{
my $name = substr($_[0], $_[1], 13);
print "heh: $name\n" if $debug > 4;
print "# Raw name: $name\n" if $debug > 4;
$name=~s/^\W.*//;
$name=~s/(\r|\n|\0).*//;
$name=~s/\W$//;
print "Decoded: $name\n" if $debug > 2;
print "# Decoded: $name\n" if $debug > 2;
return $name;
}

Expand All @@ -94,13 +94,14 @@ sub load_ini
next if ! -r $_;
my $fd;
my %cfg;
if (open($fd, "<$_"))

{
{
my %cfg=( "sectype" => "main");
push(@cfiledata, \%cfg);
}
my %cfg=( "sectype" => "main");
push(@cfiledata, \%cfg);
}

if (open($fd, "<$_"))
{
for (<$fd>)
{
s/^\s+//;
Expand Down Expand Up @@ -174,9 +175,19 @@ sub match_output
{
my $output = shift;
my @ret = ();
#print Dumper("# cfiledata:", @cfiledata) if $debug > 4;

if (! scalar @cfiledata)
{
return @ret;
}

for my $xr (@cfiledata)
{
next unless ($$xr{"sectype"} eq "main" || $$xr{"sectype"} eq "output");
#print "# What is this?".Dumper("# $xr -> ", $xr) if $debug > 5;
my $st = $$xr{"sectype"};
next if !defined($st);
next unless ($st eq "main" || $st eq "output");

my $fil = $$xr{"match-name"};
if (defined($fil))
Expand Down Expand Up @@ -232,7 +243,9 @@ sub pick_for_combo
my $val;
for my $xr (@cfiledata)
{
next unless ($$xr{"sectype"} eq "main" || $$xr{"sectype"} eq "combo");
my $st = $$xr{"sectype"};
next if ! defined($st);
next unless ($st eq "main" || $st eq "combo");
my $fil = ($$xr{"match-name"} or $$xr{"match-label"});
if (defined($fil))
{
Expand Down Expand Up @@ -271,39 +284,46 @@ sub read_xrandr
{
print "# DBG: $_" if $debug > 4;
my $resFound =/(\d+x\d+\++\d)/;
# compressed, non-verbose output
if(/^(\w\S*)\s+(connected|disconnected)\s+(primary)?/)
{
# parse state helper var
$curmon = $1;
$prim = $curmon if $3;
# print "# heh? $1 - $2 - $3 - $4\n";
print "# curmon hit? $1 - $2 - ".(defined($3) ? $3 : "")."\n" if $debug > 4;
# disconnected and also no active resolution set!
$disabled = ($2 eq "disconnected") && !$resFound;
if($disabled)
{
print "# marked as disabled: $curmon\n" if $debug > 4;
#$turnRestOff.=" --display $curmon --off";
}
else
{
print "# add as connected: $curmon" if $debug > 4;
push(@connected, $curmon);
}
}

# consider active only when there is a flag in the resolution list...
$active{$curmon} = (/^\s.*\*current/ && !$disabled) if $curmon;

if (defined($currentEdid)) {
# print "# consider: $curmon" if $debug > 4;
if (defined($currentEdid))
{
if (/:/) # now analyze and stop merging
{
parse_edid($currentEdid, $curmon);
undef $currentEdid;
}
else {
else
{
/(\w+)/;
$currentEdid .= $1;
}
}
elsif (/EDID:/) {
elsif (/EDID:/)
{
$currentEdid = "";
}
}
Expand Down Expand Up @@ -392,6 +412,9 @@ sub add_conf
my $newPrim = $cmdHints[0];
my %dedup;
my @xcmds;

print "add_conf: $showname, $icon, $cmd, $postCmdHint" if $debug > 4;

for my $involved (@cmdHints)
{
print "# affected: $involved\n" if $debug;
Expand Down Expand Up @@ -450,7 +473,7 @@ sub run
[$prim, $sec]
);
add_conf(nameOf($sec)." + ".nameOf($prim, 1), "setscreen21",
ajoin(fmtOutputMode($sec), loc($sec), fmtOutputMode($prim), $priFlag, loc($prim, $lof, $sec), $killRest),
ajoin(fmtOutputMode($sec), loc($sec), fmtOutputMode($prim), $priFlag, loc($prim, $rof, $sec), $killRest),
[$prim, $sec]);
add_conf(nameOf($prim)." + ".nameOf($sec, 1), "setscreen12x",
ajoin(fmtOutputMode($prim), loc($prim), fmtOutputMode($sec), $priFlag, loc($sec, $rof, $prim), $killRest),
Expand Down

0 comments on commit 9980833

Please sign in to comment.