1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
#!/bin/bash
# debian-ftp-master -- set up some windows for doing work on Debian's ftp-master
# Copyright (C) 2019 Sean Whitton
#
# GPL-3 or later
set -e
. $HOME/.shenv
# # require irssi is already raiseable, as starting it is interactive in
# # a way we can't easily wait for
# if ! wmctrl -l | grep -q "irssi"; then
# zenity --error --no-wrap --text="Please attach to irssi first."
# 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
# # 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
# # it. So, ensure one is open
# if ! wmctrl -lx | grep -q "emacs.Emacs"; then
# emacsclient -c -a '' -n -e '(switch-to-buffer "*scratch*")'
# fi
# 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
# start Emacs on ftp-master
ssh ftp-master.debian.org pgrep -u spwhitton emacs \
|| ssh ftp-master.debian.org emacs --daemon &
# # open zenity dialog first; i3 will not float it
# zenity --question --no-wrap --no-markup \
# --title="ftp-master session cleanup" \
# --text="Kill tmux & Emacs sessions on ftp-master?" &
# zenity_pid=$!
# until wmctrl -l | grep -q "ftp-master session cleanup"; do
# sleep 0.3
# done
monitors="$(xrandr -q | grep ' connected' | wc -l)"
if ! wmctrl -l | grep -q "ftp-master dak command session"; then
first="$(i3-fresh-workspace)"
xfce4-terminal -x ssh-and-tmux \
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
xfce4-terminal -x ssh-and-tmux \
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 35 ppt, focus left
sleep 0.2
i3-msg resize set height 65 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
else
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
# ssh athena tmux send-keys -t irssi "\"/join -OFTC #debian-ftp-private\"" ENTER
# # ssh athena tmux send-keys -t irssi ! l o c k SPACE N E W
# # ssh athena tmux send-keys -t irssi LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT
# i3-msg '[class="^Xfce4-terminal$" title="^irssi$"]' scratchpad show
# # finally, get a little more space in the mc session
# ssh ftp-master.debian.org tmux set -t mc status off
# # clean everything up, per DMUP
# wait $zenity_pid
# zenity_exit=$?
# wmctrl -c "*NEW notes*" ||:
# if [ $zenity_exit = 0 ]; then
# ssh ftp-master.debian.org tmux kill-server
# ssh ftp-master.debian.org pkill -u spwhitton emacs
# sleep 10
# # --title needs to be different from the above so i3 floats the window
# ssh ftp-master.debian.org pgrep -u spwhitton emacs && zenity --error --no-wrap --title="Session cleanup error" --text="Processes still running on ftp-master!"
# fi
|