Compare commits
No commits in common. "0d0d7d0e4af94fbc5197d7d7612109d519204cb1" and "a678a8955ec3996f0f56868f51253686bdc4cdea" have entirely different histories.
0d0d7d0e4a
...
a678a8955e
100
dwmbar
100
dwmbar
|
@ -6,13 +6,13 @@ import signal
|
||||||
import psutil
|
import psutil
|
||||||
import alsaaudio
|
import alsaaudio
|
||||||
import requests
|
import requests
|
||||||
from subprocess import run
|
from subprocess import run, check_output
|
||||||
|
from Xlib import X, display, Xutil
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
DD = ';'
|
DD = ';'
|
||||||
DELIM = ' '
|
DELIM = ' '
|
||||||
COLOR = False
|
|
||||||
|
|
||||||
|
|
||||||
def shutdown():
|
def shutdown():
|
||||||
|
@ -28,7 +28,8 @@ async def dwmbar():
|
||||||
while True:
|
while True:
|
||||||
bar = f"{status()}{DD}{bl}{DD}{br}"
|
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)
|
run(["xprop", "-root", "-set", "WM_NAME", bar], check=True)
|
||||||
|
|
||||||
await asyncio.sleep(0.1)
|
await asyncio.sleep(0.1)
|
||||||
|
@ -56,7 +57,7 @@ def status():
|
||||||
|
|
||||||
|
|
||||||
async def bl():
|
async def bl():
|
||||||
global bl, COLOR
|
global bl
|
||||||
|
|
||||||
COLOR1='#AAAAAA'
|
COLOR1='#AAAAAA'
|
||||||
COLOR2='#444444'
|
COLOR2='#444444'
|
||||||
|
@ -82,10 +83,7 @@ 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)
|
||||||
|
|
||||||
|
@ -93,7 +91,7 @@ async def bl():
|
||||||
|
|
||||||
|
|
||||||
async def br():
|
async def br():
|
||||||
global br, COLOR
|
global br
|
||||||
|
|
||||||
COLOR1='#AAAAAA'
|
COLOR1='#AAAAAA'
|
||||||
COLOR2='#444444'
|
COLOR2='#444444'
|
||||||
|
@ -105,16 +103,13 @@ 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, COLOR
|
global net
|
||||||
|
|
||||||
COLOR1='#FF9B00'
|
COLOR1='#FF9B00'
|
||||||
COLOR2='#A16200'
|
COLOR2='#A16200'
|
||||||
|
@ -132,16 +127,12 @@ 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, COLOR
|
global ram
|
||||||
|
|
||||||
COLOR1='#C700FF'
|
COLOR1='#C700FF'
|
||||||
COLOR2='#590073'
|
COLOR2='#590073'
|
||||||
|
@ -150,16 +141,12 @@ 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, COLOR
|
global cpu
|
||||||
|
|
||||||
COLOR1='#990057'
|
COLOR1='#990057'
|
||||||
COLOR2='#FF00B2'
|
COLOR2='#FF00B2'
|
||||||
|
@ -167,16 +154,12 @@ 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, COLOR
|
global gpu
|
||||||
|
|
||||||
COLOR1='#990057'
|
COLOR1='#990057'
|
||||||
COLOR2='#FF00B2'
|
COLOR2='#FF00B2'
|
||||||
|
@ -184,16 +167,12 @@ 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, COLOR
|
global cpu
|
||||||
|
|
||||||
COLOR1='#009CFF'
|
COLOR1='#009CFF'
|
||||||
COLOR2='#005083'
|
COLOR2='#005083'
|
||||||
|
@ -202,16 +181,12 @@ 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, COLOR
|
global disk
|
||||||
|
|
||||||
COLOR1='#00FF90'
|
COLOR1='#00FF90'
|
||||||
COLOR2='#00A45D'
|
COLOR2='#00A45D'
|
||||||
|
@ -220,16 +195,12 @@ 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, COLOR
|
global vol
|
||||||
|
|
||||||
COLOR1='#FF0000'
|
COLOR1='#FF0000'
|
||||||
COLOR2='#700000'
|
COLOR2='#700000'
|
||||||
|
@ -249,16 +220,12 @@ 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, COLOR
|
global lang
|
||||||
|
|
||||||
COLOR1='#FF5800'
|
COLOR1='#FF5800'
|
||||||
COLOR2='#973400'
|
COLOR2='#973400'
|
||||||
|
@ -266,16 +233,12 @@ 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, COLOR
|
global tim
|
||||||
|
|
||||||
COLOR1='#00E9FF'
|
COLOR1='#00E9FF'
|
||||||
COLOR2='#008592'
|
COLOR2='#008592'
|
||||||
|
@ -283,16 +246,12 @@ 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, COLOR
|
global dat
|
||||||
|
|
||||||
COLOR1='#17FF00'
|
COLOR1='#17FF00'
|
||||||
COLOR2='#0EA100'
|
COLOR2='#0EA100'
|
||||||
|
@ -300,10 +259,7 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue