Skip to content

Commit 4b39fb5

Browse files
committed
Enhance notification display and styling
1 parent 6e45268 commit 4b39fb5

File tree

6 files changed

+87
-34
lines changed

6 files changed

+87
-34
lines changed

modules/controls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ def on_speaker_changed(self, *_):
205205
self.progress_bar.remove_style_class("muted")
206206
self.vol_label.remove_style_class("muted")
207207
self.progress_bar.value = self.audio.speaker.volume / 100
208-
if self.audio.speaker.volume >= 75:
208+
if self.audio.speaker.volume > 74:
209209
self.vol_button.get_child().set_markup(icons.vol_high)
210-
elif self.audio.speaker.volume >= 1:
210+
elif self.audio.speaker.volume > 0:
211211
self.vol_button.get_child().set_markup(icons.vol_medium)
212212
else:
213213
self.vol_button.get_child().set_markup(icons.vol_mute)
@@ -325,9 +325,9 @@ def on_brightness_changed(self, *_):
325325
return
326326
self.progress_bar.value = self.brightness.screen_brightness / self.brightness.max_screen
327327
brightness_percentage = (self.brightness.screen_brightness / self.brightness.max_screen) * 100
328-
if brightness_percentage >= 75:
328+
if brightness_percentage > 74:
329329
self.brightness_label.set_markup(icons.brightness_high)
330-
elif brightness_percentage >= 25:
330+
elif brightness_percentage > 24:
331331
self.brightness_label.set_markup(icons.brightness_medium)
332332
else:
333333
self.brightness_label.set_markup(icons.brightness_low)

modules/notch.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from fabric.widgets.centerbox import CenterBox
55
from fabric.widgets.button import Button
66
from fabric.widgets.stack import Stack
7+
from fabric.widgets.revealer import Revealer
78
from fabric.widgets.wayland import WaylandWindow as Window
89
from fabric.hyprland.widgets import ActiveWindow
910
from fabric.utils.helpers import FormattedString, truncate
@@ -25,7 +26,7 @@ def __init__(self, **kwargs):
2526
name="notch",
2627
layer="top",
2728
anchor="top",
28-
margin="-40px 10px 10px 10px",
29+
margin="-40px 40px 10px 10px",
2930
keyboard_mode="none",
3031
exclusivity="normal",
3132
visible=True,
@@ -136,9 +137,33 @@ def __init__(self, **kwargs):
136137
)
137138
)
138139

140+
self.notification_revealer = Revealer(
141+
name="notification-revealer",
142+
transition_type="slide-down",
143+
transition_duration=250,
144+
child_revealed=False,
145+
)
146+
147+
self.boxed_notification_revealer = Box(
148+
name="boxed-notification-revealer",
149+
orientation="v",
150+
children=[
151+
self.notification_revealer,
152+
]
153+
)
154+
155+
self.notch_complete = Box(
156+
name="notch-complete",
157+
orientation="v",
158+
children=[
159+
self.notch_box,
160+
self.boxed_notification_revealer,
161+
]
162+
)
163+
139164
self.hidden = False
140165

141-
self.add(self.notch_box)
166+
self.add(self.notch_complete)
142167
self.show_all()
143168

144169
self.add_keybinding("Escape", lambda *_: self.close_notch())
@@ -180,7 +205,6 @@ def open_notch(self, widget):
180205
widgets = {
181206
"launcher": self.launcher,
182207
"dashboard": self.dashboard,
183-
"notification": self.notification,
184208
"overview": self.overview,
185209
"power": self.power,
186210
"bluetooth": self.bluetooth
@@ -213,7 +237,7 @@ def open_notch(self, widget):
213237
else:
214238
self.stack.set_visible_child(self.dashboard)
215239

216-
if widget == "dashboard":
240+
if widget == "dashboard" or widget == "overview":
217241
self.bar.revealer.set_reveal_child(False)
218242
else:
219243
self.bar.revealer.set_reveal_child(True)

modules/notifications.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(self, notification: Notification, timeout_ms=5000, **kwargs):
4545
name="notification-box",
4646
# spacing=8,
4747
orientation="v",
48+
h_align="center",
4849
children=[
4950
# self.create_header(notification),
5051
self.create_content(notification),
@@ -223,10 +224,11 @@ def unhover_button(self, button):
223224

224225
class NotificationContainer(Box):
225226
def __init__(self, **kwargs):
226-
super().__init__(name="notification", orientation="v", spacing=4, v_expand=True, h_expand=True)
227+
super().__init__(name="notification", orientation="v", spacing=4)
227228
self.notch = kwargs["notch"]
228229
self._server = Notifications()
229230
self._server.connect("notification-added", self.on_new_notification)
231+
self._pending_removal = False
230232

231233
def set_pointer_cursor(self, widget, cursor_name):
232234
"""Cambia el cursor sobre un widget."""
@@ -236,18 +238,34 @@ def set_pointer_cursor(self, widget, cursor_name):
236238
window.set_cursor(cursor)
237239

238240
def on_new_notification(self, fabric_notif, id):
239-
for child in self.get_children():
240-
child.destroy()
241241
notification = fabric_notif.get_notification_from_id(id)
242242
new_box = NotificationBox(notification)
243-
self.add(new_box)
244243
notification.connect("closed", self.on_notification_closed)
245-
self.notch.open_notch("notification")
244+
245+
self._pending_removal = False
246+
247+
for child in self.notch.notification_revealer:
248+
child.destroy()
249+
250+
self.notch.notification_revealer.add(new_box)
251+
self.notch.notification_revealer.show_all()
252+
self.notch.notification_revealer.set_reveal_child(True)
246253

247254
def on_notification_closed(self, notification, reason):
248-
self.notch.close_notch()
249-
# Set cursor to default
255+
self.notch.notification_revealer.set_reveal_child(False)
250256
self.set_pointer_cursor(self, "arrow")
251257
logger.info(f"Notification {notification.id} closed with reason: {reason}")
252-
for child in self.get_children():
253-
child.destroy()
258+
259+
self._pending_removal = True
260+
# Esperamos a que termine la transición antes de eliminar el hijo
261+
GLib.timeout_add(
262+
self.notch.notification_revealer.get_transition_duration(),
263+
self._remove_notification_children
264+
)
265+
266+
def _remove_notification_children(self):
267+
if self._pending_removal:
268+
for child in self.notch.notification_revealer:
269+
child.destroy()
270+
self._pending_removal = False
271+
return False # Para que el timeout no se repita

styles/notch.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#notch-box {
2-
margin: 10px;
3-
margin-top: 0px;
4-
transition: all 0.5s cubic-bezier(0.5, 0.25, 0, 1);
2+
margin: 0 60px 10px 60px;
53
}
64

75
#notch-box.hidden {
@@ -18,7 +16,7 @@
1816
min-height: 40px;
1917
min-width: 256px;
2018
border-radius: 0 0 20px 20px;
21-
transition: all 0.5s cubic-bezier(0.5, 0.25, 0, 1.25);
19+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
2220
}
2321

2422
#notch-content.launcher {

styles/notifications.css

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,54 @@
11
#notification-action-buttons button.start-action {
2-
border-radius: 20px;
2+
border-radius: 20px;
33
}
44

55
#notification-action-buttons button {
6-
background-color: var(--surface);
7-
padding: 8px;
6+
background-color: var(--surface);
7+
padding: 8px;
88
}
99

1010
#notification-action-buttons button:hover {
11-
background-color: var(--surface-bright);
11+
background-color: var(--surface-bright);
1212
}
1313

1414
#notification-action-buttons button:active {
15-
background-color: var(--primary);
15+
background-color: var(--primary);
1616
}
1717

1818
#notification-action-buttons button:active #button-label {
19-
color: var(--shadow);
19+
color: var(--shadow);
2020
}
2121

2222
#notification-image image {
23-
border-radius: 16px;
23+
border-radius: 16px;
2424
}
2525

2626
#notification-summary,
2727
#button-label {
28-
font-weight: bold;
28+
font-weight: bold;
2929
}
3030

3131
#notification-summary {
32-
font-weight: bold;
33-
color: var(--primary);
32+
font-weight: bold;
33+
color: var(--primary);
3434
}
3535

3636
#notification-app-name {
37-
color: var(--outline);
37+
color: var(--outline);
3838
}
3939

4040
#action-button {
41-
margin-top: 8px;
41+
margin-top: 8px;
4242
}
43+
44+
#notification-box {
45+
border-radius: 32px;
46+
padding: 16px;
47+
background-color: var(--shadow);
48+
margin: 8px;
49+
min-width: 336px;
50+
}
51+
52+
#boxed-notification-revealer {
53+
margin-top: -14px;
54+
}

styles/shadows.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#systray,
66
#battery,
77
#button-bar-vol,
8-
#control-small {
8+
#control-small,
9+
#notification-box {
910
box-shadow: 0 0 4px alpha(black, 0.5);
1011
}
1112

0 commit comments

Comments
 (0)