diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-18 22:09:26 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-19 19:50:21 -0700 |
commit | 5445799aeb21cac8c43b62b4361b8ebd65b01177 (patch) | |
tree | 2954057393b5af001718b8aa2da422408f6d7584 /scripts | |
parent | 4d2a37ed9bf3aeb911701ccd74423ccbfcf2f968 (diff) | |
download | dotfiles-5445799aeb21cac8c43b62b4361b8ebd65b01177.tar.gz |
rewrite debian-ftp-master{,cut-note} for sway
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/desktop/sway-ftp-master | 84 | ||||
-rwxr-xr-x | scripts/desktop/sway-ftp-master-cut-note | 12 |
2 files changed, 96 insertions, 0 deletions
diff --git a/scripts/desktop/sway-ftp-master b/scripts/desktop/sway-ftp-master new file mode 100755 index 00000000..5ac8fbbd --- /dev/null +++ b/scripts/desktop/sway-ftp-master @@ -0,0 +1,84 @@ +#!/usr/bin/perl + +# sway-ftp-master -- set up some windows for doing work on Debian's ftp-master +# +# Copyright (C) 2019, 2021 Sean Whitton +# +# GPL-3 or later + +use 5.032; +use strict; +use warnings; + +use JSON; + +sub walk_tree (&$) { + my ($pred, $tree) = @_; + $pred->($tree) and return $tree; + map &walk_tree($pred, $_), $tree->{nodes}->@*, $tree->{floating_nodes}->@*; +} + +sub title_exists { + my $name = shift; + walk_tree { $_->{name} and $_->{name} eq $name } + decode_json `swaymsg -t get_tree`; +} + +sub marked_exists { + my $mark = shift; + walk_tree { grep $_ eq $mark, $_->{marks}->@* } + decode_json `swaymsg -t get_tree`; +} + +sub focus_title { system "swaymsg", qq|[title="$_[0]"]|, "focus" } + +sub focus_marked { system "swaymsg", qq|[con_mark="$_[0]"]|, "focus" } + +if (marked_exists "dak") { + focus_marked "dak"; +} else { + # first establish a control socket, so that the two interactive ssh + # connections don't race to do this and one of them disables multiplexing + system "ssh", "-fN", "ftp-master.debian.org"; + + # start Emacs on ftp-master + 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`; + + fork // die "couldn't fork" + or exec "ssh-and-tmux-term", "ftp-master.debian.org", "dak", + "ftp-master dak command session"; + sleep 0.3 until marked_exists "dak"; + focus_marked "dak"; + + fork // die "couldn't fork" + or exec "ssh-and-tmux-term", "ftp-master.debian.org", "mc", + "ftp-master GNU mc session"; + sleep 0.3 until marked_exists "mc"; + focus_marked "mc"; + + system "emacsclient", "-c", "-a", "", "-n", "-e", + '(progn (switch-to-buffer "*NEW notes*") (text-mode))'; + sleep 0.3 until title_exists "*NEW notes*"; + focus_title "\\*NEW notes\\*"; + + # currently we implement only the layout the X11 script chose for melete + + system "swaymsg", + "move down,", + "focus up,", + "focus left,", + "move right,", + "move right,", + "move right,", + "split v,", + "layout tabbed,", + "resize set width 35,", + "focus left,", + "split v,", + "layout tabbed,", + "resize set height 65,", + "focus right"; +} diff --git a/scripts/desktop/sway-ftp-master-cut-note b/scripts/desktop/sway-ftp-master-cut-note new file mode 100755 index 00000000..09480303 --- /dev/null +++ b/scripts/desktop/sway-ftp-master-cut-note @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +emacsclient -eval '(with-current-buffer "*NEW notes*" + (gui-set-selection nil (buffer-string)) + (erase-buffer))' + +# first select mc window ready for processing the next package +swaymsg '[con_mark="mc"] focus; [con_mark=dak] focus' + +wtype -M shift -k insert |