From 071ea6e4ad2a383c87f3f9689fae6ae3a5007eb7 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Dec 2024 03:19:40 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20dwmbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dwmbar | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/dwmbar b/dwmbar index 71949c2..4ad8984 100755 --- a/dwmbar +++ b/dwmbar @@ -33,6 +33,7 @@ async def dwmbar(): await asyncio.sleep(0.1) +net = ram = cpu = gpu = wlan = disk = vol = lang = dat = tim = currates = weather = 0 def status(): global DELIM, net, ram, cpu, gpu, wlan, disk, vol, lang, dat, tim @@ -76,16 +77,19 @@ async def currates(): while True: curs = [] - curs.append(['', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=BTCUSDT').json()['lastPrice']):.2f}"]) - curs.append(['', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=LTCUSDT').json()['lastPrice']):.2f}"]) - curs.append(['Ð', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=DOGEUSDT').json()['lastPrice']):.2f}"]) + try: + curs.append(['', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=BTCUSDT').json()['lastPrice']):.2f}"]) +# curs.append(['', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=LTCUSDT').json()['lastPrice']):.2f}"]) +# curs.append(['Ð', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=DOGEUSDT').json()['lastPrice']):.2f}"]) - if COLOR: - row = list(map(lambda x: f'^b{COLOR1}^^c{COLOR2}^ {x[0]} ^c{COLOR1}^^b{COLOR2}^ {x[1]} ^d^', curs)) - else: - row = list(map(lambda x: f'[{x[0]} | {x[1]}]', curs)) + if COLOR: + row = list(map(lambda x: f'^b{COLOR1}^^c{COLOR2}^ {x[0]} ^c{COLOR1}^^b{COLOR2}^ {x[1]} ^d^', curs)) + else: + row = list(map(lambda x: f'[{x[0]} | {x[1]}]', curs)) - currates = DELIM.join(row) + currates = DELIM.join(row) + except: + pass await asyncio.sleep(60 * 10) @@ -99,14 +103,17 @@ async def weather(): CITY='Tyumen' while True: - i = requests.get(f"https://wttr.in/{CITY}?format=%c").text.strip() #.encode('utf-8')[0:3].decode('utf-8') - t = requests.get(f"https://wttr.in/{CITY}?format=%t").text.strip() - w = requests.get(f"https://wttr.in/{CITY}?format=j2").json()['current_condition'][0]['windspeedKmph'].strip() + try: + i = requests.get(f"https://wttr.in/{CITY}?format=%c").text.strip() #.encode('utf-8')[0:3].decode('utf-8') + t = requests.get(f"https://wttr.in/{CITY}?format=%t").text.strip() + w = requests.get(f"https://wttr.in/{CITY}?format=j2").json()['current_condition'][0]['windspeedKmph'].strip() - if COLOR: - weather = f"^b{COLOR2}^^c{COLOR1}^ {w} km/h ^b{COLOR1}^^c{COLOR2}^ {i} ^c{COLOR1}^^b{COLOR2}^ {t} ^d^" - else: - weather = f"[{w} km/h | {i} | {t}]" + if COLOR: + weather = f"^b{COLOR2}^^c{COLOR1}^ {w} km/h ^b{COLOR1}^^c{COLOR2}^ {i} ^c{COLOR1}^^b{COLOR2}^ {t} ^d^" + else: + weather = f"[{w} km/h | {i} | {t}]" + except: + pass await asyncio.sleep(60 * 30) @@ -333,4 +340,4 @@ if __name__ == '__main__': except KeyboardInterrupt: print("KeyboardInterrupt: Stopping the event loop...") finally: - loop.close() + loop.close() \ No newline at end of file