Skip to content

Instantly share code, notes, and snippets.

@veelenga
Last active July 5, 2016 09:45
Show Gist options
  • Save veelenga/8831d198b6fecdfc9476 to your computer and use it in GitHub Desktop.
Save veelenga/8831d198b6fecdfc9476 to your computer and use it in GitHub Desktop.
i3blocks script gist for displaying current currency ratio from Google's finance convertor
#!/bin/sh
# Copyright (C) 2014 Vitaliy Elengaupt <velenhaupt@gmail.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Usage:
# currency.sh EUR UAH
#
from=${1:-"USD"}
to=${2:-"UAH"}
# Uses Google's finance converter https://www.google.com/finance/converter
# Response example:
# <div id="currency_converter_result">1 USD = <span class="bld">21 UAH</span>
#
curl -s https://www.google.com/finance/converter\?a=1\&from=$from\&to=$to |
grep -a "currency_converter_result" |
ruby -e "r = ARGF.read.scan(/bld>(.*) $to</)[0]; r ? puts(r) : puts('N/A')"
[currency]
label=$
command=~/.i3/bin/currency.sh USD UAH
interval=once
color=#ffffff
Copy link

ghost commented Aug 19, 2015

Hey @veelenga,

In case you haven't heard, i3blocks is splitting into two repos! i3blocks will now go on to contain the core binary and a set of smallest usable blocklets to provide some beginner functionality. From i3blocks, i3blocks-contrib has now split off to gather the community contributed blocklets in a single repo to make perusing them easier and more convenient. We would be honoured if you would consider submitting your blocklet(s) to the contrib repo.

This change is the core change scheduled for the v1.5 release. Please note that as an artifact of this split, your entry for this blocklet in the core wiki has been removed as has everyone else's. If you would like to submit your blocklet, please review the contrib wiki to understand the workflow of i3blocks-contrib.

Please note that this change over is in its early stages, so the process for submission hasn't been completely nailed down. We're hard at work still compiling the two project wikis and documenting all changes and standards. It is very likely that things will still change and we value your input on how that change should occur.

Deepest regrads,

@Nycroth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment