diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-04 10:12:40 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-04 10:12:40 -0700 |
commit | 7de922d5c31d45102f1a132ed5c24f9550b81da1 (patch) | |
tree | 26e8b775c849b4f9960006be01ad430d0f0964b9 /scripts | |
parent | 3ead88a5b944974ab6b436b22f9f407b8f7c7b90 (diff) | |
download | dotfiles-7de922d5c31d45102f1a132ed5c24f9550b81da1.tar.gz |
move i3-fresh-workspace
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/desktop/fresh-workspace | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/desktop/fresh-workspace b/scripts/desktop/fresh-workspace new file mode 100755 index 00000000..89a5de48 --- /dev/null +++ b/scripts/desktop/fresh-workspace @@ -0,0 +1,36 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use JSON; +use List::Util "first"; + +my @all_workspaces = ( + "1", "2", "3", "4", "5", "6", + "7", "8", "9", "10", "11:F1", "12:F2", + "13:F3", "14:F4", "15:F5", "16:F6", "17:F7", "18:F8", + "19:F9", "20:F10", "21:F11", "22:F12" +); + +my %current_names = map +($_->{name}, undef), + @{ decode_json `i3-msg -t get_workspaces` }; + +my $next_free_workspace + = first { not exists $current_names{$_} } @all_workspaces; + +if ($next_free_workspace) { + if (grep /--send/, @ARGV) { + # Send it there but don't change focus. User can use 'move + # container to workspace back_and_forth' binding to move any + # other wanted containers over there, before finally switching + # the view with 'workspace back_and_forth' + system + "i3-msg move container to workspace $next_free_workspace >/dev/null"; + } else { + system "i3-msg workspace $next_free_workspace >/dev/null"; + } +} + +# added for the benefit of ~/src/dotfiles/bin/debian-ftp-master +print "$next_free_workspace\n"; |