gnome applet to track crypto prices
Published01/01/2022
Stats1 min read ·
codecrypto
← Back to blog
Discussion
Add your thoughts
gnome applet to track crypto prices
13 June 2021
add more FOMO to your life by constantly showing crypto prices as an applet. Wrote a small gnome applet to keep track of prices :)
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
import signal
from threading import Thread
APPINDICATOR_ID = "my-crypto-tracker"
def main():
indicator = appindicator.Indicator.new(
APPINDICATOR_ID,
os.path.abspath("crypto.svg"),
appindicator.IndicatorCategory.SYSTEM_SERVICES,
)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(build_menu())
gtk.main()
def build_menu():
menu = gtk.Menu()
item_quit = gtk.MenuItem("Quit")
menu.append(item_quit)
menu.show_all()
return menu
def quit(source):
notify.uninit()
gtk.main_quit()
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL)
I usually use bitbns as the source
CRYPTO_PRICE_ENDPOINT = "https://bitbns.com/order/getTickerWithVolume/"
def fetch_prices(coin_symbol):
response = requests.get(CRYPTO_PRICE_ENDPOINT)
response_to_json = response.json()
coin_price = response_to_json[coin_symbol]["last_traded_price"]
return coin_price
use indicator.set_label(your_thread) to keep updating the ticker
Lock Thread
1,149 views
No comments yet. Be the first to share your thoughts.