diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-08-15 09:19:39 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-08-17 16:18:14 -0700 |
commit | 0277189d5fe4ac4a452a2568db4d5ec97c793286 (patch) | |
tree | dc100bdb2cf7d1dd8295e3ede11b625ba58238ab /scripts | |
parent | 0ad52a42d64f91d71f43c47fad87746c1afa6fb4 (diff) | |
download | dotfiles-0277189d5fe4ac4a452a2568db4d5ec97c793286.tar.gz |
handle workspace_buttons out in i3status-wrapper, compact less often
Even if we were to uncomment the call to compact_workspaces in
i3status-wrapper, (the rest of) this change would still mean we would do fewer
get_workspaces queries overall.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/desktop/i3status-wrapper | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper index af487b0c..7a9c489b 100755 --- a/scripts/desktop/i3status-wrapper +++ b/scripts/desktop/i3status-wrapper @@ -80,6 +80,9 @@ my $caffeinated_id; open my $events, "-|", $wmipc, "-t", "subscribe", "-m", '[ "window", "workspace" ]'; +my $workspaces = @{ decode_json `$wmipc -t get_workspaces` }; +$workspaces > 1 or wmipc "bar bar-0 workspace_buttons no"; + while (my $event = decode_json <$events>) { if ($event->{change} eq "mark") { if (grep $_ eq "caffeinated", $event->{container}{marks}->@*) { @@ -91,7 +94,15 @@ while (my $event = decode_json <$events>) { undef $caffeinated_id, undef $info{caffeinated_name}; kill USR1 => $i3status; } - } elsif ($event->{change} eq "init" or $event->{change} eq "empty") { - compact_workspaces; + } elsif ($event->{change} eq "init") { + ++$workspaces == 2 and wmipc "bar bar-0 workspace_buttons yes"; + } elsif ($event->{change} eq "empty") { + --$workspaces == 1 and wmipc "bar bar-0 workspace_buttons no"; + + # For simplicity, only fresh-workspace script calls compact_workspaces + # atm. For greater consistency we could call it here, too, without + # supplying a leave_gap argument. + + # compact_workspaces; } } |