Upgrade to Agsv2 + Astal (#533)
* migrate to astal * Reorganize project structure. * progress * Migrate Dashboard and Window Title modules. * Migrate clock and notification bar modules. * Remove unused code * Media menu * Rework network and volume modules * Finish custom modules. * Migrate battery bar module. * Update battery module and organize helpers. * Migrate workspace module. * Wrap up bar modules. * Checkpoint before I inevitbly blow something up. * Updates * Fix event propagation logic. * Type fixes * More type fixes * Fix padding for event boxes. * Migrate volume menu and refactor scroll event handlers. * network module WIP * Migrate network service. * Migrate bluetooth menu * Updates * Migrate notifications * Update scrolling behavior for custom modules. * Improve popup notifications and add timer functionality. * Migration notifications menu header/controls. * Migrate notifications menu and consolidate notifications menu code. * Migrate power menu. * Dashboard progress * Migrate dashboard * Migrate media menu. * Reduce media menu nesting. * Finish updating media menu bindings to navigate active player. * Migrate battery menu * Consolidate code * Migrate calendar menu * Fix workspace logic to update on client add/change/remove and consolidate code. * Migrate osd * Consolidate hyprland service connections. * Implement startup dropdown menu position allocation. * Migrate settings menu (WIP) * Settings dialo menu fixes * Finish Dashboard menu * Type updates * update submoldule for types * update github ci * ci * Submodule update * Ci updates * Remove type checking for now. * ci fix * Fix a bunch of stuff, losing track... need rest. Brb coffee * Validate dropdown menu before render. * Consolidate code and add auto-hide functionality. * Improve auto-hide behavior. * Consolidate audio menu code * Organize bluetooth code * Improve active player logic * Properly dismiss a notification on action button resolution. * Implement CLI command engine and migrate CLI commands. * Handle variable disposal * Bar component fixes and add hyprland startup rules. * Handle potentially null bindings network and bluetooth bindings. * Handle potentially null wired adapter. * Fix GPU stats * Handle poller for GPU * Fix gpu bar logic. * Clean up logic for stat bars. * Handle wifi and wired bar icon bindings. * Fix battery percentages * Fix switch behavior * Wifi staging fixes * Reduce redundant hyprland service calls. * Code cleanup * Document the option code and reduce redundant calls to optimize performance. * Remove outdated comment. * Add JSDocs * Add meson to build hyprpanel * Consistency updates * Organize commands * Fix images not showing up on notifications. * Remove todo * Move hyprpanel configuration to the ~/.config/hyprpanel directory and add utility commands. * Handle SRC directory for the bundled/built hyprpanel. * Add namespaces to all windows * Migrate systray * systray updates * Update meson to include ts, tsx and scss files. * Remove log from meson * Fix file choose path and make it float. * Added a command to check the dependency status * Update dep names. * Get scale directly from env * Add todo
This commit is contained in:
169
src/components/bar/index.tsx
Normal file
169
src/components/bar/index.tsx
Normal file
@@ -0,0 +1,169 @@
|
||||
import {
|
||||
Menu,
|
||||
Workspaces,
|
||||
ClientTitle,
|
||||
Media,
|
||||
Notifications,
|
||||
Volume,
|
||||
Network,
|
||||
Bluetooth,
|
||||
BatteryLabel,
|
||||
Clock,
|
||||
SysTray,
|
||||
|
||||
// Custom Modules
|
||||
Ram,
|
||||
Cpu,
|
||||
CpuTemp,
|
||||
Storage,
|
||||
Netstat,
|
||||
KbInput,
|
||||
Updates,
|
||||
Submap,
|
||||
Weather,
|
||||
Power,
|
||||
Hyprsunset,
|
||||
Hypridle,
|
||||
} from './exports';
|
||||
|
||||
import { WidgetContainer } from './shared/WidgetContainer';
|
||||
import options from 'src/options';
|
||||
import { App, Gtk } from 'astal/gtk3/index';
|
||||
|
||||
import Astal from 'gi://Astal?version=3.0';
|
||||
import { bind, Variable } from 'astal';
|
||||
import { gdkMonitorIdToHyprlandId, getLayoutForMonitor, isLayoutEmpty } from './utils/monitors';
|
||||
|
||||
const { layouts } = options.bar;
|
||||
const { location } = options.theme.bar;
|
||||
const { location: borderLocation } = options.theme.bar.border;
|
||||
|
||||
const widget = {
|
||||
battery: (): JSX.Element => WidgetContainer(BatteryLabel()),
|
||||
dashboard: (): JSX.Element => WidgetContainer(Menu()),
|
||||
workspaces: (monitor: number): JSX.Element => WidgetContainer(Workspaces(monitor)),
|
||||
windowtitle: (): JSX.Element => WidgetContainer(ClientTitle()),
|
||||
media: (): JSX.Element => WidgetContainer(Media()),
|
||||
notifications: (): JSX.Element => WidgetContainer(Notifications()),
|
||||
volume: (): JSX.Element => WidgetContainer(Volume()),
|
||||
network: (): JSX.Element => WidgetContainer(Network()),
|
||||
bluetooth: (): JSX.Element => WidgetContainer(Bluetooth()),
|
||||
clock: (): JSX.Element => WidgetContainer(Clock()),
|
||||
systray: (): JSX.Element => WidgetContainer(SysTray()),
|
||||
ram: (): JSX.Element => WidgetContainer(Ram()),
|
||||
cpu: (): JSX.Element => WidgetContainer(Cpu()),
|
||||
cputemp: (): JSX.Element => WidgetContainer(CpuTemp()),
|
||||
storage: (): JSX.Element => WidgetContainer(Storage()),
|
||||
netstat: (): JSX.Element => WidgetContainer(Netstat()),
|
||||
kbinput: (): JSX.Element => WidgetContainer(KbInput()),
|
||||
updates: (): JSX.Element => WidgetContainer(Updates()),
|
||||
submap: (): JSX.Element => WidgetContainer(Submap()),
|
||||
weather: (): JSX.Element => WidgetContainer(Weather()),
|
||||
power: (): JSX.Element => WidgetContainer(Power()),
|
||||
hyprsunset: (): JSX.Element => WidgetContainer(Hyprsunset()),
|
||||
hypridle: (): JSX.Element => WidgetContainer(Hypridle()),
|
||||
};
|
||||
|
||||
export const Bar = (() => {
|
||||
const usedHyprlandMonitors = new Set<number>();
|
||||
|
||||
return (monitor: number): JSX.Element => {
|
||||
const hyprlandMonitor = gdkMonitorIdToHyprlandId(monitor, usedHyprlandMonitors);
|
||||
|
||||
const computeVisibility = bind(layouts).as(() => {
|
||||
const foundLayout = getLayoutForMonitor(hyprlandMonitor, layouts.get());
|
||||
return !isLayoutEmpty(foundLayout);
|
||||
});
|
||||
|
||||
const computeAnchor = bind(location).as((loc) => {
|
||||
if (loc === 'bottom') {
|
||||
return Astal.WindowAnchor.BOTTOM | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT;
|
||||
}
|
||||
|
||||
return Astal.WindowAnchor.TOP | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT;
|
||||
});
|
||||
|
||||
const computeLayer = Variable.derive([bind(options.theme.bar.layer), bind(options.tear)], (barLayer, tear) => {
|
||||
if (tear && barLayer === 'overlay') {
|
||||
return Astal.Layer.TOP;
|
||||
}
|
||||
const layerMap = {
|
||||
overlay: Astal.Layer.OVERLAY,
|
||||
top: Astal.Layer.TOP,
|
||||
bottom: Astal.Layer.BOTTOM,
|
||||
background: Astal.Layer.BACKGROUND,
|
||||
};
|
||||
|
||||
return layerMap[barLayer];
|
||||
});
|
||||
|
||||
const computeBorderLocation = bind(borderLocation).as((brdrLcn) =>
|
||||
brdrLcn !== 'none' ? 'bar-panel withBorder' : 'bar-panel',
|
||||
);
|
||||
|
||||
const leftBinding = Variable.derive([bind(layouts)], (currentLayouts) => {
|
||||
const foundLayout = getLayoutForMonitor(hyprlandMonitor, currentLayouts);
|
||||
|
||||
return foundLayout.left
|
||||
.filter((mod) => Object.keys(widget).includes(mod))
|
||||
.map((w) => widget[w](hyprlandMonitor));
|
||||
});
|
||||
const middleBinding = Variable.derive([bind(layouts)], (currentLayouts) => {
|
||||
const foundLayout = getLayoutForMonitor(hyprlandMonitor, currentLayouts);
|
||||
|
||||
return foundLayout.middle
|
||||
.filter((mod) => Object.keys(widget).includes(mod))
|
||||
.map((w) => widget[w](hyprlandMonitor));
|
||||
});
|
||||
const rightBinding = Variable.derive([bind(layouts)], (currentLayouts) => {
|
||||
const foundLayout = getLayoutForMonitor(hyprlandMonitor, currentLayouts);
|
||||
|
||||
return foundLayout.right
|
||||
.filter((mod) => Object.keys(widget).includes(mod))
|
||||
.map((w) => widget[w](hyprlandMonitor));
|
||||
});
|
||||
|
||||
return (
|
||||
<window
|
||||
name={`bar-${hyprlandMonitor}`}
|
||||
namespace={`bar-${hyprlandMonitor}`}
|
||||
className={'bar'}
|
||||
application={App}
|
||||
monitor={monitor}
|
||||
visible={computeVisibility}
|
||||
anchor={computeAnchor}
|
||||
layer={computeLayer()}
|
||||
exclusivity={Astal.Exclusivity.EXCLUSIVE}
|
||||
onDestroy={() => {
|
||||
computeLayer.drop();
|
||||
leftBinding.drop();
|
||||
middleBinding.drop();
|
||||
rightBinding.drop();
|
||||
}}
|
||||
>
|
||||
<box className={'bar-panel-container'}>
|
||||
<centerbox
|
||||
css={'padding: 1px;'}
|
||||
hexpand
|
||||
className={computeBorderLocation}
|
||||
startWidget={
|
||||
<box className={'box-left'} hexpand>
|
||||
{leftBinding()}
|
||||
</box>
|
||||
}
|
||||
centerWidget={
|
||||
<box className={'box-center'} halign={Gtk.Align.CENTER}>
|
||||
{middleBinding()}
|
||||
</box>
|
||||
}
|
||||
endWidget={
|
||||
<box className={'box-right'} halign={Gtk.Align.END}>
|
||||
{rightBinding()}
|
||||
</box>
|
||||
}
|
||||
/>
|
||||
</box>
|
||||
</window>
|
||||
);
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user