[AGS] Bar: Improve QuickActions

This commit is contained in:
2025-04-22 17:38:41 +02:00
parent 8a2180e120
commit 69484fc302
12 changed files with 390 additions and 75 deletions

View File

@@ -1,31 +1,25 @@
import { Astal, App } from "astal/gtk4";
import PowerProfiles from "gi://AstalPowerProfiles";
import { Variable } from "astal";
import { Sliders } from "./modules/Sliders";
import { Toggles } from "./modules/Toggles";
import { PowerProfileBox } from "./modules/PowerProfileBox";
import { BatteryBox } from "./modules/BatteryBox";
import { Gtk } from "astal/gtk4"
import Network from "./modules/Networking/Network";
import Power from "./modules/Power";
export default function QuickActions() {
const powerprofiles = PowerProfiles.get_default();
const hasProfiles = powerprofiles?.get_profiles()?.length > 0;
const { TOP, RIGHT } = Astal.WindowAnchor;
const visible = Variable(false);
return (
<window
name="system-menu"
application={App}
layer={Astal.Layer.OVERLAY}
anchor={TOP | RIGHT}
keymode={Astal.Keymode.ON_DEMAND}
visible={visible()}
>
<box cssClasses={["system-menu"]} vertical>
<Toggles />
{hasProfiles && <PowerProfileBox />}
<Sliders />
<BatteryBox />
</box>
</window>
);
const QuickActions = () => {
const popover = new Gtk.Popover( { cssClasses: [ 'quick-actions-popover' ] } );
popover.set_child( createQuickActionMenu() );
return popover;
}
const createQuickActionMenu = () => {
return <box visible cssClasses={[ 'quick-actions' ]}>
<Power></Power>
<Network></Network>
</box>
}
// TODO: Expose additional functions to be usable through CLI
export default {
QuickActions
};