aboutsummaryrefslogtreecommitdiffstats
path: root/.config/herbstluftwm/calc.sh
diff options
context:
space:
mode:
authorshmibs <shmibs@gmail.com>2014-05-22 11:32:52 -0700
committershmibs <shmibs@gmail.com>2014-05-22 11:32:52 -0700
commitddff9cf6eb63fea91ef0f157c78effd7a2351f24 (patch)
tree1c2db9d66a925a066c294ad7bd104b7c2c33ddcd /.config/herbstluftwm/calc.sh
parenta995874431c74929a8ac26ddaf96741429e6382d (diff)
downloaddotfiles-ddff9cf6eb63fea91ef0f157c78effd7a2351f24.tar.gz
added dmenu calculator
also added easy colour grabber
Diffstat (limited to '.config/herbstluftwm/calc.sh')
-rwxr-xr-x.config/herbstluftwm/calc.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/.config/herbstluftwm/calc.sh b/.config/herbstluftwm/calc.sh
new file mode 100755
index 0000000..aa041a6
--- /dev/null
+++ b/.config/herbstluftwm/calc.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+acc=0
+in="first"
+prompt="calc:"
+pi="3.1415926535897932384626433832795028841971694"
+e="2.7182818284590452353602874713526624977572471"
+while [ "$in" != "" ]; do
+ val=0
+
+ in=$(echo "" | dmenu -q -h 18 -nb $1 -nf $2 -sb $3 -sf $4 -p "$prompt")
+
+ out=$(echo "pi=$pi; e=$e; $acc $in" | calc -p 2>&1 | tr -d "\n")
+
+ if [ "$out" = "Missing operator" ]; then
+ out=$(echo "pi=$pi; e=$e; $in" | calc -p 2>&1)
+ fi
+
+ # check for error output
+ if [ "${?#0}" != "" ]; then
+ out=$(echo "$out" | tr -d "\n")
+ prompt="calc: ($acc) err: $out"
+ else
+ acc=$out
+ prompt="calc: ($acc)"
+ fi
+done
+