Compare commits

..

No commits in common. "0d0d7d0e4af94fbc5197d7d7612109d519204cb1" and "a678a8955ec3996f0f56868f51253686bdc4cdea" have entirely different histories.

1 changed files with 28 additions and 72 deletions

100
dwmbar
View File

@ -6,13 +6,13 @@ import signal
import psutil
import alsaaudio
import requests
from subprocess import run
from subprocess import run, check_output
from Xlib import X, display, Xutil
from datetime import datetime
DD = ';'
DELIM = ' '
COLOR = False
def shutdown():
@ -28,7 +28,8 @@ async def dwmbar():
while True:
bar = f"{status()}{DD}{bl}{DD}{br}"
# print(bar)
# print(bar.encode('utf-8'))
# print(br)
run(["xprop", "-root", "-set", "WM_NAME", bar], check=True)
await asyncio.sleep(0.1)
@ -56,7 +57,7 @@ def status():
async def bl():
global bl, COLOR
global bl
COLOR1='#AAAAAA'
COLOR2='#444444'
@ -82,10 +83,7 @@ async def bl():
:.2f} RUB"""
])
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))
row = list(map(lambda x: f'^b{COLOR1}^^c{COLOR2}^ {x[0]} ^c{COLOR1}^^b{COLOR2}^ {x[1]} ^d^', curs))
bl = DELIM.join(row)
@ -93,7 +91,7 @@ async def bl():
async def br():
global br, COLOR
global br
COLOR1='#AAAAAA'
COLOR2='#444444'
@ -105,16 +103,13 @@ async def br():
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^"
else:
br = f"[{w} km/h | {i} | {t}]"
br = f"^b{COLOR2}^^c{COLOR1}^ {w} km/h ^b{COLOR1}^^c{COLOR2}^ {i} ^c{COLOR1}^^b{COLOR2}^ {t} ^d^"
await asyncio.sleep(60 * 30)
async def net():
global net, COLOR
global net
COLOR1='#FF9B00'
COLOR2='#A16200'
@ -132,16 +127,12 @@ async def net():
orecv = recv
osent = sent
if COLOR:
net = f'^c{COLOR1}^^b{COLOR2}^ {inb} ^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {outb} ^d^'
else:
net = f'[{inb} |  | {outb}]'
net = f'^c{COLOR1}^^b{COLOR2}^ {inb} ^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {outb} ^d^'
await asyncio.sleep(1)
async def ram():
global ram, COLOR
global ram
COLOR1='#C700FF'
COLOR2='#590073'
@ -150,16 +141,12 @@ async def ram():
ramt = psutil.virtual_memory().total / 1024 / 1024 / 1024
ramu = psutil.virtual_memory().used / 1024 / 1024 / 1024
if COLOR:
ram = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {ramu:0.1f}/{ramt:0.1f}G ^d^'
else:
ram = f'[ | {ramu:0.1f}/{ramt:0.1f}G]'
ram = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {ramu:0.1f}/{ramt:0.1f}G ^d^'
await asyncio.sleep(1)
async def cpu():
global cpu, COLOR
global cpu
COLOR1='#990057'
COLOR2='#FF00B2'
@ -167,16 +154,12 @@ async def cpu():
while True:
load = psutil.cpu_percent()
if COLOR:
cpu = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {load:0.0f}% ^d^'
else:
cpu = f'[ | {load:0.0f}%]'
cpu = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {load:0.0f}% ^d^'
await asyncio.sleep(1)
async def gpu():
global gpu, COLOR
global gpu
COLOR1='#990057'
COLOR2='#FF00B2'
@ -184,16 +167,12 @@ async def gpu():
while True:
load = open('/sys/class/drm/card0/device/gpu_busy_percent').read().strip()
if COLOR:
gpu = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {load}% ^d^'
else:
gpu = f'[ | {load}%]'
gpu = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {load}% ^d^'
await asyncio.sleep(1)
async def wlan():
global cpu, COLOR
global cpu
COLOR1='#009CFF'
COLOR2='#005083'
@ -202,16 +181,12 @@ async def wlan():
c = psutil.cpu_percent()
i = ''
if COLOR:
cpu = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {c:0.0f}% ^d^'
else:
cpu = f'[ | {c:0.0f}%]'
cpu = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {c:0.0f}% ^d^'
await asyncio.sleep(1)
async def disk():
global disk, COLOR
global disk
COLOR1='#00FF90'
COLOR2='#00A45D'
@ -220,16 +195,12 @@ async def disk():
f = psutil.disk_usage('/').free / 1024 / 1024 / 1024
t = psutil.disk_usage('/').total / 1024 / 1024 / 1024
if COLOR:
disk = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {f:0.0f}/{t:0.0f}G ^d^'
else:
disk = f'[ | {f:0.0f}/{t:0.0f}G]'
disk = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {f:0.0f}/{t:0.0f}G ^d^'
await asyncio.sleep(3)
async def vol():
global vol, COLOR
global vol
COLOR1='#FF0000'
COLOR2='#700000'
@ -249,16 +220,12 @@ async def vol():
if alsaaudio.Mixer().getmute()[0]:
i = ''
if COLOR:
vol = f'^b{COLOR1}^^c{COLOR2}^ {i} ^c{COLOR1}^^b{COLOR2}^ {v}% ^d^'
else:
vol = f'[{i} | {v}%]'
vol = f'^b{COLOR1}^^c{COLOR2}^ {i} ^c{COLOR1}^^b{COLOR2}^ {v}% ^d^'
await asyncio.sleep(1)
async def lang():
global lang, COLOR
global lang
COLOR1='#FF5800'
COLOR2='#973400'
@ -266,16 +233,12 @@ async def lang():
while True:
l = run(["xkblayout-state", "print", "%s"], check=True, capture_output=True, text=True).stdout
if COLOR:
lang = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {l} ^d^'
else:
lang = f'[ | {l}]'
lang = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {l} ^d^'
await asyncio.sleep(0.1)
async def tim():
global tim, COLOR
global tim
COLOR1='#00E9FF'
COLOR2='#008592'
@ -283,16 +246,12 @@ async def tim():
while True:
t = datetime.now().strftime("%H:%M:%S")
if COLOR:
tim = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {t} ^d^'
else:
tim = f'[ | {t}]'
tim = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {t} ^d^'
await asyncio.sleep(1)
async def dat():
global dat, COLOR
global dat
COLOR1='#17FF00'
COLOR2='#0EA100'
@ -300,10 +259,7 @@ async def dat():
while True:
d = datetime.now().strftime("%d.%m.%y")
if COLOR:
dat = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {d} ^d^'
else:
dat = f'[ | {d}]'
dat = f'^b{COLOR1}^^c{COLOR2}^  ^c{COLOR1}^^b{COLOR2}^ {d} ^d^'
await asyncio.sleep(1)