summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"