diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-16 03:38:28 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-16 03:38:58 -0500 |
commit | b7992389f1bcf70d59415d4d466f11ed8fbd9e57 (patch) | |
tree | 566a4334032fce089ea23130a0dff2c0c4880ddc /bin | |
parent | 0a7205a3ff935e2e9177493675253a07db52120b (diff) | |
download | conf-b7992389f1bcf70d59415d4d466f11ed8fbd9e57.tar.gz conf-b7992389f1bcf70d59415d4d466f11ed8fbd9e57.zip |
more tweaks to the workspace switcher, i think this covers everything
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/i3-switch-workspace | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/bin/i3-switch-workspace b/bin/i3-switch-workspace index f3ae58a..6c674fb 100755 --- a/bin/i3-switch-workspace +++ b/bin/i3-switch-workspace @@ -31,26 +31,26 @@ my $next_workspace = $workspace_data->[-1]{num} + 1; my $prev_workspace = $workspace_data->[0]{num} - 1; if ($workspace_data->[0]{focused} && $dir eq 'prev') { - if ($prev_workspace < 0) { - i3_msg('command', "workspace number $next_workspace"); - } - else { - my $current_workspace = $workspace_data->[0]{num}; - my $tree_data = $json->decode(i3_msg('get_tree')); - my $workspace_tree = find_workspace($tree_data, $current_workspace); - if (@{ $workspace_tree->{nodes} }) { # note: not floating_nodes - i3_msg('command', "workspace number $prev_workspace"); + my $current_workspace = $workspace_data->[0]{num}; + my $tree_data = $json->decode(i3_msg('get_tree')); + my $workspace_tree = find_workspace($tree_data, $current_workspace); + if (@{ $workspace_tree->{nodes} } || @{ $workspace_tree->{floating_nodes} }) { + if ($prev_workspace < 0) { + i3_msg('command', "workspace number $next_workspace"); } else { - i3_msg('command', "workspace $dir"); + i3_msg('command', "workspace number $prev_workspace"); } } + else { + i3_msg('command', "workspace $dir"); + } } elsif ($workspace_data->[-1]{focused} && $dir eq 'next') { my $current_workspace = $workspace_data->[-1]{num}; my $tree_data = $json->decode(i3_msg('get_tree')); my $workspace_tree = find_workspace($tree_data, $current_workspace); - if (@{ $workspace_tree->{nodes} }) { # note: not floating_nodes + if (@{ $workspace_tree->{nodes} } || @{ $workspace_tree->{floating_nodes} }) { i3_msg('command', "workspace number $next_workspace"); } else { @@ -58,7 +58,13 @@ elsif ($workspace_data->[-1]{focused} && $dir eq 'next') { } } else { - i3_msg('command', "workspace $dir"); + for my $i (0..$#$workspace_data) { + if ($workspace_data->[$i]{focused}) { + my $to = $workspace_data->[$i]{num} + ($dir eq 'prev' ? -1 : 1); + i3_msg('command', "workspace number $to"); + last; + } + } } sub find_workspace { |