├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── PKGBUILD ├── README.md └── wofi-calc.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: Zeioth 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tags 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 4 | 5 | Original packager: 6 | - Adrian Lopez 7 | 8 | Original authors: 9 | - stvsu 10 | - pierenn 11 | 12 | Historical Source: https://todo.sr.ht/~scoopta/wofi/49 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in all 22 | copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 | SOFTWARE. 31 | -------------------------------------------------------------------------------- /PKGBUILD: -------------------------------------------------------------------------------- 1 | pkgname=wofi-calc-git 2 | pkgver=1.0.r26.e2113b4 3 | pkgrel=1 4 | epoch= 5 | pkgdesc="A simple calculator for wofi, inspired in rofi-calc." 6 | arch=(any) 7 | url="https://github.com/Zeioth/wofi-calc.git" 8 | license=('MIT') 9 | groups=() 10 | depends=(wofi libqalculate) 11 | makedepends=(wofi libqalculate) 12 | checkdepends=() 13 | optdepends=() 14 | provides=(wofi-calc-git) 15 | conflicts=(wofi-calc) 16 | replaces=() 17 | backup=() 18 | options=() 19 | install= 20 | changelog= 21 | source=("git+$url") 22 | noextract=() 23 | sha256sums=('SKIP') 24 | validpgpkeys=() 25 | 26 | pkgver() { 27 | cd "${_pkgname}" 28 | printf "1.0.r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" 29 | } 30 | 31 | package() { 32 | # Note: 'install' is a chmod+cp one-liner command by GNU 33 | mkdir -p "$pkgdir"/usr/bin 34 | install -m 555 "${srcdir}"/wofi-calc/wofi-calc.sh "$pkgdir"/usr/bin/wofi-calc 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wofi-calc 2 | A simple calculator for wofi, inspired in rofi-calc. 3 | 4 | ## Install from AUR 5 | 6 | yay -S wofi-calc 7 | 8 | ## Install from github 9 | 10 | makepkg -sri 11 | 12 | ## To use it run 13 | 14 | wofi-calc 15 | 16 | ## 🌟 Support the project 17 | Please star this repository to increase the visibility of the project. 18 | -------------------------------------------------------------------------------- /wofi-calc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | RESULT_FILE="$HOME/.config/qalculate/qalc.result.history" 4 | if [ ! -f "$RESULT_FILE" ]; then 5 | touch $RESULT_FILE 6 | fi 7 | 8 | LAST_WOFI="" 9 | QALC_RET="" 10 | while : 11 | do 12 | qalc_hist=`tac $RESULT_FILE | head -1000` 13 | WOFI_RET=`wofi --sort-order=default --cache-file=/dev/null -d -p calc <<< "$qalc_hist"` 14 | 15 | rtrn=$? 16 | 17 | if test "$rtrn" = "0"; then 18 | if [[ "$WOFI_RET" =~ .*=.* ]]; then 19 | RESULT=`echo "$WOFI_RET" | awk {'print $NF'}` 20 | wl-copy "$RESULT" 21 | exit 0 22 | else 23 | QALC_RET=`qalc "$WOFI_RET"` 24 | LAST_WOFI=$WOFI_RET 25 | echo $QALC_RET >> $RESULT_FILE 26 | fi 27 | else 28 | if [ ! -z "$LAST_WOFI" ]; then 29 | RESULT=`qalc -t "$LAST_WOFI"` 30 | wl-copy "$RESULT" 31 | fi 32 | exit 0 33 | fi 34 | done 35 | --------------------------------------------------------------------------------