First commit.

This commit is contained in:
Adrian Lopez 2021-09-24 23:45:04 +02:00
parent 28f215a79d
commit 47e0bf6d0f
4 changed files with 108 additions and 1 deletions

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Alexander Adrian Lopez
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40
PKGBUILD Normal file
View file

@ -0,0 +1,40 @@
# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.
# Maintainer: Adrian Lopez <zeioth@hotmail.com>
pkgname=wofi-calc
pkgver=1.0
pkgrel=1
epoch=
pkgdesc="Search code documentation from rofi"
arch=(x86_64 i686)
url="https://github.com/Zeioth/wofi-calc.git"
license=('MIT')
groups=()
depends=()
makedepends=(wofi)
checkdepends=()
optdepends=()
provides=(wofi-calc)
conflicts=(wofi-calc)
replaces=()
backup=()
options=()
install=
changelog=
source=("git+$url")
noextract=()
md5sums=('SKIP')
validpgpkeys=()
pkgver() {
cd "${_pkgname}"
printf "1.0.r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
package() {
cp "${srcdir}"/wofi-calc/wofi-calc ~/.local/bin/rofi-calc
chmod u+x ~/.local/bin/wofi-calc
}

View file

@ -1,2 +1,14 @@
# wofi-calc # wofi-calc
A simple calculator for wofi, inspired in rofi-calc A simple calculator for wofi, inspired in rofi-calc.
## Install from AUR
yay -S wofi-calc
## Install from github
makepkg -sri
## To use it run
wofi-calc

34
wofi-calc Executable file
View file

@ -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