From 5bf54c73cea483b17224fc393abebdc33997e8a6 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Fri, 4 Apr 2025 11:10:07 -0400 Subject: [PATCH] implement swaync --- widget/Bar.tsx | 2 ++ widget/SwayNC.tsx | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 widget/SwayNC.tsx diff --git a/widget/Bar.tsx b/widget/Bar.tsx index 903f5b6..74aae85 100644 --- a/widget/Bar.tsx +++ b/widget/Bar.tsx @@ -6,6 +6,7 @@ import Mpris from "./Mpris"; import OS from "./OS"; import Pywal from "./Pywal"; import Tray from "./Tray"; +import SwayNC from "./SwayNC"; export default function Bar(gdkmonitor: Gdk.Monitor) { const { TOP, LEFT, RIGHT } = Astal.WindowAnchor; @@ -32,6 +33,7 @@ export default function Bar(gdkmonitor: Gdk.Monitor) { + diff --git a/widget/SwayNC.tsx b/widget/SwayNC.tsx new file mode 100644 index 0000000..2b98c6b --- /dev/null +++ b/widget/SwayNC.tsx @@ -0,0 +1,47 @@ +import { bind } from "astal"; +import { exec, Variable } from "astal"; +import { Gdk } from "astal/gtk4"; + +type SwayNCOptions = { + text: string; + alt: "none" | "notification" | "dnd-none" | "dnd-notification"; + tooltip: string; + class: "notification" | "dnd-notification"; +}; + +function Icon(alt: SwayNCOptions["alt"]) { + switch (alt) { + case "none": { + return "󰂜"; + } + case "notification": { + return "󰅸"; + } + case "dnd-none": { + return "󱏨"; + } + case "dnd-notification": { + return "󱏨"; + } + } +} + +const SwayNC = function () { + const options = Variable(null).watch( + "swaync-client -swb", + (stdout, prev) => { + return JSON.parse(stdout) as SwayNCOptions; + }, + ); + + return ( + + ); +}; + +export default SwayNC;