blob: 72fea609acaf47d6b7f70c78214a659f785eb9ed (
plain)
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
|
#!/usr/bin/env bash
RESULT_FILE="$HOME/.config/qalculate/qalc.result.history"
if [ ! -f "$RESULT_FILE" ]; then
touch $RESULT_FILE
fi
LAST_WOFI=""
QALC_RET=""
while :
do
qalc_hist=`tac $RESULT_FILE | head -1000`
WOFI_RET=`wofi --sort-order=default --cache-file=/dev/null -d -p calc <<< "$qalc_hist"`
rtrn=$?
if test "$rtrn" = "0"; then
if [[ "$WOFI_RET" =~ .*=.* ]]; then
RESULT=`echo "$WOFI_RET" | awk {'print $NF'}`
wl-copy "$RESULT"
exit 0
else
QALC_RET=`qalc "$WOFI_RET"`
LAST_WOFI=$WOFI_RET
echo $QALC_RET >> $RESULT_FILE
fi
else
if [ ! -z "$LAST_WOFI" ]; then
RESULT=`qalc -t "$LAST_WOFI"`
wl-copy "$RESULT"
fi
exit 0
fi
done
|