Added New Widgets

This commit is contained in:
tr1x_em committed 2025-08-03 22:03:55 +05:30
1 parent 9c5c17c097
commit 9484b8d773
2 files changed
+230 -20

No files matched your search

+43
View File
@@ -172,3 +172,46 @@ menu > menuitem:hover > label {
min-height: 170px;
border-radius: 16px;
}
#info-box-widget{
/* background-color: alpha(#232323, 1); */
background: linear-gradient(to bottom, #202020, #000000);
margin: 20px 10px 20px 10px;
min-width: 170px;
min-height: 170px;
border-radius: 16px;
}
#ram-progress{
font-family: "SF Pro Rounded";
margin-left: 12px;
color: var(--foreground);
/* background-color: alpha(#72BBCC, 0.9); */
}
#progress-label{
/* background-color: alpha(#FFF, 0.9); */
font-family: "SF Pro Rounded";
font-weight:600;
font-size: 13px;
}
#progress{
font-family: "SF Pro Rounded";
border: solid 8px #0984FF;
/* border-radius: 100px; */
color: alpha(#AAAAAA, 0.7);
}
#info {
font-family: "SF Pro Rounded";
margin-left: -8px;
margin-top: 5px;
font-size:14px;
font-weight:600;
/* margin-bottom:-10px; */
/* margin-top:-35px; */
}
#component-name{
font-size: 10px;
}
+187 -20
View File
@@ -449,13 +449,26 @@ class Date(Box):
self.add(self.datethree)
class raminfo(Box):
class DateContainer(Box):
def __init__(self, **kwargs):
super().__init__(
orientation="v",
name="box-widget",
v_expand=True,
v_align="center",
h_align="center",
children=[Date()],
**kwargs,
)
class RamInfo(Box):
@staticmethod
def bake_progress_bar(name: str = "progress-bar", size: int = 45, **kwargs):
def bake_progress_bar(name: str = "progress-bar", size: int = 80, **kwargs):
return CircularProgressBar(
name=name,
start_angle=180,
end_angle=540,
start_angle=270,
end_angle=630,
min_value=0,
max_value=100,
size=size,
@@ -463,19 +476,175 @@ class raminfo(Box):
)
@staticmethod
def bake_progress_icon(**kwargs):
return Label(**kwargs).build().add_style_class("progress-icon").unwrap()
def bake_progress_label(text, **kwargs):
return Label(label=text, **kwargs)
def __init__(self, **kwargs):
super().__init__(
layer="bottom",
title="sysinfo",
name="sysinfo",
visible=False,
all_visible=False,
name="info-box-widget",
visible=True,
h_expand=True,
v_expand=True,
all_visible=True,
**kwargs,
)
self.ram_progress = self.bake_progress_bar(name="progress")
self.ram_label = Label(
label="15%\nRam", justification="center", name="progress-label"
)
self.ram_info_label = Label(
label="ram info", name="info", justification="center", h_align="center"
)
self.progress_container = Box(
name="progress-bar-container",
h_expand=True,
v_expand=True,
orientation="v",
spacing=12,
h_align="center",
v_align="center",
children=[
Box(
children=[
Overlay(
child=self.ram_progress,
tooltip_text="",
overlays=self.ram_label,
),
],
),
Box(
h_align="center",
justification="centre",
orientation="v",
children=[
self.ram_info_label,
],
),
],
)
self.add(self.progress_container)
invoke_repeater(1000, self.update)
def update(self):
mem = psutil.virtual_memory()
self.ram_label.set_label(f" {round(mem.percent):<2} %\nRAM")
used_gb = mem.used / (1024**3)
free_gb = mem.available / (1024**3)
self.ram_info_label.set_label(
f"Used: {round( used_gb,1 ):>3}GB\nFree: {round( free_gb,1 ):>3}GB"
)
GLib.idle_add(self.ram_progress.set_value, mem.percent)
# executor.submit(update)
return True
class CpuInfo(Box):
@staticmethod
def bake_progress_bar(name: str = "progress-bar", size: int = 80, **kwargs):
return CircularProgressBar(
name=name,
start_angle=270,
end_angle=630,
min_value=0,
max_value=100,
size=size,
**kwargs,
)
@staticmethod
def bake_progress_label(text, **kwargs):
return Label(label=text, **kwargs)
def __init__(self, **kwargs):
super().__init__(
layer="bottom",
title="sysinfo",
name="info-box-widget",
visible=True,
h_expand=True,
v_expand=True,
all_visible=True,
**kwargs,
)
self.cpu_progress = self.bake_progress_bar(name="progress")
self.cpu_label = Label(
label="15%\nCPU", justification="center", name="progress-label"
)
self.cpu_info_label = Label(
label="CPU Info", name="info", justification="center", h_align="center"
)
self.progress_container = Box(
name="progress-bar-container",
h_expand=True,
v_expand=True,
orientation="v",
spacing=12,
h_align="center",
v_align="center",
children=[
Box(
children=[
Overlay(
child=self.cpu_progress,
tooltip_text="",
overlays=self.cpu_label,
),
],
),
Box(
h_align="center",
justification="centre",
orientation="v",
children=[
self.cpu_info_label,
],
),
],
)
self.add(self.progress_container)
invoke_repeater(1000, self.update)
def get_cpu_temp(self):
temps = psutil.sensors_temperatures()
if not temps:
return None
for name, entries in temps.items():
if (
"coretemp" in name.lower()
or "k10temp" in name.lower()
or "cpu" in name.lower()
):
for entry in entries:
# Match common CPU temp labels
if (
"package id 0" in (entry.label or "").lower()
or "core 0" in (entry.label or "").lower()
or (entry.label is None or entry.label.strip() == "")
):
return round(entry.current, 1)
return None
def update(self):
cpu = psutil.cpu_percent()
self.cpu_label.set_label(f" {round(cpu):<2} %\nCPU")
self.cpu_info_label.set_label(f"Temp: {self.get_cpu_temp()}°C")
GLib.idle_add(self.cpu_progress.set_value, cpu)
# executor.submit(update)
return True
# FIX: GTK ERRORS
@@ -491,25 +660,23 @@ class Deskwidgets(Window):
child=Box(
name="desktop-widgets-container",
children=[
Box(
orientation="v",
name="box-widget",
v_expand=True,
v_align="center",
h_align="center",
children=[Date()],
),
DateContainer(),
WeatherContainer(),
],
),
)
bottom_left = Window(
anchor="bottom left",
name="box-widget",
anchor="top right",
orientation="h",
layer="bottom",
child=raminfo(),
child=Box(
name="desktop-widgets-container",
children=[
CpuInfo(),
RamInfo(),
],
),
)
container = Box(