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

0
13
déc.
2019

screenshot conky bitcoin

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 et curl (apt install tor curl).

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://linuxfr.org/wiki/debian-ubuntu-conky-afficher-prix-du-bitcoin-dash-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 commandes.

#!/bin/bash
# Gitlab : https://gitlab.com/voxdemonix/conky/blob/master/conky_bitcoin_rate/
btcAddr='YOUR_BiTCoin_ACCOUNT_HERE';

[ $(cat /tmp/${USER}_PRIVACON 2>&1 | grep -Eo "0|1") ] && exit # PRIVACON, stop if most alert (1) or Ghost mode (0)
PRIVACON=$(cat /tmp/${USER}_PRIVACON 2>&1 | grep -Eo "[0-9]");
[ -z "$PRIVACON" ] && PRIVACON=6 # set privacon to 6 if undectected

echo -n '${color yellow}Account BTC : '

if [ "$PRIVACON" -gt 3 ]; then
    raw=$(torsocks curl --max-time 10 "https://blockchain.info/q/addressbalance/$btcAddr");
    echo "$raw" | grep -Eo '^([0-9]{1,}([.]{1}[0-9]{1,}){0,1}){1}$' | sed \':a;N;$!ba;s/\n//g\' || account=$( echo "scale=8; $raw/100000000" | bc | sed 's/^\./0\./' ); echo -n "$account"
else
    echo -n "\${color red}\${font Symbola :size=9}⛔\${font}\${color}\${color yellow}"
    account=0
fi

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';

Envoyer un commentaire

Suivre le flux des commentaires

Note : les commentaires appartiennent à celles et ceux qui les ont postés. Nous n’en sommes pas responsables.