From d40d2cbaa1f6323ebfe6584f0acffc679912a8ac Mon Sep 17 00:00:00 2001 From: Penelope Gwen Date: Tue, 3 Mar 2026 08:30:02 -0800 Subject: [PATCH] New backup 2026-03-03 08:30:02 --- de/home/.config/sway/config.d/keys.d/launch | 2 +- de/home/.config/sway/scripts/wofi-calc.sh | 34 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 de/home/.config/sway/scripts/wofi-calc.sh diff --git a/de/home/.config/sway/config.d/keys.d/launch b/de/home/.config/sway/config.d/keys.d/launch index 8841fcb..4823dec 100644 --- a/de/home/.config/sway/config.d/keys.d/launch +++ b/de/home/.config/sway/config.d/keys.d/launch @@ -35,7 +35,7 @@ bindsym { #file browser $mod+shift+f exec 'sdu launch --program filemanager' #calculator - $mod+c exec wofi-calc + $mod+c exec "$HOME/.config/sway/scripts/wofi-calc.sh" #sticky notes $mod+shift+m exec stickynotes #gocryptfs diff --git a/de/home/.config/sway/scripts/wofi-calc.sh b/de/home/.config/sway/scripts/wofi-calc.sh new file mode 100755 index 0000000..72fea60 --- /dev/null +++ b/de/home/.config/sway/scripts/wofi-calc.sh @@ -0,0 +1,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