summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2017-10-21 10:39:34 +0200
committerAnton Bobov <abobov@gmail.com>2017-10-21 10:39:34 +0200
commit1f44d74c080c168ccdb315f18a99f270f09c548d (patch)
tree94be07cc74b594b315fa8cb064a3f9f667070c16
parent95e920f6fe2de0b26cd8af072b29438c9a8e83cc (diff)
Update bin.
+ clipboard-stream: prints clipboard changes to stdout * ledger price db refactoring, added new xe
-rwxr-xr-xclipboard-stream13
-rwxr-xr-xledger-price-db-update.sh18
2 files changed, 27 insertions, 4 deletions
diff --git a/clipboard-stream b/clipboard-stream
new file mode 100755
index 0000000..b4c1120
--- /dev/null
+++ b/clipboard-stream
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+set -e
+
+recent_value=$(xclip -o -selection clipboard)
+while true ; do
+ value=$(xclip -o -selection clipboard)
+ if [ "$recent_value" != "$value" ] ; then
+ recent_value=$value
+ echo $recent_value
+ fi
+ sleep 0.1
+done
diff --git a/ledger-price-db-update.sh b/ledger-price-db-update.sh
index 084b27c..478efb9 100755
--- a/ledger-price-db-update.sh
+++ b/ledger-price-db-update.sh
@@ -17,8 +17,18 @@ xe() {
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s=$1&f=p"
}
-usd=$(xe "USDRUB=X")
-eur=$(xe "EURRUB=X")
+print_rate() {
+ currency="$1"
+ symbol="$2"
+
+ val=$(xe "$currency=X")
+
+ test -n "$val" && echo P $(date +"%Y/%m/%d %H:%M:%S") $symbol $val R
+}
+
+{
+ print_rate "USDRUB" "\$"
+ print_rate "EURRUB" "€"
+ print_rate "PLNRUB" "P"
+} >> "$PRICE_DB_FILE"
-test -n "$usd" && echo P $(date +"%Y/%m/%d %H:%M:%S") \$ $usd R >> "$PRICE_DB_FILE"
-test -n "$eur" && echo P $(date +"%Y/%m/%d %H:%M:%S") € $eur R >> "$PRICE_DB_FILE"