Update code for two status (third line in my dwm lost)

This commit is contained in:
BitHeaven 2024-05-31 20:34:28 +05:00
parent 27add6597a
commit 580a50f296
1 changed files with 27 additions and 12 deletions

39
dwmbar
View File

@ -21,11 +21,11 @@ def shutdown():
async def dwmbar(): async def dwmbar():
global bl, br global DD
await asyncio.sleep(1) await asyncio.sleep(1)
while True: while True:
bar = f"{status()}{DD}{bl}{DD}{br}" bar = f"{status()}{DD}{extrabar()}"
# print(bar) # print(bar)
run(["xprop", "-root", "-set", "WM_NAME", bar], check=True) run(["xprop", "-root", "-set", "WM_NAME", bar], check=True)
@ -54,8 +54,22 @@ def status():
return '' return ''
async def bl(): def extrabar():
global bl, COLOR global DELIM, currates, weather, COLOR
try:
bar = [
weather,
currates
]
return DELIM.join(bar)
except:
return ''
async def currates():
global DELIM, currates, COLOR
COLOR1='#AAAAAA' COLOR1='#AAAAAA'
COLOR2='#444444' COLOR2='#444444'
@ -71,13 +85,13 @@ async def bl():
else: else:
row = list(map(lambda x: f'[{x[0]} | {x[1]}]', curs)) row = list(map(lambda x: f'[{x[0]} | {x[1]}]', curs))
bl = DELIM.join(row) currates = DELIM.join(row)
await asyncio.sleep(60 * 10) await asyncio.sleep(60 * 10)
async def br(): async def weather():
global br, COLOR global weather, COLOR
COLOR1='#AAAAAA' COLOR1='#AAAAAA'
COLOR2='#444444' COLOR2='#444444'
@ -85,15 +99,16 @@ async def br():
CITY='Tyumen' CITY='Tyumen'
while True: 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') 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() 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() w = requests.get(f"https://wttr.in/{CITY}?format=j2").json()['current_condition'][0]['windspeedKmph'].strip()
if COLOR: 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: else:
br = f"[{w} km/h | {i} | {t}]" weather = f"[{w} km/h | {i} | {t}]"
print('w e')
await asyncio.sleep(60 * 30) await asyncio.sleep(60 * 30)
@ -303,8 +318,8 @@ async def main():
lang(), lang(),
dat(), dat(),
tim(), tim(),
bl(), currates(),
br() weather()
) )