diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-01-03 23:25:43 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-01-04 11:11:55 -0700 |
commit | 35b66310cc54a6e06e060a9b471fbfc43ff0341e (patch) | |
tree | 1d0be75041229c9a5595a8663b5f26655cd57d11 /scripts | |
parent | ab924009cb7e84fcdc95935d9d5bda66ee113789 (diff) | |
download | dotfiles-35b66310cc54a6e06e060a9b471fbfc43ff0341e.tar.gz |
move fresh-workspace into lib so sway-ftp-master need not shell out
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/desktop/fresh-workspace | 44 | ||||
-rwxr-xr-x | scripts/desktop/sway-ftp-master | 4 |
2 files changed, 6 insertions, 42 deletions
diff --git a/scripts/desktop/fresh-workspace b/scripts/desktop/fresh-workspace index 7251ed07..e04e8338 100755 --- a/scripts/desktop/fresh-workspace +++ b/scripts/desktop/fresh-workspace @@ -1,43 +1,5 @@ #!/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" -); - -`which i3-msg`; -my $exec = $? == 0 ? "i3-msg" : "swaymsg"; - -my %current_names = map +($_->{name}, undef), - @{ decode_json `$exec -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 - "$exec move container to workspace $next_free_workspace" - # Only the first of the three commands within this call to i3-msg - # should be necessary, but we need the others to work around - # https://github.com/swaywm/sway/issues/6081 - .", workspace $next_free_workspace, workspace back_and_forth >/dev/null"; - } else { - system "$exec workspace $next_free_workspace >/dev/null"; - } -} - -# added for the benefit of ~/src/dotfiles/bin/debian-ftp-master -print "$next_free_workspace\n"; +use lib "$ENV{HOME}/src/dotfiles/perl5"; +use Local::Desktop; +exit !defined fresh_workspace grep $_ eq "--send", @ARGV diff --git a/scripts/desktop/sway-ftp-master b/scripts/desktop/sway-ftp-master index 5ac66a2e..dd90663c 100755 --- a/scripts/desktop/sway-ftp-master +++ b/scripts/desktop/sway-ftp-master @@ -9,8 +9,10 @@ use 5.032; use strict; use warnings; +use lib "$ENV{HOME}/src/dotfiles/perl5"; use JSON; +use Local::Desktop; sub walk_tree (&$) { my ($pred, $tree) = @_; @@ -45,7 +47,7 @@ if (marked_exists "dak") { system "ssh", "ftp-master.debian.org", "pgrep", "-u", "spwhitton", "emacs", "||", "ssh", "ftp-master.debian.org", "emacs", "--daemon", "&"; - my ($first) = `~/src/dotfiles/scripts/desktop/fresh-workspace`; + my $first = fresh_workspace() // die "no fresh workspace"; fork // die "couldn't fork" or exec "foot", "--override=locked-title=yes", |