diff --git a/config/astal/components/bar/Bar.tsx b/config/astal/components/bar/Bar.tsx index e44fce8..7ce9882 100644 --- a/config/astal/components/bar/Bar.tsx +++ b/config/astal/components/bar/Bar.tsx @@ -1,19 +1,30 @@ -import { App, Astal, Gdk, Gtk } from "astal/gtk4"; -import Hyprland from "./modules/Hyprland"; -import Calendar from "./modules/Calendar"; -import QuickView from "./modules/QuickView"; -import SystemInfo from "./modules/SystemInfo"; -import { CenterBox } from "astal/gtk4/widget"; +import { + App, Astal, Gdk, Gtk +} from 'astal/gtk4'; +import Calendar from './modules/Calendar'; +import { + CenterBox +} from 'astal/gtk4/widget'; +import Hyprland from './modules/Hyprland'; +import QuickView from './modules/QuickView'; +import SystemInfo from './modules/SystemInfo'; -const Bar = ( { gdkmonitor, name }: { gdkmonitor: Gdk.Monitor, name: string } ) => { - const { TOP, LEFT, RIGHT } = Astal.WindowAnchor; +const Bar = ( { + gdkmonitor, name +}: { + 'gdkmonitor': Gdk.Monitor, + 'name': string +} ) => { + const { + TOP, LEFT, RIGHT + } = Astal.WindowAnchor; return ( + @@ -36,7 +48,7 @@ const Bar = ( { gdkmonitor, name }: { gdkmonitor: Gdk.Monitor, name: string } ) @@ -48,21 +60,24 @@ const Bar = ( { gdkmonitor, name }: { gdkmonitor: Gdk.Monitor, name: string } ) ); }; -const cliHandler = (args: string[]): string => { - return "Not implemented"; +const cliHandler = ( args: string[] ): string => { + console.debug( args ); + + return 'Not implemented'; }; -const BarLauncher = ( monitor: Gdk.Monitor ) => { - const windowName = `bar-${monitor.get_connector()}` +const BarLauncher = ( monitor: Gdk.Monitor ) => { + const windowName = `bar-${ monitor.get_connector() }`; + const createBar = () => { - return - } + return ; + }; // Actually start the bar createBar(); return windowName; -} +}; export default { BarLauncher, diff --git a/config/astal/components/bar/bar.scss b/config/astal/components/bar/bar.scss index 9454e98..e293673 100644 --- a/config/astal/components/bar/bar.scss +++ b/config/astal/components/bar/bar.scss @@ -12,6 +12,14 @@ window.Bar { /* margin: 8px; */ /* } */ .mode-status { + color: white; + background-color: #00002dff; + padding-left: 10px; + padding-right: 10px; + margin-left: 5px; + border-radius: 20px; + font-family: $monospace-font; + &.windowing-mode { background-color: darkslategray; color: white; @@ -31,7 +39,7 @@ window.Bar { background-color: darkred; color: white; } - + &.screenshotting-mode { background-color: purple; color: white; @@ -85,12 +93,13 @@ window.Bar { .time { min-width: 11rem; padding: 3px; + & button { box-shadow: none; padding: 0; } } - + .quick-view-symbol { margin: 4px; } diff --git a/config/astal/components/bar/modules/Hyprland.tsx b/config/astal/components/bar/modules/Hyprland.tsx index 11c357c..e360543 100644 --- a/config/astal/components/bar/modules/Hyprland.tsx +++ b/config/astal/components/bar/modules/Hyprland.tsx @@ -1,50 +1,59 @@ -import AstalTray from "gi://AstalTray"; -import { bind, GObject } from "astal"; -import AstalHyprland from "gi://AstalHyprland"; -import { Gtk } from "astal/gtk4"; -import Pango from "gi://Pango?version=1.0"; +import { + GObject, bind, + exec, + readFile +} from 'astal'; +import AstalHyprland from 'gi://AstalHyprland'; +import AstalTray from 'gi://AstalTray'; +import { + Gtk +} from 'astal/gtk4'; +import Pango from 'gi://Pango?version=1.0'; const hypr = AstalHyprland.get_default(); const SYNC = GObject.BindingFlags.SYNC_CREATE; const SysTray = () => { - const trayBox = new Gtk.Box({ cssClasses: ["bar-button"] }); + const trayBox = new Gtk.Box( { + 'cssClasses': [ 'bar-button' ] + } ); const tray = AstalTray.get_default(); - const trayItems = new Map(); - const trayAddedHandler = tray.connect("item-added", (_, id) => { - const item = tray.get_item(id); - const popover = Gtk.PopoverMenu.new_from_model(item.menu_model); + const trayAddedHandler = tray.connect( 'item-added', ( _, id ) => { + const item = tray.get_item( id ); + const popover = Gtk.PopoverMenu.new_from_model( item.menu_model ); const icon = new Gtk.Image(); - const button = new Gtk.MenuButton({ + const button = new Gtk.MenuButton( { popover, - child: icon, - cssClasses: ["tray-item"], - }); + 'child': icon, + 'cssClasses': [ 'tray-item' ], + } ); - item.bind_property("gicon", icon, "gicon", SYNC); - popover.insert_action_group("dbusmenu", item.action_group); - item.connect("notify::action-group", () => { - popover.insert_action_group("dbusmenu", item.action_group); - }); + item.bind_property( + 'gicon', icon, 'gicon', SYNC + ); + popover.insert_action_group( 'dbusmenu', item.action_group ); + item.connect( 'notify::action-group', () => { + popover.insert_action_group( 'dbusmenu', item.action_group ); + } ); - trayItems.set(id, button); - trayBox.append(button); - }); + trayItems.set( id, button ); + trayBox.append( button ); + } ); + const trayRemovedHandler = tray.connect( 'item-removed', ( _, id ) => { + const button = trayItems.get( id ); - const trayRemovedHandler = tray.connect("item-removed", (_, id) => { - const button = trayItems.get(id); - if (button) { - trayBox.remove(button); + if ( button ) { + trayBox.remove( button ); button.run_dispose(); - trayItems.delete(id); + trayItems.delete( id ); } - }); + } ); - trayBox.connect("destroy", () => { - tray.disconnect(trayAddedHandler); - tray.disconnect(trayRemovedHandler); - }); + trayBox.connect( 'destroy', () => { + tray.disconnect( trayAddedHandler ); + tray.disconnect( trayRemovedHandler ); + } ); return trayBox; }; @@ -52,25 +61,21 @@ const SysTray = () => { 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 => ( - - )), - )} + {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 => ( + + ) ), )} ); }; @@ -80,15 +85,15 @@ const Workspace = () => { * displaying all available clients */ const ActiveWindow = () => { - const focused = bind(hypr, "focusedClient"); + 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); + popover.set_child( popoverBox ); + return popover; }; @@ -98,65 +103,88 @@ const ActiveWindow = () => { // Return fully assembled HyprlandFocusedClient box // ─────────────────────────────────────────────────────────────────── return ( - + {windowPopover} ); }; +type submaps = 'device' | 'launch' | 'workspace' | 'windowing' | 'screenshotting' | 'notifications' | ''; + const ModeStatus = () => { - const label = new Gtk.Label(); - const map = { - "device": "D", - "launch": "L", - "workspace": "W", - "windowing": "M", - "screenshotting": "S", - "notifications": "N", + let isUsingHyprmode = false; + + try { + const path = exec( 'bash -c "cd ~ && pwd"' ) + '/.config/hyprmode'; + + isUsingHyprmode = readFile( path ).trim() === 'y'; + } catch ( e ) { + printerr( 'Failed to read hyprmode config', e ); } + + const label = new Gtk.Label(); + + if ( !isUsingHyprmode ) return label; + + print( '==> Using hyprmode config' ); + + const map = { + 'device': 'D', + 'launch': 'L', + 'workspace': 'W', + 'windowing': 'M', + 'screenshotting': 'S', + 'notifications': 'N', + '': 'N' + }; + + label.label = 'N'; + label.cssClasses = [ 'mode-status' ]; + // TODO: Possibly add popover to it that lists binds - hypr.connect("submap", (name: string) => { + hypr.connect( 'submap', ( _, name: submaps ) => { label.label = map[name]; - label.cssClasses = ["mode-status", name + '-mode'] - }) - return -} + label.cssClasses = [ + 'mode-status', + name + '-mode' + ]; + } ); + + return label; +}; const WindowPopoverBox = () => { return - + - {bind(hypr, 'clients').as(clients => { - return clients.map(client => { + {bind( hypr, 'clients' ).as( clients => { + return clients.map( client => { return - }) - })} + onClicked={() => client.focus()} + >; + } ); + } )} - -} + ; +}; export default { Workspace, diff --git a/config/astal/components/bar/modules/QuickView.tsx b/config/astal/components/bar/modules/QuickView.tsx index f3f7243..c38af83 100644 --- a/config/astal/components/bar/modules/QuickView.tsx +++ b/config/astal/components/bar/modules/QuickView.tsx @@ -1,17 +1,24 @@ -import { bind } from "astal"; -import { execAsync } from "astal"; -import AstalBattery from "gi://AstalBattery"; -import AstalBluetooth from "gi://AstalBluetooth"; -import AstalNetwork from "gi://AstalNetwork"; -import AstalWp from "gi://AstalWp"; -import { Gtk } from "astal/gtk4"; -import Brightness from "../../../util/brightness"; -import QuickActions from "../../QuickActions/QuickActions"; +import AstalBattery from 'gi://AstalBattery'; +import AstalBluetooth from 'gi://AstalBluetooth'; +import AstalNetwork from 'gi://AstalNetwork'; +import AstalWp from 'gi://AstalWp'; +import Brightness from '../../../util/brightness'; +import { + Gtk +} from 'astal/gtk4'; +import QuickActions from '../../QuickActions/QuickActions'; +import { + bind +} from 'astal'; +import { + execAsync +} from 'astal'; const STATE = AstalNetwork.DeviceState; const QuickView = () => { const qa = QuickActions.QuickActions(); + const showQuickActions = () => { qa.popup(); }; @@ -19,14 +26,14 @@ const QuickView = () => { return ( ); @@ -38,7 +42,7 @@ Kernel: ${stats.kernel}`; const SystemInformationPanel = () => { const popover = new Gtk.Popover(); - popover.set_child(info()); + popover.set_child( info() ); return popover; }; @@ -54,44 +58,44 @@ const SystemInfo = () => { sysinfo.refreshStats(); }; - if (sysinfo.enabled) { + if ( sysinfo.enabled ) { return ( ); } else { - return ; + return ; } }; diff --git a/config/astal/util/colours.scss b/config/astal/util/colours.scss index cc9bbd5..7562119 100644 --- a/config/astal/util/colours.scss +++ b/config/astal/util/colours.scss @@ -3,3 +3,4 @@ $bg-color: #0A0A0F; $accent-color: #591641; $accent-color-2: #97103A; $shadow-color: rgba(0, 0, 2, 0.3); +$monospace-font: Source Code Pro