diff --git a/nixosModules/ags/config/configurations/binto.ts b/nixosModules/ags/config/configurations/binto.ts index 8bb571c7..ab04c93c 100644 --- a/nixosModules/ags/config/configurations/binto.ts +++ b/nixosModules/ags/config/configurations/binto.ts @@ -33,7 +33,7 @@ export default () => { respond('closed all windows'); } else if (request.startsWith('fetchCapsState')) { - Brightness.fetchCapsState(); + Brightness.get_default().fetchCapsState(); respond('fetched caps_lock state'); } else if (request.startsWith('popup')) { @@ -41,7 +41,7 @@ export default () => { respond('osd popped up'); } else if (request.startsWith('save-replay')) { - GSR.saveReplay(); + GSR.get_default().saveReplay(); respond('saving replay'); } }, @@ -61,9 +61,9 @@ export default () => { PowerMenu(); Screenshot(); - Brightness.initService({ caps: 'input2::capslock' }); - GSR.initService(); - new MonitorClicks(); + Brightness.get_default({ caps: 'input2::capslock' }); + GSR.get_default(); + MonitorClicks.get_default(); }, }); }; diff --git a/nixosModules/ags/config/configurations/wim.ts b/nixosModules/ags/config/configurations/wim.ts index 692f586b..49c98a48 100644 --- a/nixosModules/ags/config/configurations/wim.ts +++ b/nixosModules/ags/config/configurations/wim.ts @@ -34,11 +34,11 @@ export default () => { respond('closed all windows'); } else if (request.startsWith('fetchCapsState')) { - Brightness.fetchCapsState(); + Brightness.get_default().fetchCapsState(); respond('fetched caps_lock state'); } else if (request.startsWith('Brightness.screen')) { - Brightness.screen += parseFloat(request.replace('Brightness.screen ', '')); + Brightness.get_default().screen += parseFloat(request.replace('Brightness.screen ', '')); respond('screen brightness changed'); } else if (request.startsWith('popup')) { @@ -68,11 +68,11 @@ export default () => { PowerMenu(); Screenshot(); - Brightness.initService({ + Brightness.get_default({ kbd: 'tpacpi::kbd_backlight', caps: 'input1::capslock', }); - new MonitorClicks(); + MonitorClicks.get_default(); }, }); }; diff --git a/nixosModules/ags/config/lib.ts b/nixosModules/ags/config/lib.ts index 153ef72e..3d50c792 100644 --- a/nixosModules/ags/config/lib.ts +++ b/nixosModules/ags/config/lib.ts @@ -2,7 +2,6 @@ import { idle } from 'astal'; import { App, Gdk, Gtk } from 'astal/gtk3'; import AstalHyprland from 'gi://AstalHyprland'; -const Hyprland = AstalHyprland.get_default(); /* Types */ import PopupWindow from './widgets/misc/popup-window'; @@ -32,19 +31,23 @@ export interface CursorPos { export const get_hyprland_monitor = (monitor: Gdk.Monitor): AstalHyprland.Monitor | undefined => { + const hyprland = AstalHyprland.get_default(); + const manufacturer = monitor.manufacturer?.replace(',', ''); const model = monitor.model?.replace(',', ''); const start = `${manufacturer} ${model}`; - return Hyprland.get_monitors().find((m) => m.description?.startsWith(start)); + return hyprland.get_monitors().find((m) => m.description?.startsWith(start)); }; export const get_hyprland_monitor_desc = (monitor: Gdk.Monitor): string => { + const hyprland = AstalHyprland.get_default(); + const manufacturer = monitor.manufacturer?.replace(',', ''); const model = monitor.model?.replace(',', ''); const start = `${manufacturer} ${model}`; - return `desc:${Hyprland.get_monitors().find((m) => m.description?.startsWith(start))?.description}`; + return `desc:${hyprland.get_monitors().find((m) => m.description?.startsWith(start))?.description}`; }; export const get_gdkmonitor_from_desc = (desc: string): Gdk.Monitor => { @@ -69,9 +72,11 @@ export const hyprMessage = (message: string) => new Promise(( resolution = () => { /**/ }, rejection = () => { /**/ }, ) => { + const hyprland = AstalHyprland.get_default(); + try { - Hyprland.message_async(message, (_, asyncResult) => { - const result = Hyprland.message_finish(asyncResult); + hyprland.message_async(message, (_, asyncResult) => { + const result = hyprland.message_finish(asyncResult); resolution(result); }); @@ -82,9 +87,11 @@ export const hyprMessage = (message: string) => new Promise(( }); export const centerCursor = (): void => { + const hyprland = AstalHyprland.get_default(); + let x: number; let y: number; - const monitor = Hyprland.get_focused_monitor(); + const monitor = hyprland.get_focused_monitor(); switch (monitor.transform) { case 1: diff --git a/nixosModules/ags/config/services/brightness.ts b/nixosModules/ags/config/services/brightness.ts index 66d5761d..764a8a70 100644 --- a/nixosModules/ags/config/services/brightness.ts +++ b/nixosModules/ags/config/services/brightness.ts @@ -12,7 +12,7 @@ const SCREEN_ICONS: Record = { const INTERVAL = 500; @register() -class Brightness extends GObject.Object { +export default class Brightness extends GObject.Object { declare private _kbd: string | undefined; declare private _caps: string | undefined; @@ -98,33 +98,39 @@ class Brightness extends GObject.Object { return this._capsIcon; } - /** - * This is to basically have the constructor run when I want and - * still export this to wherever I need to. - * - * @param o params - * @param o.kbd name of kbd in brightnessctl - * @param o.caps name of caps_lock in brightnessctl - */ - public async initService({ kbd, caps }: { kbd?: string, caps?: string }) { - try { - if (kbd) { - this.hasKbd = true; - this._kbd = kbd; - this._monitorKbdState(); - this._kbdMax = Number(await execAsync(`brightnessctl -d ${this._kbd} m`)); - } + public constructor({ kbd, caps }: { kbd?: string, caps?: string } = {}) { + super(); - this._caps = caps; - this._screen = Number(await execAsync('brightnessctl g')) / - Number(await execAsync('brightnessctl m')); - this.notify('screen'); + try { + (async() => { + if (kbd) { + this.hasKbd = true; + this._kbd = kbd; + this._monitorKbdState(); + this._kbdMax = Number(await execAsync(`brightnessctl -d ${this._kbd} m`)); + } + + this._caps = caps; + this._screen = Number(await execAsync('brightnessctl g')) / + Number(await execAsync('brightnessctl m')); + this.notify('screen'); + })(); } catch (_e) { console.error('missing dependency: brightnessctl'); } } + private static _default: InstanceType | undefined; + + public static get_default({ kbd, caps }: { kbd?: string, caps?: string } = {}) { + if (!Brightness._default) { + Brightness._default = new Brightness({ kbd, caps }); + } + + return Brightness._default; + } + private _getScreenIcon() { const brightness = this._screen * 100; @@ -168,7 +174,3 @@ class Brightness extends GObject.Object { .catch(logError); } } - -const brightnessService = new Brightness(); - -export default brightnessService; diff --git a/nixosModules/ags/config/services/gpu-screen-recorder.ts b/nixosModules/ags/config/services/gpu-screen-recorder.ts index 5e01ab1c..e6c1cd03 100644 --- a/nixosModules/ags/config/services/gpu-screen-recorder.ts +++ b/nixosModules/ags/config/services/gpu-screen-recorder.ts @@ -72,10 +72,12 @@ const notifySend = ({ }); @register() -class GSR extends GObject.Object { +export default class GSR extends GObject.Object { private _lastNotifID: number | undefined; - public initService() { + public constructor() { + super(); + try { subprocess( ['gsr-start'], @@ -99,6 +101,16 @@ class GSR extends GObject.Object { } } + private static _default: InstanceType | undefined; + + public static get_default() { + if (!GSR._default) { + GSR._default = new GSR(); + } + + return GSR._default; + } + public saveReplay() { execAsync(['gpu-save-replay']) .then(async() => { @@ -155,7 +167,3 @@ class GSR extends GObject.Object { }); } } - -const gsrService = new GSR(); - -export default gsrService; diff --git a/nixosModules/ags/config/services/monitor-clicks.ts b/nixosModules/ags/config/services/monitor-clicks.ts index 67d8af1d..1c337bc4 100644 --- a/nixosModules/ags/config/services/monitor-clicks.ts +++ b/nixosModules/ags/config/services/monitor-clicks.ts @@ -39,10 +39,10 @@ export default class MonitorClicks extends GObject.Object { constructor() { super(); - this.#initAppConnection(); + this._initAppConnection(); } - startProc() { + private _startProc() { if (this.process) { return; } @@ -68,7 +68,7 @@ export default class MonitorClicks extends GObject.Object { this.emit('proc-started', true); } - killProc() { + private _killProc() { if (this.process) { this.process.kill(); this.process = null; @@ -76,7 +76,7 @@ export default class MonitorClicks extends GObject.Object { } } - #initAppConnection() { + private _initAppConnection() { App.connect('window-toggled', () => { const anyVisibleAndClosable = (App.get_windows() as PopupWindow[]).some((w) => { @@ -90,16 +90,26 @@ export default class MonitorClicks extends GObject.Object { }); if (anyVisibleAndClosable) { - this.startProc(); + this._startProc(); } else { - this.killProc(); + this._killProc(); } }); } - static async detectClickedOutside(clickStage: string) { + private static _default: InstanceType | undefined; + + public static get_default() { + if (!MonitorClicks._default) { + MonitorClicks._default = new MonitorClicks(); + } + + return MonitorClicks._default; + } + + public static async detectClickedOutside(clickStage: string) { const toClose = ((App.get_windows() as PopupWindow[])).some((w) => { const closable = ( w.close_on_unfocus && @@ -124,6 +134,7 @@ export default class MonitorClicks extends GObject.Object { const noCloseWidgetsNames = [ 'bar-', 'osk', + 'noanim-', ]; const getNoCloseWidgets = (names: string[]) => { diff --git a/nixosModules/ags/config/widgets/applauncher/app-item.tsx b/nixosModules/ags/config/widgets/applauncher/app-item.tsx index 6c131934..419df209 100644 --- a/nixosModules/ags/config/widgets/applauncher/app-item.tsx +++ b/nixosModules/ags/config/widgets/applauncher/app-item.tsx @@ -33,9 +33,7 @@ export class AppItem extends Widget.Box { ); const textBox = ( - + + + ); +}; diff --git a/nixosModules/ags/config/widgets/bar/items/tray.tsx b/nixosModules/ags/config/widgets/bar/items/tray.tsx index cb641532..ce72c80a 100644 --- a/nixosModules/ags/config/widgets/bar/items/tray.tsx +++ b/nixosModules/ags/config/widgets/bar/items/tray.tsx @@ -2,7 +2,6 @@ import { App, Gdk, Gtk, Widget } from 'astal/gtk3'; import { bind, idle } from 'astal'; import AstalTray from 'gi://AstalTray'; -const Tray = AstalTray.get_default(); const SKIP_ITEMS = ['.spotify-wrapped']; @@ -35,20 +34,22 @@ const TrayItem = (item: AstalTray.TrayItem) => { }; export default () => { + const tray = AstalTray.get_default(); + const itemMap = new Map(); return ( items.length !== 0)} + visible={bind(tray, 'items').as((items) => items.length !== 0)} setup={(self) => { self - .hook(Tray, 'item-added', (_, item: string) => { - if (itemMap.has(item) || SKIP_ITEMS.includes(Tray.get_item(item).title)) { + .hook(tray, 'item-added', (_, item: string) => { + if (itemMap.has(item) || SKIP_ITEMS.includes(tray.get_item(item).title)) { return; } - const widget = TrayItem(Tray.get_item(item)) as Widget.Revealer; + const widget = TrayItem(tray.get_item(item)) as Widget.Revealer; itemMap.set(item, widget); @@ -59,7 +60,7 @@ export default () => { }); }) - .hook(Tray, 'item-removed', (_, item: string) => { + .hook(tray, 'item-removed', (_, item: string) => { if (!itemMap.has(item)) { return; } diff --git a/nixosModules/ags/config/widgets/bar/items/workspaces.tsx b/nixosModules/ags/config/widgets/bar/items/workspaces.tsx index b5722f03..c1a1baf5 100644 --- a/nixosModules/ags/config/widgets/bar/items/workspaces.tsx +++ b/nixosModules/ags/config/widgets/bar/items/workspaces.tsx @@ -2,78 +2,83 @@ import { Gtk, Widget } from 'astal/gtk3'; import { timeout } from 'astal'; import AstalHyprland from 'gi://AstalHyprland'; -const Hyprland = AstalHyprland.get_default(); import { hyprMessage } from '../../../lib'; const URGENT_DURATION = 1000; -const Workspace = ({ id = 0 }) => ( - - { + const hyprland = AstalHyprland.get_default(); - onClickRelease={() => { - hyprMessage(`dispatch workspace ${id}`).catch(console.log); - }} + return ( + - { - const update = ( - _: Widget.Box, - client?: AstalHyprland.Client, - ) => { - const workspace = Hyprland.get_workspace(id); - const occupied = workspace && workspace.get_clients().length > 0; + onClickRelease={() => { + hyprMessage(`dispatch workspace ${id}`).catch(console.log); + }} + > + { + const update = ( + _: Widget.Box, + client?: AstalHyprland.Client, + ) => { + const workspace = hyprland.get_workspace(id); + const occupied = workspace && workspace.get_clients().length > 0; - if (!client) { - return; - } + self.toggleClassName('occupied', occupied); - const isUrgent = client && + if (!client) { + return; + } + + const isUrgent = client && client.get_workspace().get_id() === id; - if (isUrgent) { - self.toggleClassName('urgent', true); + if (isUrgent) { + self.toggleClassName('urgent', true); // Only show for a sec when urgent is current workspace - if (Hyprland.get_focused_workspace().get_id() === id) { - timeout(URGENT_DURATION, () => { - self.toggleClassName('urgent', false); - }); + if (hyprland.get_focused_workspace().get_id() === id) { + timeout(URGENT_DURATION, () => { + self.toggleClassName('urgent', false); + }); + } } - } - }; + }; - update(self); - self - .hook(Hyprland, 'event', () => update(self)) + update(self); + self + .hook(hyprland, 'event', () => update(self)) // Deal with urgent windows - .hook(Hyprland, 'urgent', update) + .hook(hyprland, 'urgent', update) - .hook(Hyprland, 'notify::focused-workspace', () => { - if (Hyprland.get_focused_workspace().get_id() === id) { - self.toggleClassName('urgent', false); - } - }); - }} - /> - - -); + .hook(hyprland, 'notify::focused-workspace', () => { + if (hyprland.get_focused_workspace().get_id() === id) { + self.toggleClassName('urgent', false); + } + }); + }} + /> + + + ); +}; export default () => { + const Hyprland = AstalHyprland.get_default(); + const L_PADDING = 2; const WS_WIDTH = 30; diff --git a/nixosModules/ags/config/widgets/clipboard/clip-item.tsx b/nixosModules/ags/config/widgets/clipboard/clip-item.tsx index aee0bda9..dea0f33b 100644 --- a/nixosModules/ags/config/widgets/clipboard/clip-item.tsx +++ b/nixosModules/ags/config/widgets/clipboard/clip-item.tsx @@ -94,5 +94,3 @@ export class ClipItem extends Widget.Box { } } } - -export default ClipItem; diff --git a/nixosModules/ags/config/widgets/notifs/binto.tsx b/nixosModules/ags/config/widgets/notifs/binto.tsx index d09cc9a3..9938504e 100644 --- a/nixosModules/ags/config/widgets/notifs/binto.tsx +++ b/nixosModules/ags/config/widgets/notifs/binto.tsx @@ -10,8 +10,8 @@ import Center from './center'; export const NotifPopups = () => ( diff --git a/nixosModules/ags/config/widgets/notifs/center.tsx b/nixosModules/ags/config/widgets/notifs/center.tsx index 70b20aa8..feb4f6f4 100644 --- a/nixosModules/ags/config/widgets/notifs/center.tsx +++ b/nixosModules/ags/config/widgets/notifs/center.tsx @@ -2,7 +2,6 @@ import { bind, timeout } from 'astal'; import { App, Gtk, Widget } from 'astal/gtk3'; import AstalNotifd from 'gi://AstalNotifd'; -const Notifications = AstalNotifd.get_default(); import { Notification, HasNotifs } from './notification'; import NotifGestureWrapper from './gesture'; @@ -22,71 +21,79 @@ const addNotif = (box: Widget.Box, notifObj: AstalNotifd.Notification) => { } }; -const NotificationList = () => ( - { + const notifications = AstalNotifd.get_default(); - setup={(self) => { - Notifications.get_notifications().forEach((n) => { - addNotif(self, n); - }); + return ( + { - if (id) { - const notifObj = Notifications.get_notification(id); + setup={(self) => { + notifications.get_notifications().forEach((n) => { + addNotif(self, n); + }); - if (notifObj) { - addNotif(self, notifObj); + self + .hook(notifications, 'notified', (_, id) => { + if (id) { + const notifObj = notifications.get_notification(id); + + if (notifObj) { + addNotif(self, notifObj); + } } - } - }) - .hook(Notifications, 'resolved', (_, id) => { - const notif = (self.get_children() as NotifGestureWrapper[]) - .find((ch) => ch.id === id); + }) + .hook(notifications, 'resolved', (_, id) => { + const notif = (self.get_children() as NotifGestureWrapper[]) + .find((ch) => ch.id === id); - if (notif?.sensitive) { - notif.slideAway('Right'); - } - }); - }} - /> -); - -const ClearButton = () => ( - hasNotifs ? 'pointer' : 'not-allowed')} - > - - -); +const ClearButton = () => { + const notifications = AstalNotifd.get_default(); + + return ( + hasNotifs ? 'pointer' : 'not-allowed')} + > + + + ); +}; const Header = () => ( diff --git a/nixosModules/ags/config/widgets/notifs/gesture.tsx b/nixosModules/ags/config/widgets/notifs/gesture.tsx index 644a58ea..40489298 100644 --- a/nixosModules/ags/config/widgets/notifs/gesture.tsx +++ b/nixosModules/ags/config/widgets/notifs/gesture.tsx @@ -5,7 +5,6 @@ import { idle, interval, timeout } from 'astal'; import AstalIO from 'gi://AstalIO'; import AstalNotifd from 'gi://AstalNotifd'; -const Notifications = AstalNotifd.get_default(); import { hyprMessage } from '../../lib'; @@ -159,10 +158,12 @@ export class NotifGestureWrapper extends Widget.EventBox { if (!duplicate) { // Kill notif if specified if (!this.is_popup) { - Notifications.get_notification(this.id)?.dismiss(); + const notifications = AstalNotifd.get_default(); + + notifications.get_notification(this.id)?.dismiss(); // Update HasNotifs - HasNotifs.set(Notifications.get_notifications().length > 0); + HasNotifs.set(notifications.get_notifications().length > 0); } else { // Make sure we cleanup any references to this instance @@ -183,6 +184,8 @@ export class NotifGestureWrapper extends Widget.EventBox { setup_notif = () => { /**/ }, ...rest }: NotifGestureWrapperProps) { + const notifications = AstalNotifd.get_default(); + super({ on_button_press_event: () => { this.setCursor('grabbing'); @@ -234,7 +237,7 @@ export class NotifGestureWrapper extends Widget.EventBox { }); } - this.hook(Notifications, 'notified', (_, notifId) => { + this.hook(notifications, 'notified', (_, notifId) => { if (notifId === this.id) { this.slideAway(this.is_popup ? 'Left' : 'Right', true); } @@ -315,7 +318,7 @@ export class NotifGestureWrapper extends Widget.EventBox { slideRight; idle(() => { - if (!Notifications.get_notification(id)) { + if (!notifications.get_notification(id)) { return; } @@ -328,7 +331,7 @@ export class NotifGestureWrapper extends Widget.EventBox { rev.revealChild = true; timeout(ANIM_DURATION, () => { - if (!Notifications.get_notification(id)) { + if (!notifications.get_notification(id)) { return; } diff --git a/nixosModules/ags/config/widgets/notifs/notification.tsx b/nixosModules/ags/config/widgets/notifs/notification.tsx index 363acc23..c209e34f 100644 --- a/nixosModules/ags/config/widgets/notifs/notification.tsx +++ b/nixosModules/ags/config/widgets/notifs/notification.tsx @@ -7,7 +7,6 @@ import AstalApps from 'gi://AstalApps'; const Applications = AstalApps.Apps.new(); import AstalNotifd from 'gi://AstalNotifd'; -const Notifications = AstalNotifd.get_default(); import NotifGestureWrapper from './gesture'; // import SmoothProgress from '../misc/smooth-progress'; @@ -94,7 +93,9 @@ export const Notification = ({ popup_timer = 0, slide_in_from = 'Left' as 'Left' | 'Right', }): NotifGestureWrapper | undefined => { - const notifObj = Notifications.get_notification(id); + const notifications = AstalNotifd.get_default(); + + const notifObj = notifications.get_notification(id); if (!notifObj) { return; @@ -106,7 +107,7 @@ export const Notification = ({ return; } - HasNotifs.set(Notifications.get_notifications().length > 0); + HasNotifs.set(notifications.get_notifications().length > 0); // const progress = SmoothProgress({ className: 'smooth-progress' }); diff --git a/nixosModules/ags/config/widgets/notifs/popups.tsx b/nixosModules/ags/config/widgets/notifs/popups.tsx index 25969cdb..033b81fc 100644 --- a/nixosModules/ags/config/widgets/notifs/popups.tsx +++ b/nixosModules/ags/config/widgets/notifs/popups.tsx @@ -1,65 +1,68 @@ import AstalNotifd from 'gi://AstalNotifd'; -const Notifications = AstalNotifd.get_default(); import NotifGestureWrapper from './gesture'; import { Notification } from './notification'; -export default () => ( - { + const notifications = AstalNotifd.get_default(); + + return ( + { - const notifQueue: number[] = []; + setup={(self) => { + const notifQueue: number[] = []; - const addPopup = (id: number) => { - if (!id || !Notifications.get_notification(id)) { - return; - } + const addPopup = (id: number) => { + if (!id || !notifications.get_notification(id)) { + return; + } - if (NotifGestureWrapper.sliding_in === 0) { - const NewNotif = Notification({ id, popup_timer: 5 }); + if (NotifGestureWrapper.sliding_in === 0) { + const NewNotif = Notification({ id, popup_timer: 5 }); - if (NewNotif) { + if (NewNotif) { // Use this instead of add to put it at the top - self.pack_end(NewNotif, false, false, 0); - self.show_all(); + self.pack_end(NewNotif, false, false, 0); + self.show_all(); - NotifGestureWrapper.popups.set(id, NewNotif); + NotifGestureWrapper.popups.set(id, NewNotif); + } } - } - else { - notifQueue.push(id); - } - }; - - NotifGestureWrapper.on_sliding_in = (n) => { - if (n === 0) { - const id = notifQueue.shift(); - - if (id) { - addPopup(id); + else { + notifQueue.push(id); } - } - }; + }; - const handleResolved = (id: number) => { - const notif = NotifGestureWrapper.popups.get(id); + NotifGestureWrapper.on_sliding_in = (n) => { + if (n === 0) { + const id = notifQueue.shift(); - if (!notif) { - return; - } + if (id) { + addPopup(id); + } + } + }; - notif.slideAway('Left'); - NotifGestureWrapper.popups.delete(id); - }; + const handleResolved = (id: number) => { + const notif = NotifGestureWrapper.popups.get(id); - self - .hook(Notifications, 'notified', (_, id) => addPopup(id)) - .hook(Notifications, 'resolved', (_, id) => handleResolved(id)); - }} - /> -); + if (!notif) { + return; + } + + notif.slideAway('Left'); + NotifGestureWrapper.popups.delete(id); + }; + + self + .hook(notifications, 'notified', (_, id) => addPopup(id)) + .hook(notifications, 'resolved', (_, id) => handleResolved(id)); + }} + /> + ); +}; diff --git a/nixosModules/ags/config/widgets/osd/main.tsx b/nixosModules/ags/config/widgets/osd/main.tsx index ea05c787..6ded4dc7 100644 --- a/nixosModules/ags/config/widgets/osd/main.tsx +++ b/nixosModules/ags/config/widgets/osd/main.tsx @@ -51,6 +51,7 @@ export default () => { globalThis.popup_osd = popup; + const brightness = Brightness.get_default(); const speaker = AstalWp.get_default()?.audio.default_speaker; const microphone = AstalWp.get_default()?.audio.default_microphone; @@ -123,29 +124,29 @@ export default () => { css="margin-bottom: 80px;" setup={(self) => { - self.hook(Brightness, 'notify::screen-icon', () => { + self.hook(brightness, 'notify::screen-icon', () => { popup('brightness'); }); }} > - + { - Brightness.hasKbd && ( + brightness.hasKbd && ( { - self.hook(Brightness, 'notify::kbd-level', () => { + self.hook(brightness, 'notify::kbd-level', () => { popup('keyboard'); }); }} @@ -154,8 +155,8 @@ export default () => { (v ?? 0) / 2)} - sensitive={bind(Brightness, 'kbdLevel').as((v) => v !== 0)} + fraction={bind(brightness, 'kbdLevel').as((v) => (v ?? 0) / 2)} + sensitive={bind(brightness, 'kbdLevel').as((v) => v !== 0)} valign={Gtk.Align.CENTER} /> @@ -168,13 +169,13 @@ export default () => { css="margin-bottom: 80px;" setup={(self) => { - self.hook(Brightness, 'notify::caps-icon', () => { + self.hook(brightness, 'notify::caps-icon', () => { popup('caps'); }); }} > - + diff --git a/nixosModules/ags/config/widgets/screenshot/main.tsx b/nixosModules/ags/config/widgets/screenshot/main.tsx index 13192b7a..ffd42c81 100644 --- a/nixosModules/ags/config/widgets/screenshot/main.tsx +++ b/nixosModules/ags/config/widgets/screenshot/main.tsx @@ -2,10 +2,7 @@ import { bind, execAsync, Variable } from 'astal'; import { App, Gtk, Widget } from 'astal/gtk3'; import AstalApps from 'gi://AstalApps'; -const Applications = AstalApps.Apps.new(); - import AstalHyprland from 'gi://AstalHyprland'; -const Hyprland = AstalHyprland.get_default(); import PopupWindow from '../misc/popup-window'; import Separator from '../misc/separator'; @@ -25,6 +22,8 @@ const takeScreenshot = (selector: string[], delay = 1000): void => { }; export default () => { + const hyprland = AstalHyprland.get_default(); + const windowList = as Widget.Box; const updateWindows = async() => { @@ -32,8 +31,10 @@ export default () => { return; } + const applications = AstalApps.Apps.new(); + windowList.children = (JSON.parse(await hyprMessage('j/clients')) as AstalHyprland.Client[]) - .filter((client) => client.workspace.id === Hyprland.get_focused_workspace().get_id()) + .filter((client) => client.workspace.id === hyprland.get_focused_workspace().get_id()) .map((client) => (