Add notification timeout
This commit is contained in:
parent
77825859ec
commit
1a2bef6b9b
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue