-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_qt.sh
59 lines (50 loc) · 850 Bytes
/
bash_qt.sh
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
#!/bin/echo To use bash-qt, put in your source file source
_qt_sig() {
read cmd <&4
if echo "$cmd" | egrep -q "^sig:"
then
eval "${cmd:4:${#cmd}-4}"
fi
}
qt_init() {
trap _qt_exit EXIT
QT_IN_PIPE="$(mktemp)"
QT_OUT_PIPE="$(mktemp)"
rm -f "$QT_IN_PIPE" "$QT_OUT_PIPE"
mknod --mode=600 "$QT_IN_PIPE" p
mknod --mode=600 "$QT_OUT_PIPE" p
./bash_qt_support.py $$ <"$QT_IN_PIPE" >"$QT_OUT_PIPE" &
_QT_SUPPORT_PID="$!"
exec 3>"$QT_IN_PIPE"
exec 4<"$QT_OUT_PIPE"
rm "$QT_IN_PIPE" "$QT_OUT_PIPE"
QT_APP="$(qt QtGui.QApplication [])"
}
_qt_exit() {
kill $_QT_SUPPORT_PID
}
qt() {
line=""
for arg in "$@"
do
line="$line\"$arg\" "
done
echo "$line" >&3
head -1 <&4
}
qts() {
qt "$@" >/dev/null
}
qt_signal() {
qts signal "$@"
}
qt_sig_end() {
qts sig_end
}
qt_exec() {
qts exec "$QT_APP"
while true
do
_qt_sig
done
}