diff --git a/ags/window/AppsWindow.ts b/ags/window/AppsWindow.ts index d20cfa7..2336ff5 100644 --- a/ags/window/AppsWindow.ts +++ b/ags/window/AppsWindow.ts @@ -117,6 +117,7 @@ export const AppsWindow = (mon: number): (Widget.Window) => { marginTop: 64, onDestroy: () => { searchSubscription?.(); + searchString.drop(); flowboxConnections.map(id => flowbox.disconnect(id)); }, onKeyPressEvent: (_, event: Gdk.Event) => { diff --git a/ags/window/OSD.ts b/ags/window/OSD.ts index 9db81a9..07a767a 100644 --- a/ags/window/OSD.ts +++ b/ags/window/OSD.ts @@ -7,73 +7,86 @@ export enum OSDModes { BRIGHTNESS } -let osdMode: Variable = new Variable(OSDModes.SINK); -let osdIcon: Binding = osdMode().as((mode: OSDModes) => { - switch(mode) { - case OSDModes.SINK: return "󰕾"; - case OSDModes.BRIGHTNESS: return "󰃠"; - default: return "󱧣"; - } -}); +let osdMode: (Variable|null); +let osdIcon: (Binding|null); export function setOSDMode(newMode: OSDModes): void { + if(!osdMode) return; + osdMode.set(newMode); } -export const OSD = (mon: number) => new Widget.Window({ - namespace: "osd", - layer: Astal.Layer.OVERLAY, - anchor: Astal.WindowAnchor.BOTTOM, - canFocus: false, - marginBottom: 80, - focusOnClick: false, - clickThrough: true, - monitor: mon, - child: new Widget.Box({ - className: "osd", - children: [ - new Widget.Label({ - className: "icon", - label: osdIcon - } as Widget.LabelProps), - new Widget.Box({ - className: "volume", - orientation: Gtk.Orientation.VERTICAL, - valign: Gtk.Align.CENTER, - children: [ - new Widget.Label({ - className: "device", - label: bind(Wireplumber.getDefault().getDefaultSink(), "name").as((name: string) => - name || "Speaker"), - halign: Gtk.Align.CENTER - } as Widget.LabelProps), - new Widget.Box({ - vexpand: false, - expand: false, - children: [ - new Widget.LevelBar({ - className: "levelbar", - width_request: 120, - value: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) => - Math.floor(volume * 100)), - maxValue: bind(Wireplumber.getWireplumber(), "defaultSpeaker").as(() => - Wireplumber.getDefault().getMaxSinkVolume()), - vexpand: false, - expand: false, - halign: Gtk.Align.CENTER - } as Widget.LevelBarProps), - /*new Widget.Label({ - className: "value", - label: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) => - `${Math.floor(volume * 100)}%`), - vexpand: false, - expand: false, - halign: Gtk.Align.CENTER - } as Widget.LabelProps)*/ - ] - } as Widget.BoxProps) - ] - } as Widget.BoxProps) - ] - } as Widget.BoxProps) -} as Widget.WindowProps); +export const OSD = (mon: number) => { + osdMode = new Variable(OSDModes.SINK); + osdIcon = osdMode().as((mode: OSDModes) => { + switch(mode) { + case OSDModes.SINK: return "󰕾"; + case OSDModes.BRIGHTNESS: return "󰃠"; + default: return "󱧣"; + } + }); + + return new Widget.Window({ + namespace: "osd", + layer: Astal.Layer.OVERLAY, + anchor: Astal.WindowAnchor.BOTTOM, + canFocus: false, + marginBottom: 80, + focusOnClick: false, + clickThrough: true, + monitor: mon, + onDestroy: () => { + osdMode?.drop(); + + osdMode = null; + osdIcon = null; + }, + child: new Widget.Box({ + className: "osd", + children: [ + new Widget.Label({ + className: "icon", + label: osdIcon + } as Widget.LabelProps), + new Widget.Box({ + className: "volume", + orientation: Gtk.Orientation.VERTICAL, + valign: Gtk.Align.CENTER, + children: [ + new Widget.Label({ + className: "device", + label: bind(Wireplumber.getDefault().getDefaultSink(), "name").as((name: string) => + name || "Speaker"), + halign: Gtk.Align.CENTER + } as Widget.LabelProps), + new Widget.Box({ + vexpand: false, + expand: false, + children: [ + new Widget.LevelBar({ + className: "levelbar", + width_request: 120, + value: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) => + Math.floor(volume * 100)), + maxValue: bind(Wireplumber.getWireplumber(), "defaultSpeaker").as(() => + Wireplumber.getDefault().getMaxSinkVolume()), + vexpand: false, + expand: false, + halign: Gtk.Align.CENTER + } as Widget.LevelBarProps), + /*new Widget.Label({ + className: "value", + label: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) => + `${Math.floor(volume * 100)}%`), + vexpand: false, + expand: false, + halign: Gtk.Align.CENTER + } as Widget.LabelProps)*/ + ] + } as Widget.BoxProps) + ] + } as Widget.BoxProps) + ] + } as Widget.BoxProps) + } as Widget.WindowProps); +}