import { bind, execAsync, Variable } from 'astal'; import { App, Gtk, Widget } from 'astal/gtk3'; import AstalApps from 'gi://AstalApps'; import AstalHyprland from 'gi://AstalHyprland'; import PopupWindow from '../misc/popup-window'; import Separator from '../misc/separator'; import { hyprMessage } from '../../lib'; const ICON_SEP = 6; const takeScreenshot = (selector: string[], delay = 1000): void => { App.get_window('win-screenshot')?.set_visible(false); setTimeout(() => { execAsync([ `${SRC}/widgets/screenshot/capture.sh`, ].concat(selector)).catch(console.error); }, delay); }; export default () => { const hyprland = AstalHyprland.get_default(); const windowList = as Widget.Box; const updateWindows = async() => { if (!App.get_window('win-screenshot')?.visible) { 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()) .map((client) => ( )); }; hyprland.connect('notify::clients', updateWindows); hyprland.connect('notify::focused-workspace', updateWindows); const Shown = Variable('monitors'); const stack = ( {bind(hyprland, 'monitors').as((monitors) => monitors.map((monitor) => ( )))} {windowList} ) as Widget.Stack; const StackButton = ({ label = '', iconName = '' }) => ( ) as Widget.Button; let frozen = false; const freezeIcon = as Widget.Icon; const freezeButton = ( ) as Widget.Button; const regionButton = ( ) as Widget.Button; return ( { updateWindows(); }} > {regionButton} {freezeButton} {stack} ); };