Visualiser une révision

[Debian/Ubuntu] Conky : Afficher prix du Bitcoin/Dash et la quantité sur le compte

voxdemonix : révision n°2 (13 décembre 2019 16:28:46)

![screenshot conky bitcoin](https://gitlab.com/voxdemonix/conky/raw/master/conky_bitcoin_rate/screenshot-2019_11_29-conky_bitcoin_rate1.jpg)

Si vous ne souhaitez pas éditer le code, alors créez le dossier _/home/your_username/.conky/conky-perso/conky_bitcoin_rate_ et ajoutez les codes source suivants dedans. Installez aussi tor (_apt install tor_).

Gitlab : https://gitlab.com/voxdemonix/conky/tree/master/conky_bitcoin_rate

**Code source du fichier conkyrc (ajoutez le code dans _~/.conky/conky-perso/conky_bitcoin_rate/conkyrc_)**

```
# INFOS : https://wiki.0rion.netlib.re/doku.php?id=documentation_en:conky_display_linuxfr.org/wiki/debian-ubuntu-conky-afficher-prix-du-bitcoin_-dash_current_pric-et-la-quantite-sur-le-compte
# http://conky.sourceforge.net/config_settings.html
# Use Xft?
use_xft yes
xftfont Ubuntu Beta:size=8
xftalpha 0.8
text_buffer_size 2048

# Update interval in seconds
update_interval 300

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_transparent no
own_window_argb_visual yes
own_window_argb_value 210  # semi-transparent
own_window_type normal
own_window_class conky
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
background no

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 200 20
maximum_width 500
maximum_height 100

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Stippled borders?
stippled_borders 0

# border margins
border_inner_margin 2

# border width
border_width 1

# Default colors and also border colors
default_color 00c4e7
default_shade_color black
default_outline_color white
own_window_colour black

# Text alignment, other possible values are commented
#alignment top_left
alignment tl
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 300
gap_y 300

# Subtract file system buffers from usedmemory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about?  This only affects certain objects.
use_spacer none


TEXT
${execp ~/.conky/conky-perso/conky_bitcoin_rate/bitcoin_rate.bash }
```


Le code source du fichier _bitcoin_rate.bash_ (ajoutez le dans _~/.conky/conky-perso/conky_bitcoin_rate/bitcoin_rate.bash_). Si vous n'utilisez pas Tor, supprimez “_torsocks_” dans les commande.

```bash
#!/bin/bash
echo -n '${color yellow}Account BTC : '
btcAddr='your_account_here'; raw=$(torsocks curl --max-time 10 "https://blockchain.info/q/addressbalance/$btcAddr");  echo "$raw" | grep 'html' || account=$( echo "scale=8; $raw/100000000" | bc | sed 's/^\./0\./' ); echo -n "$account"
echo -n ' ${font Symbola:size=10}₿${font}${color}'
raw=$(torsocks curl --max-time 10 'https://api.coindesk.com/v1/bpi/currentprice/EUR.json'); euro=$(echo "$raw"  | grep -oP '(?<="Euro","rate_float":).*?(?=\})'); dollars=$(echo "$raw" | grep -oP '(?<="United States Dollar","rate_float":).*?(?=\})' | sed 's/\./,/');
balance=$(bc<<<$account*$euro)
balance=${balance%.*}
echo " (\${color orange}$balance€\${color})"
euro=$(echo -n "$euro" | sed 's/\./,/')
echo -n '${alignc}'; printf %.2f $dollars; echo -n ' USD <~~ BITCOIN ~~> ';  printf %.2f $euro; echo -n ' EURO';
echo
raw=$(torsocks curl --max-time 10 'https://min-api.cryptocompare.com/data/price?fsym=DASH&tsyms=USD,EUR'); euro=$(echo "$raw"  | grep -oP '(?<="EUR":).*?(?=})' | sed 's/\./,/'); dollars=$(echo "$raw" | grep -oP '(?<="USD":).*?(?=,)' | sed 's/\./,/'); echo -n '${alignc}'; printf %.2f $dollars; echo -n ' USD <~~ DASH ~~> ';  printf %.2f $euro; echo -n ' EURO';
```