Add do not disturb toggle and bar indicator
This commit is contained in:
parent
85309c1b3c
commit
24339d5705
|
|
@ -1,11 +1,38 @@
|
||||||
import GLib from "gi://GLib"
|
import GLib from "gi://GLib"
|
||||||
import { App, Astal, Gdk, Gtk } from "astal/gtk3"
|
import { App, Astal, Gdk, Gtk } from "astal/gtk3"
|
||||||
import Notifd from "gi://AstalNotifd"
|
import Notifd from "gi://AstalNotifd"
|
||||||
import { bind } from "astal"
|
import { Variable, bind } from "astal"
|
||||||
import { MAX_TIMEOUT } from "../notif-config"
|
import { MAX_TIMEOUT } from "../notif-config"
|
||||||
|
|
||||||
const notifd = Notifd.get_default()
|
const notifd = Notifd.get_default()
|
||||||
|
|
||||||
|
export const dndIcon = Variable.derive([bind(notifd, "dontDisturb")], (dnd) =>
|
||||||
|
dnd
|
||||||
|
? "notifications-disabled-symbolic"
|
||||||
|
: "preferences-system-notifications-symbolic",
|
||||||
|
)
|
||||||
|
|
||||||
|
export function DndToggle() {
|
||||||
|
return (
|
||||||
|
<box
|
||||||
|
className={bind(notifd, "dontDisturb").as((v) =>
|
||||||
|
v ? "toggle-button active" : "toggle-button",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="toggle-pill"
|
||||||
|
hexpand
|
||||||
|
onClicked={() => (notifd.dontDisturb = !notifd.dontDisturb)}
|
||||||
|
>
|
||||||
|
<box hexpand>
|
||||||
|
<icon className="icon" icon={dndIcon()} />
|
||||||
|
<label className="label" label="Do Not Disturb" />
|
||||||
|
</box>
|
||||||
|
</button>
|
||||||
|
</box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
notifd.default_timeout = MAX_TIMEOUT
|
notifd.default_timeout = MAX_TIMEOUT
|
||||||
|
|
||||||
// notifications restored from the daemon's cache on startup are stale
|
// notifications restored from the daemon's cache on startup are stale
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { bluetoothIndicator, BluetoothSection } from "./Bluetooth"
|
||||||
import { BrightnessRow } from "./Brightness"
|
import { BrightnessRow } from "./Brightness"
|
||||||
import { MediaSection } from "./Media"
|
import { MediaSection } from "./Media"
|
||||||
import { batteryIcon, batteryPercent, BatterySection } from "./Battery"
|
import { batteryIcon, batteryPercent, BatterySection } from "./Battery"
|
||||||
import { NotificationCard } from "./Notifications"
|
import { NotificationCard, DndToggle, dndIcon } from "./Notifications"
|
||||||
|
|
||||||
const speaker = AstalWp.get_default().audio.default_speaker!
|
const speaker = AstalWp.get_default().audio.default_speaker!
|
||||||
const mic = AstalWp.get_default().audio.default_microphone
|
const mic = AstalWp.get_default().audio.default_microphone
|
||||||
|
|
@ -83,7 +83,7 @@ export default function QuickSettings(gdkmonitor: Gdk.Monitor) {
|
||||||
>
|
>
|
||||||
<box spacing={6}>
|
<box spacing={6}>
|
||||||
<box className="notif-indicator" spacing={3}>
|
<box className="notif-indicator" spacing={3}>
|
||||||
<icon icon="preferences-system-notifications-symbolic" />
|
<icon icon={dndIcon()} />
|
||||||
<label
|
<label
|
||||||
className="notif-count"
|
className="notif-count"
|
||||||
label={notifCount.as((n) => `${n}`)}
|
label={notifCount.as((n) => `${n}`)}
|
||||||
|
|
@ -139,6 +139,7 @@ export default function QuickSettings(gdkmonitor: Gdk.Monitor) {
|
||||||
</box>
|
</box>
|
||||||
)}
|
)}
|
||||||
<BrightnessRow />
|
<BrightnessRow />
|
||||||
|
<DndToggle />
|
||||||
<WifiSection open={open} />
|
<WifiSection open={open} />
|
||||||
<BluetoothSection open={open} />
|
<BluetoothSection open={open} />
|
||||||
<MediaSection />
|
<MediaSection />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue