Compare commits

...

4 commits

Author SHA1 Message Date
GaspardCulis
bce5209fe1
hypr: Removed deprecated config 2024-08-09 13:58:58 +02:00
GaspardCulis
129d6fa881
hypr -> startup: Exec "end-rs daemon" on startup 2024-08-09 13:58:17 +02:00
GaspardCulis
63c1da3f34
eww -> notification: Refactor widget to work with end-rs 2024-08-09 13:57:05 +02:00
GaspardCulis
13f8a8707c
sync + misc: Added end-rs config 2024-08-09 13:55:19 +02:00
7 changed files with 110 additions and 101 deletions

View file

@ -1,26 +1,45 @@
.notifications-container {
padding: 8px;
.notification {
padding: 6px;
margin-right: 12px;
margin-bottom: 12px;
background-color: $background;
border-radius: 20px;
.notification {
padding: 6px;
background-color: $background;
border-radius: 20px;
.notification-app-icon {
min-width: 24px;
min-height: 24px;
.notification-icon {
min-width: 128px;
min-height: 128px;
background-size: cover;
background-position: center center;
}
background-size: cover;
background-position: center center;
border-radius: 16px;
.notification-icon {
min-width: 128px;
min-height: 128px;
background-size: cover;
background-position: center center;
border-radius: 16px;
}
.notification-text-container {
padding-top: 6px;
.notification-summary {
font-weight: bold;
}
}
.notification-text-container {
padding-top: 6px;
.notification-buttons {
margin-top: 6px;
.notification-summary {
font-weight: bold;
}
.notification-button {
color: $text;
font-size: 0.8em;
padding: 8px;
border-radius: 10px;
margin-right: 12px;
border: 1px solid $text;
}
}
}

View file

@ -1,23 +1,27 @@
(defvar close_icon "/usr/share/icons/Qogir-ubuntu-dark/16/actions/window-close.svg")
(deflisten notifications :initial '[{"id": 69, "dismissed": false, "app_name": "notify-send", "replaces_id": 0, "app_icon": "/home/gaspard/Images/memes/vroom.png", "summary": "Work period over", "body": "You can take a little nap now.", "actions": [], "hints": {"urgency": 1, "sender-pid": 12406}, "expire_timeout": -1}]' "~/.config/eww/scripts/get-notifications")
(defvar end-binary "~/.cargo/bin/end-rs")
(defvar end-notifications '')
(defvar end-histories '')
(defvar end-replies '')
(defvar end-reply-text '')
(defwidget notification [notif]
(defwidget notification[notification]
(box
:class "notification"
:space-evenly false
:orientation "v"
:spacing 6
(box :orientation "h" :spacing 8 :space-evenly false
(image
:path "/usr/share/icons/Qogir-ubuntu/scalable/apps/spotify.svg"
:image-width 24
:image-height 24)
(box
:class "${notification.app_icon ?: "" != "" ? "notification-app-icon" : ""}"
:style "background-image: url('${notification.app_icon}');"
)
(label
:text "${notif.app_name}"
:text "${notification.application}"
:halign "start"
:hexpand true)
(button :onclick "dbus-send --session --dest=org.freedesktop.Notifications --type=method_call /org/freedesktop/Notifications org.freedesktop.Notifications.CloseNotification uint32:${notif.id}"
(button :onclick "${end-binary} close ${notification.id}"
(image
:path "${close_icon}"
:image-width 24
@ -26,8 +30,8 @@
)
(box :orientation "h" :space-evenly false :spacing 8
(box
:class "${notif.app_icon != "" ? "notification-icon" : ""}"
:style "background-image: url('${notif.app_icon}');"
:class "${notification.icon != "" ? "notification-icon" : ""}"
:style "background-image: url('${notification.icon}');"
)
(box
:class "notification-text-container"
@ -36,13 +40,26 @@
:space-evenly false
(label
:class "notification-summary"
:text "${notif.summary}"
:text "${notification.summary}"
:halign "start")
(label
:text "${notif.body}"
:text "${notification.body}"
:wrap true
:halign "fill"
:vexpand true)
(box
:class "notification-buttons"
:orientation "horizontal"
:space-evenly false
:halign "end"
:vexpand false
(for action in {notification.actions}
(button
:class "notification-button"
:onclick "${end-binary} action ${notification.id} ${action.id}"
:vexpand false
{action.text}))
)
)
)
)
@ -57,14 +74,5 @@
:stacking "overlay"
:focusable false
:exclusive true
(box
:class "notifications-container"
:orientation "v"
:halign "end"
:valign "end"
:spacing 6
(for notif in {jq(notifications, '[.[] | select(.dismissed == false)]')}
(notification :notif "${notif}")
)
)
(literal :content end-notifications)
)

View file

@ -1,56 +0,0 @@
#!/usr/bin/env python3
import json
import dbus
from random import randint
from threading import Timer
from gi.repository import GLib
from dbus.mainloop.glib import DBusGMainLoop
DEFAULT_NOTIF_TIMEOUT = 10 * 1000
notification_history = []
def set_timeout(fn, ms, *args, **kwargs):
t = Timer(ms / 1000, fn, args=args, kwargs=kwargs)
t.start()
return t
def dismiss_notification(notification_id: int):
for notification in notification_history:
if notification["id"] == notification_id:
notification["dismissed"] = True
print(json.dumps(notification_history), flush=True)
def handle_notification(_, message):
keys = ["app_name", "replaces_id", "app_icon", "summary",
"body", "actions", "hints", "expire_timeout"]
args = message.get_args_list()
match message.get_member() :
case "Notify":
notification = dict([(keys[i], args[i]) for i in range(8)])
notification["dismissed"] = False
notification["id"] = randint(0, 8192 * 2)
notification_history.append(notification)
expire_timeout = int(notification["expire_timeout"])
set_timeout(dismiss_notification, expire_timeout if expire_timeout > 0 else DEFAULT_NOTIF_TIMEOUT, notification["id"])
print(json.dumps(notification_history), flush=True)
case "CloseNotification":
dismiss_notification(int(args[0]))
case _:
return
if __name__ == "__main__":
DBusGMainLoop(set_as_default=True)
notification_bus = dbus.SessionBus()
notification_bus.add_match_string("type='method_call',interface='org.freedesktop.Notifications',eavesdrop=true")
notification_bus.add_message_filter(handle_notification)
loop = GLib.MainLoop()
loop.run()

View file

@ -80,11 +80,6 @@ dwindle {
preserve_split = yes # you probably want this
}
master {
# See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
new_is_master = true
}
gestures {
# See https://wiki.hyprland.org/Configuring/Variables/ for more
workspace_swipe = on

View file

@ -2,7 +2,7 @@
exec-once = hyprpm reload -n
exec-once = artix-pipewire-launcher restart
exec-once = mako
exec-once = ~/.cargo/bin/end-rs daemon
exec-once = wallpaperctl daemon
exec-once = swayosd-server
exec-once = udiskie

42
misc/end-rs/config.toml Normal file
View file

@ -0,0 +1,42 @@
### Path to the eww binary
eww_binary_path = "/usr/bin/eww"
### Where to find the icons for the notifications
icon_dirs = [
"/usr/share/icons",
"/usr/share/pixmaps",
]
### The theme to use for the icons
icon_theme = "Adwaita"
### The default notification window
### Can be a single string or a vector of strings(for multi-monitor support)
eww_notification_window = "notification_overlay"
### The default notification widget
eww_notification_widget = "notification"
### The variable which contains the literal for the notifications
eww_notification_var = "end-notifications"
### The default history window
eww_history_window = "history-frame"
### The default history widget
eww_history_widget = "end-history"
### The variable which contains the literal for the history
eww_history_var = "end-histories"
### The default reply window
eww_reply_window = "reply-frame"
### The default reply widget
eww_reply_widget = "end-reply"
### The variable which contains the literal for the replies
eww_reply_var = "end-replies"
### The variable which contains content for the reply text
eww_reply_text = "end-reply-text"
### Max notifications to be preserved in history. In case of 0, all notifications will be preserved.
max_notifications = 10
### The orientation of the notifications. Can be either "v" or "h" or "vertical" or "horizontal" (Basically the eww orientation value)
notification_orientation = "v"
### The timeouts for different types of notifications in seconds. A value of 0 means that the notification will never timeout
[timeout]
low = 5
normal = 10
critical = 0

1
sync
View file

@ -57,6 +57,7 @@ synced_files = [
("misc/picom/", "~/.config/picom/"),
("misc/runst/", "~/.config/runst/"),
("misc/mako/", "~/.config/mako/"),
("misc/end-rs/", "~/.config/end-rs/"),
("misc/swayosd/", "~/.config/swayosd/"),
("misc/anyrun/", "~/.config/anyrun/"),
("misc/x11-toggle-gpu/", "~/.local/share/x11-toggle-gpu/"),