diff options
Diffstat (limited to 'perl5/Local/Desktop.pm')
-rw-r--r-- | perl5/Local/Desktop.pm | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/perl5/Local/Desktop.pm b/perl5/Local/Desktop.pm index f769d827..0460447e 100644 --- a/perl5/Local/Desktop.pm +++ b/perl5/Local/Desktop.pm @@ -33,9 +33,6 @@ use List::Util "first", "any"; use Local::Desktop::WMIPC; our @EXPORT = qw( - @all_workspaces - fresh_workspace - compact_workspaces select_wallpaper_files ensure_resize_for_current_outputs resize_for_current_outputs @@ -43,86 +40,6 @@ our @EXPORT = qw( my $output_re = qr/ ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) /; -our @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" -); - -=head fresh_workspace($send) - -Switch to the next free workspace, if any. Return the name of that workspace, -or undef if no workspace was available. If $send, send the current window to -the fresh workspace instead of switching focus there. - -=cut - -sub fresh_workspace { - my $next_free_workspace = compact_workspaces(leave_gap => 1); - - if ($next_free_workspace) { - my @cmds; - my %opts = @_; - - push @cmds, "move container to workspace $next_free_workspace" - if $opts{send}; - - # When !$opts{go} we should execute neither of these commands, but we - # must work around <https://github.com/swaywm/sway/issues/6081>. - # - # In the case that !$opts{go}, can use 'C-i S-;' to move any other - # wanted containers over, before finally going there with 'C-i ;'. - push @cmds, "workspace $next_free_workspace"; - push @cmds, "workspace back_and_forth" unless $opts{go}; - - Local::Desktop::WMIPC->new->cmd(@cmds); - } - $next_free_workspace -} - -=head compact_workspaces(%opts) - -Rename workspaces so as to remove gaps in the sequence of workspaces. - -If C<$opts{leave_gap}>, ensure there is a gap of one workspace after the -currently focused workspace and return the name of the gap workspace, or just -return undef if there is no space for a gap. - -=cut - -sub compact_workspaces { - my %opts = @_; - my $wmipc = Local::Desktop::WMIPC->new; - my @workspaces; - foreach my $ws ($wmipc->get_workspaces->@*) { - any { $_ eq $ws->{name} } @all_workspaces and push @workspaces, $ws - } - @workspaces < @all_workspaces or return; - my ($current_workspace, $gap_workspace); - if ($opts{leave_gap}) { - $_->{focused} and $current_workspace = $_->{name}, last - for @workspaces - } - - my ($i, @cmds); - while (my $next = shift @workspaces) { - my $workspace = $all_workspaces[$i++]; - $opts{leave_gap} - and $next->{name} eq $current_workspace - and $gap_workspace = $all_workspaces[$i++]; - next if $next->{name} eq $workspace; - my $pair = [$next->{name}, $workspace]; - _wsnum($next->{name}) > _wsnum($workspace) - ? push @cmds, $pair - : unshift @cmds, $pair - } - - $wmipc->cmd(map "rename workspace $_->[0] to $_->[1]", @cmds); - - $opts{leave_gap} and $gap_workspace -} - =head select_wallpaper_files(@files) Select the first entry of @files as the wallpaper for the first output, the |