summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2024-02-22 08:36:48 +0800
committerSean Whitton <spwhitton@spwhitton.name>2024-02-22 08:36:52 +0800
commit49043f849913d02f31730ee34916d2c91ed2b8fc (patch)
treec08bdc790cff030a641318185fc3ac3af3d1bc64
parente713faaccc850b3df6b534c7e85ebc4976b7872d (diff)
downloaddotfiles-49043f849913d02f31730ee34916d2c91ed2b8fc.tar.gz
i3status-wrapper: make $last_dir workspace-specific
-rwxr-xr-xscripts/desktop/i3status-wrapper16
1 files changed, 8 insertions, 8 deletions
diff --git a/scripts/desktop/i3status-wrapper b/scripts/desktop/i3status-wrapper
index fb8d4e34..64db2da9 100755
--- a/scripts/desktop/i3status-wrapper
+++ b/scripts/desktop/i3status-wrapper
@@ -95,7 +95,8 @@ unless (fork // warn "couldn't fork monitoring loop") {
if ($node->{type} eq "workspace"
&& grep $_ eq $node->{name}, @all_workspaces) {
my $entry = $info{paper_ws}{$node->{id}}
- //= { name => $node->{name}, off_left => [], off_right => [] };
+ //= { name => $node->{name}, off_left => [], off_right => [],
+ last_dir => 1 };
sync_cols($node => $entry);
$entry->{ncols} = max 2, scalar $entry->{cols}->@*;
} elsif (grep $_ eq "caffeinated", $node->{marks}->@*) {
@@ -171,7 +172,7 @@ unless (fork // warn "couldn't fork monitoring loop") {
&& grep $_ eq $e->{current}{name}, @all_workspaces) {
$info{paper_ws}{$e->{current}{id}}
= { name => $e->{current}{name}, ncols => 2, cols => [],
- off_left => [], off_right => [], };
+ off_left => [], off_right => [], last_dir => 1 };
} elsif ($e->{change} && $e->{change} eq "rename"
&& exists $info{paper_ws}{$e->{current}{id}}) {
$info{paper_ws}{$e->{current}{id}}{name}
@@ -224,7 +225,6 @@ unless (fork // warn "couldn't fork command pipe reader") {
my $cols = $ws->{cols};
my $col_rows = $info{col_rows}{$ws->{focused_col}};
my $i = first { $cols->[$_] == $ws->{focused_col} } 0..$#$cols;
- state $last_dir = 1;
my $mv = sub {
my ($j, $move) = @_;
@@ -302,7 +302,7 @@ unless (fork // warn "couldn't fork command pipe reader") {
with_ignored_events { $wmipc->cmd(@cmds, hide_con($pushed)) };
kill USR1 => $i3status;
}
- $last_dir = $j > $i ? 1 : -1;
+ $ws->{last_dir} = $j > $i ? 1 : -1;
};
# Command dispatch
@@ -318,9 +318,9 @@ unless (fork // warn "couldn't fork command pipe reader") {
elsif ($cmd =~ /^other column$/) {
# This is meant to be similar to my custom Emacs C-x o.
- if ($i == 0 || $last_dir == -1 && $i < $#$cols) {
+ if ($i == 0 || $ws->{last_dir} == -1 && $i < $#$cols) {
$mv->($i+1);
- } elsif ($i == $#$cols || $last_dir == 1) {
+ } elsif ($i == $#$cols || $ws->{last_dir} == 1) {
$mv->($i-1);
}
} elsif ($cmd eq "monocle toggle\n") {
@@ -351,7 +351,7 @@ unless (fork // warn "couldn't fork command pipe reader") {
# Possibly we could float the container, select the
# appropriate full column and unfloat it into place?
$wmipc->cmd(sprintf "move %s", $dir > 0 ? "right" : "left");
- $last_dir = $dir;
+ $ws->{last_dir} = $dir;
} else { # absorb
my @cmds;
if ($i == 0 && $dir < 0 && $ws->{off_left}->@*) {
@@ -386,7 +386,7 @@ unless (fork // warn "couldn't fork command pipe reader") {
? min($#$cols, max 0, $i+$dir) : $i);
}
if (@cmds) {
- $last_dir = $dir;
+ $ws->{last_dir} = $dir;
kill USR1 => $i3status;
}
}