Add defolt layout (no color)

This commit is contained in:
bitheaven 2024-02-24 13:39:41 +05:00
parent b9ba514154
commit 0d0d7d0e4a
1 changed files with 71 additions and 26 deletions

73
dwmbar
View File

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