diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-08-16 19:58:53 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-08-16 19:59:12 -0400 |
commit | 66a8d0da9d0510bb50c7d0b07870aa90f311ba55 (patch) | |
tree | a7a573d066e3cc7db60d583aba12c4b4e736c562 | |
parent | 01f3ef3680be0bb115a1d38439a88bbb02d1802a (diff) | |
download | conf-66a8d0da9d0510bb50c7d0b07870aa90f311ba55.tar.gz conf-66a8d0da9d0510bb50c7d0b07870aa90f311ba55.zip |
handle switching workspaces with no windows open
-rwxr-xr-x | bin/i3-switch-workspace | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/bin/i3-switch-workspace b/bin/i3-switch-workspace index 6c674fb..a90be29 100755 --- a/bin/i3-switch-workspace +++ b/bin/i3-switch-workspace @@ -30,7 +30,18 @@ my $workspace_data = $json->decode(i3_msg('get_workspaces')); 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 (@$workspace_data == 1) { + 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 ($dir eq 'prev') { + i3_msg('command', "workspace number $prev_workspace"); + } + else { + i3_msg('command', "workspace number $next_workspace"); + } +} +elsif ($workspace_data->[0]{focused} && $dir eq 'prev') { 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); |