d8e854b62d9780a852cc3b3c33ce714c125a999f
[tools.git] / edit
1 #!/bin/bash
2 # Edit files with emacsclient.
3 [ "$*" ] || { echo "$0: No files given" > /dev/stderr ; exit 1; }
4 if [ -n "$DISPLAY" ]
5 then
6 xdotool key super+1
7 found=""
8 while [ -z "$found" ]
9 do
10 swarp 100 100
11 xprop WM_CLASS >/tmp/wmclass &
12 xdotool click 1
13 grep emacs < /tmp/wmclass > /dev/null && found=1 || xdotool key super+k
14 done
15 pkill xprop
16 exec emacsclient --alternate-editor="" -c "$@"
17 else
18 exec emacsclient --alternate-editor="" -t -c "$@"
19 fi