From 580a50f296c3ded27e2ef087c43c09b812755a76 Mon Sep 17 00:00:00 2001 From: BitHeaven Date: Fri, 31 May 2024 20:34:28 +0500 Subject: [PATCH] Update code for two status (third line in my dwm lost) --- dwmbar | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/dwmbar b/dwmbar index 99811f1..d4761cd 100755 --- a/dwmbar +++ b/dwmbar @@ -21,11 +21,11 @@ def shutdown(): async def dwmbar(): - global bl, br + global DD await asyncio.sleep(1) while True: - bar = f"{status()}{DD}{bl}{DD}{br}" + bar = f"{status()}{DD}{extrabar()}" # print(bar) run(["xprop", "-root", "-set", "WM_NAME", bar], check=True) @@ -54,8 +54,22 @@ def status(): return '' -async def bl(): - global bl, COLOR +def extrabar(): + global DELIM, currates, weather, COLOR + + try: + bar = [ + weather, + currates + ] + + return DELIM.join(bar) + except: + return '' + + +async def currates(): + global DELIM, currates, COLOR COLOR1='#AAAAAA' COLOR2='#444444' @@ -71,13 +85,13 @@ async def bl(): else: row = list(map(lambda x: f'[{x[0]} | {x[1]}]', curs)) - bl = DELIM.join(row) + currates = DELIM.join(row) await asyncio.sleep(60 * 10) -async def br(): - global br, COLOR +async def weather(): + global weather, COLOR COLOR1='#AAAAAA' COLOR2='#444444' @@ -85,15 +99,16 @@ async def br(): CITY='Tyumen' while True: + print('w s') 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: - br = f"^b{COLOR2}^^c{COLOR1}^ {w} km/h ^b{COLOR1}^^c{COLOR2}^ {i} ^c{COLOR1}^^b{COLOR2}^ {t} ^d^" + weather = f"^b{COLOR2}^^c{COLOR1}^ {w} km/h ^b{COLOR1}^^c{COLOR2}^ {i} ^c{COLOR1}^^b{COLOR2}^ {t} ^d^" else: - br = f"[{w} km/h | {i} | {t}]" - + weather = f"[{w} km/h | {i} | {t}]" + print('w e') await asyncio.sleep(60 * 30) @@ -303,8 +318,8 @@ async def main(): lang(), dat(), tim(), - bl(), - br() + currates(), + weather() )