import { bind, exec, readFile } from 'astal'; import AstalHyprland from 'gi://AstalHyprland'; import { Gtk } from 'astal/gtk4'; import Pango from 'gi://Pango?version=1.0'; const hypr = AstalHyprland.get_default(); const Workspace = () => { return ( {bind( hypr, 'workspaces' ).as( wss => wss .filter( ws => !( ws.id >= -99 && ws.id <= -2 ) ) // filter out special workspaces .sort( ( a, b ) => a.id - b.id ) .map( ws => ( ) ), )} ); }; /** * Displays the name of the currently active window and provides a popover for * displaying all available clients */ const ActiveWindow = () => { const focused = bind( hypr, 'focusedClient' ); const WindowPopover = (): Gtk.Popover => { // Set up boxes + Popover const popover = new Gtk.Popover(); const popoverBox = WindowPopoverBox(); popover.set_child( popoverBox ); return popover; }; const windowPopover = WindowPopover(); // ─────────────────────────────────────────────────────────────────── // Return fully assembled HyprlandFocusedClient box // ─────────────────────────────────────────────────────────────────── return ( {windowPopover} ); }; type submaps = 'device' | 'launch' | 'workspace' | 'windowing' | 'screenshotting' | 'notifications' | ''; const ModeStatus = () => { let isUsingHyprvim = false; try { const path = exec( 'bash -c "cd ~ && pwd"' ) + '/.config/hyprvim'; isUsingHyprvim = readFile( path ).trim() === 'y'; } catch ( e ) { printerr( 'Failed to read hyprvim config', e ); } const label = new Gtk.Label(); if ( !isUsingHyprvim ) return label; print( '==> Using hyprvim config' ); const map = { 'device': 'DEV', 'launch': 'LNC', 'workspace': 'WSP', 'windowing': 'WIN', 'screenshotting': 'SCS', 'notifications': 'NOT', '': 'NRM' }; label.label = map['']; label.cssClasses = [ 'mode-status' ]; // TODO: Possibly add popover to it that lists binds hypr.connect( 'submap', ( _, name: submaps ) => { label.label = map[name]; label.cssClasses = [ 'mode-status', name + '-mode' ]; } ); return label; }; const WindowPopoverBox = () => { return {bind( hypr, 'clients' ).as( clients => { return clients.map( client => { return ; } ); } )} ; }; export default { Workspace, ActiveWindow, ModeStatus };