diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-05-18 11:34:37 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-05-18 11:34:37 -0700 |
commit | a90eb437d8ef66d9c5396036f4f393491b12dece (patch) | |
tree | 8882335a7872a0a69fb94bd3d9f481fa81b9ee8b /bin | |
parent | 1c6acc54642df976ad7f150876e9fa2184057f6b (diff) | |
download | dotfiles-a90eb437d8ef66d9c5396036f4f393491b12dece.tar.gz |
use hashes for lookups
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/i3-fresh-workspace | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/bin/i3-fresh-workspace b/bin/i3-fresh-workspace index 236551da..9e576fd0 100755 --- a/bin/i3-fresh-workspace +++ b/bin/i3-fresh-workspace @@ -12,15 +12,14 @@ my @all_workspaces = ( "19:F9", "20:F10", "21:F11", "22:F12" ); -my @current_names = map $_->{name}, +my %current_names = map +($_->{name}, undef), @{ decode_json `i3-msg -t get_workspaces` }; # filter @current_names out of @all_workspaces while preserving the # order of @all_workspaces my @free_workspaces; foreach my $workspace (@all_workspaces) { - push @free_workspaces, $workspace - unless grep /\A$workspace\z/, @current_names; + push @free_workspaces, $workspace unless exists $current_names{$workspace}; } if (my $next_free_workspace = shift @free_workspaces) { |