Compare commits
5 Commits
0d0d7d0e4a
...
main
Author | SHA1 | Date | |
---|---|---|---|
071ea6e4ad | |||
0e99ff770b | |||
b893d85525 | |||
580a50f296 | |||
27add6597a |
100
dwmbar
100
dwmbar
@ -12,21 +12,20 @@ from datetime import datetime
|
|||||||
|
|
||||||
DD = ';'
|
DD = ';'
|
||||||
DELIM = ' '
|
DELIM = ' '
|
||||||
COLOR = False
|
COLOR = True
|
||||||
|
|
||||||
|
|
||||||
def shutdown():
|
def shutdown():
|
||||||
for task in asyncio.Task.all_tasks():
|
print("Shutting down...")
|
||||||
if task is not asyncio.tasks.Task.current_task():
|
loop.stop()
|
||||||
task.cancel()
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
@ -34,6 +33,7 @@ async def dwmbar():
|
|||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
|
net = ram = cpu = gpu = wlan = disk = vol = lang = dat = tim = currates = weather = 0
|
||||||
def status():
|
def status():
|
||||||
global DELIM, net, ram, cpu, gpu, wlan, disk, vol, lang, dat, tim
|
global DELIM, net, ram, cpu, gpu, wlan, disk, vol, lang, dat, tim
|
||||||
|
|
||||||
@ -55,45 +55,47 @@ 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'
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
curs = []
|
curs = []
|
||||||
curs.append(['', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=XMRUSDT').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=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=LTCUSDT').json()['lastPrice']):.2f}"])
|
||||||
curs.append(['Ð', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=DOGEUSDT').json()['lastPrice']):.2f}"])
|
# curs.append(['Ð', f"${float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=DOGEUSDT').json()['lastPrice']):.2f}"])
|
||||||
curs.append(['$', f"{float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=USDTRUB').json()['lastPrice']):.2f} RUB"])
|
|
||||||
|
|
||||||
curs.append(['',
|
|
||||||
f"""{
|
|
||||||
float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=USDTRUB').json()['lastPrice']) /
|
|
||||||
float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=USDTTRY').json()['lastPrice'])
|
|
||||||
:.2f} RUB"""
|
|
||||||
])
|
|
||||||
curs.append(['₴',
|
|
||||||
f"""{
|
|
||||||
float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=USDTRUB').json()['lastPrice']) /
|
|
||||||
float(requests.get('https://api.binance.com/api/v3/ticker/24hr?symbol=USDTUAH').json()['lastPrice'])
|
|
||||||
:.2f} RUB"""
|
|
||||||
])
|
|
||||||
|
|
||||||
if COLOR:
|
if COLOR:
|
||||||
row = list(map(lambda x: f'^b{COLOR1}^^c{COLOR2}^ {x[0]} ^c{COLOR1}^^b{COLOR2}^ {x[1]} ^d^', curs))
|
row = list(map(lambda x: f'^b{COLOR1}^^c{COLOR2}^ {x[0]} ^c{COLOR1}^^b{COLOR2}^ {x[1]} ^d^', curs))
|
||||||
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)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
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'
|
||||||
@ -101,14 +103,17 @@ async def br():
|
|||||||
CITY='Tyumen'
|
CITY='Tyumen'
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
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}]"
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
await asyncio.sleep(60 * 30)
|
await asyncio.sleep(60 * 30)
|
||||||
|
|
||||||
@ -161,8 +166,8 @@ async def ram():
|
|||||||
async def cpu():
|
async def cpu():
|
||||||
global cpu, COLOR
|
global cpu, COLOR
|
||||||
|
|
||||||
COLOR1='#990057'
|
COLOR1='#FF00B2'
|
||||||
COLOR2='#FF00B2'
|
COLOR2='#990057'
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
load = psutil.cpu_percent()
|
load = psutil.cpu_percent()
|
||||||
@ -178,11 +183,11 @@ async def cpu():
|
|||||||
async def gpu():
|
async def gpu():
|
||||||
global gpu, COLOR
|
global gpu, COLOR
|
||||||
|
|
||||||
COLOR1='#990057'
|
COLOR1='#FF00B2'
|
||||||
COLOR2='#FF00B2'
|
COLOR2='#990057'
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
load = open('/sys/class/drm/card0/device/gpu_busy_percent').read().strip()
|
load = open('/sys/class/drm/card1/device/gpu_busy_percent').read().strip()
|
||||||
|
|
||||||
if COLOR:
|
if COLOR:
|
||||||
gpu = f'^b{COLOR1}^^c{COLOR2}^ ^c{COLOR1}^^b{COLOR2}^ {load}% ^d^'
|
gpu = f'^b{COLOR1}^^c{COLOR2}^ ^c{COLOR1}^^b{COLOR2}^ {load}% ^d^'
|
||||||
@ -307,11 +312,8 @@ async def dat():
|
|||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
async def main():
|
||||||
signal.signal(signal.SIGINT, lambda n, f: shutdown())
|
await asyncio.gather(
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
main_task = asyncio.wait([
|
|
||||||
dwmbar(),
|
dwmbar(),
|
||||||
net(),
|
net(),
|
||||||
ram(),
|
ram(),
|
||||||
@ -322,12 +324,20 @@ if __name__ == '__main__':
|
|||||||
lang(),
|
lang(),
|
||||||
dat(),
|
dat(),
|
||||||
tim(),
|
tim(),
|
||||||
bl(),
|
# currates(),
|
||||||
br()
|
weather()
|
||||||
])
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
signal.signal(signal.SIGINT, lambda n, f: shutdown())
|
||||||
|
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
main_task = asyncio.ensure_future(main())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
loop.run_until_complete(main_task)
|
loop.run_until_complete(main_task)
|
||||||
except asyncio.CancelledError:
|
except KeyboardInterrupt:
|
||||||
loop.run_until_complete(main_task)
|
print("KeyboardInterrupt: Stopping the event loop...")
|
||||||
|
finally:
|
||||||
loop.close()
|
loop.close()
|
Reference in New Issue
Block a user