Add notification timeout

This commit is contained in:
Thomas Avé 2025-07-11 11:47:47 +02:00
parent 77825859ec
commit 1a2bef6b9b
2 changed files with 6 additions and 2 deletions

View File

@ -71,7 +71,7 @@ function Date({ format = "%Y-%m-%d" }): JSX.Element {
}
function Time({ format = "%H:%M:%S" }): JSX.Element {
const time = createPoll<string>("", 10000, () => GLib.DateTime.new_now_local().format(format)!)
const time = createPoll<string>("", 1000, () => GLib.DateTime.new_now_local().format(format)!)
return <label
class="item blue"
label={time}

View File

@ -4,6 +4,7 @@ import Adw from "gi://Adw"
import GLib from "gi://GLib"
import AstalNotifd from "gi://AstalNotifd"
import Pango from "gi://Pango"
import { timeout } from "ags/time"
function isIcon(icon?: string | null) {
const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()!)
@ -38,6 +39,9 @@ export default function Notification({
notification: AstalNotifd.Notification
onHoverLost: () => void
}) {
const timer = timeout(3000, () => {
onHoverLost()
})
return (
<Adw.Clamp maximumSize={400}>
<box
@ -45,7 +49,7 @@ export default function Notification({
class={`Notification ${urgency(n)}`}
orientation={Gtk.Orientation.VERTICAL}
>
<Gtk.EventControllerMotion onLeave={onHoverLost} />
<Gtk.EventControllerMotion onEnter={() => timer.cancel()} onLeave={onHoverLost} />
<box class="header">
{(n.appIcon || isIcon(n.desktopEntry)) && (
<image