summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-07-12 12:54:48 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-07-13 15:49:37 -0700
commit7587767428d7c88200462dc3f25f6f8ca6f4cc6a (patch)
tree3135b93d0a05f7c39e1785ef3e37b3d1a8147dfc /bin
parentd1b6b3b6a3526f73ed44b608363fc6d06addf4fb (diff)
downloaddotfiles-7587767428d7c88200462dc3f25f6f8ca6f4cc6a.tar.gz
debian-ftp-master: go back to existing windows
Now that they are persistent thanks to ssh-and-tmux-term.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/debian-ftp-master163
1 files changed, 87 insertions, 76 deletions
diff --git a/bin/debian-ftp-master b/bin/debian-ftp-master
index a64f129e..a7babde4 100755
--- a/bin/debian-ftp-master
+++ b/bin/debian-ftp-master
@@ -17,15 +17,15 @@ set -e
# exit 1
# fi
-# kill off any broken session (e.g. lost WiFi)
-wmctrl -c "ftp-master session cleanup" ||:
-wmctrl -c "ftp-master dak command session" ||:
-wmctrl -c "ftp-master GNU mc session" ||:
-wmctrl -c "*NEW notes*" ||:
-# wait, in case xfce4-terminal prompted the user
-while wmctrl -l | grep -q -E "ftp-master (session cleanup|dak command session|GNU mc session)"; do
- sleep 1
-done
+# # kill off any broken session (e.g. lost WiFi)
+# wmctrl -c "ftp-master session cleanup" ||:
+# wmctrl -c "ftp-master dak command session" ||:
+# wmctrl -c "ftp-master GNU mc session" ||:
+# wmctrl -c "*NEW notes*" ||:
+# # wait, in case xfce4-terminal prompted the user
+# while wmctrl -l | grep -q -E "ftp-master (session cleanup|dak command session|GNU mc session)"; do
+# sleep 1
+# done
# If there are no other Emacs frames open, the title of the frame will
# be emacs@$HOST rather than *NEW notes*, which means we can't control
@@ -34,8 +34,6 @@ if ! wmctrl -lx | grep -q "emacs.Emacs"; then
emacsclient -c -a '' -n -e '(switch-to-buffer "*scratch*")'
fi
-first="$(i3-fresh-workspace)"
-
# first establish a control socket, so that the two interactive ssh
# connections don't race to do this and one of them disables multiplexing
ssh -fN ftp-master.debian.org
@@ -57,74 +55,87 @@ ssh ftp-master.debian.org pgrep -u spwhitton emacs \
# sleep 0.3
# done
-ssh-and-tmux-term ftp-master.debian.org dak "ftp-master dak command session"
-until wmctrl -l | grep -q "ftp-master dak command session"; do
- sleep 0.3
-done
-wmctrl -R "ftp-master dak command session"
-
-# if we have the `layout tabbed` above, before any windows are opened,
-# the workspace ends up with a tabbed container inside a tabbed
-# container on buster's i3 (but not stretch's)
-i3-msg layout tabbed
-
-ssh-and-tmux-term ftp-master.debian.org mc "ftp-master GNU mc session"
-until wmctrl -l | grep -q "ftp-master GNU mc session"; do
- sleep 0.3
-done
-wmctrl -R "ftp-master GNU mc session"
-
-emacsclient -c -a '' -n -e '(progn (switch-to-buffer "*NEW notes*") (text-mode))'
-until wmctrl -l | grep -q "*NEW notes*"; do
- sleep 0.3
-done
-wmctrl -R "*NEW notes*"
-
-# Now we've the windows opened, arrange them. For some reason, in
-# order to have the resize commands take effect, there has to be a
-# pause before each resize command is issued, i.e. separate i3-msg
-# calls separated by calls to sleep
monitors="$(xrandr -q | grep ' connected' | wc -l)"
-monwidth="$(xdpyinfo | awk '/dimensions/{print $2}' | cut -dx -f1)"
-if [ $monitors -gt 1 ] ; then
- second="$(i3-fresh-workspace)"
- i3-msg workspace "$first"
- # ensure mc window is on primary output, since I spend more time
- # in it (I think this is sensible!)
- i3-msg move workspace to output primary
- # move the dak control window
- i3-msg focus left, focus left, move to workspace "$second"
- # split windows
- i3-msg move up
- sleep 0.2
- i3-msg resize set height 70 ppt
- # machine-specific: move workspace 9 to the secondary monitor, if
- # we know what that's called. Otherwise, user can just manually
- # move workspace 9 to the correct monitor right after executing
- # this script; workspace 7 will be left displayed on the primary
- # monitor
- if [ "$(hostname -f)" = "iris.silentflame.com" ]; then
- i3-msg workspace "$second"
- i3-msg move workspace to output LVDS-1
- i3-msg workspace "$second"
- else # no machine-specific config
- # ensure dak control window focused
- i3-msg workspace "$first"
+
+if ! wmctrl -l | grep -q "ftp-master dak command session"; then
+ first="$(i3-fresh-workspace)"
+
+ ssh-and-tmux-term ftp-master.debian.org dak "ftp-master dak command session"
+ until wmctrl -l | grep -q "ftp-master dak command session"; do
+ sleep 0.3
+ done
+ wmctrl -R "ftp-master dak command session"
+
+ # if we have the `layout tabbed` above, before any windows are opened,
+ # the workspace ends up with a tabbed container inside a tabbed
+ # container on buster's i3 (but not stretch's)
+ i3-msg layout tabbed
+
+ ssh-and-tmux-term ftp-master.debian.org mc "ftp-master GNU mc session"
+ until wmctrl -l | grep -q "ftp-master GNU mc session"; do
+ sleep 0.3
+ done
+ wmctrl -R "ftp-master GNU mc session"
+
+ emacsclient -c -a '' -n -e '(progn (switch-to-buffer "*NEW notes*") (text-mode))'
+ until wmctrl -l | grep -q "*NEW notes*"; do
+ sleep 0.3
+ done
+ wmctrl -R "*NEW notes*"
+
+ # Now we've the windows opened, arrange them. For some reason, in
+ # order to have the resize commands take effect, there has to be a
+ # pause before each resize command is issued, i.e. separate i3-msg
+ # calls separated by calls to sleep
+ monwidth="$(xdpyinfo | awk '/dimensions/{print $2}' | cut -dx -f1)"
+ if [ $monitors -gt 1 ] ; then
+ second="$(i3-fresh-workspace)"
+ i3-msg workspace "$first"
+ # ensure mc window is on primary output, since I spend more time
+ # in it (I think this is sensible!)
+ i3-msg move workspace to output primary
+ # move the dak control window
+ i3-msg focus left, focus left, move to workspace "$second"
+ # split windows
+ i3-msg move up
+ sleep 0.2
+ i3-msg resize set height 70 ppt
+ # machine-specific: move workspace 9 to the secondary monitor, if
+ # we know what that's called. Otherwise, user can just manually
+ # move workspace 9 to the correct monitor right after executing
+ # this script; workspace 7 will be left displayed on the primary
+ # monitor
+ if [ "$(hostname -f)" = "iris.silentflame.com" ]; then
+ i3-msg workspace "$second"
+ i3-msg move workspace to output LVDS-1
+ i3-msg workspace "$second"
+ else # no machine-specific config
+ # ensure dak control window focused
+ i3-msg workspace "$first"
+ fi
+ elif [ $monwidth -ge 1920 ]; then
+ # three column split (i.e. two mc columns and dak column) should
+ # work on a monitor this big (after some tweaking of mc's display
+ # settings)
+ i3-msg move down, focus up, focus left, move right, move right, move right
+ sleep 0.2
+ i3-msg resize set width 30 ppt, focus left
+ sleep 0.2
+ i3-msg resize set height 70 ppt, focus right
+ else
+ # small screen view
+ i3-msg focus left, split v, focus right, move left
+ sleep 0.2
+ i3-msg resize set height 30 ppt, focus up, focus left
fi
-elif [ $monwidth -ge 1920 ]; then
- # three column split (i.e. two mc columns and dak column) should
- # work on a monitor this big (after some tweaking of mc's display
- # settings)
- i3-msg move down, focus up, focus left, move right, move right, move right
- sleep 0.2
- i3-msg resize set width 30 ppt, focus left
- sleep 0.2
- i3-msg resize set height 70 ppt, focus right
else
- # small screen view
- i3-msg focus left, split v, focus right, move left
- sleep 0.2
- i3-msg resize set height 30 ppt, focus up, focus left
+ wmctrl -a "ftp-master dak command session"
+ if [ "$(hostname -f)" = "iris.silentflame.com" ] \
+ && [ $monitors -gt 1 ]; then
+ i3-msg move workspace to output LVDS-1
+ wmctrl -a "ftp-master GNU mc session"
+ fi
+ i3-msg move workspace to output primary
fi
# ssh athena tmux send-keys -t irssi DOWN