diff --git a/ags/widget/bar/Status.ts b/ags/widget/bar/Status.ts index 0ffc88f..ed9ec97 100644 --- a/ags/widget/bar/Status.ts +++ b/ags/widget/bar/Status.ts @@ -2,7 +2,7 @@ import AstalBluetooth from "gi://AstalBluetooth"; import AstalNetwork from "gi://AstalNetwork"; import AstalWp from "gi://AstalWp"; -import { bind, Variable } from "astal"; +import { bind, Binding, Variable } from "astal"; import { Gtk, Widget } from "astal/gtk3"; import { Wireplumber } from "../../scripts/volume"; import { Notifications } from "../../scripts/notifications"; @@ -22,12 +22,14 @@ export function Status(): Gtk.Widget { volumeStatus({ className: "sink", endpoint: Wireplumber.getDefault().getDefaultSink(), - icon: "󰕾" + icon: bind(Wireplumber.getDefault().getDefaultSink(), "mute").as((muted) => + !muted ? "󰕾" : "󰖁") }), volumeStatus({ className: "source", endpoint: Wireplumber.getDefault().getDefaultSource(), - icon: "󰍬" + icon: bind(Wireplumber.getDefault().getDefaultSource(), "mute").as((muted) => + !muted ? "󰍬" : "󰍭") }), StatusIcons() ] @@ -35,7 +37,7 @@ export function Status(): Gtk.Widget { } as Widget.EventBoxProps); } -function volumeStatus(props: { className?: string, endpoint: AstalWp.Endpoint, icon: string }): Gtk.Widget { +function volumeStatus(props: { className?: string, endpoint: AstalWp.Endpoint, icon?: (string|Binding) }): Gtk.Widget { return new Widget.EventBox({ className: props.className, onScroll: (_, event) => @@ -47,6 +49,7 @@ function volumeStatus(props: { className?: string, endpoint: AstalWp.Endpoint, i children: [ new Widget.Label({ className: "nf", + visible: props.icon, label: props.icon, } as Widget.LabelProps), new Widget.Label({ @@ -113,6 +116,7 @@ function StatusIcons(): Gtk.Widget { children: [ new Widget.Label({ className: "bluetooth nf state", + visible: bind(AstalBluetooth.get_default(), "adapter").as(Boolean), label: bluetoothIcon(), onDestroy: () => bluetoothIcon.drop() } as Widget.LabelProps), diff --git a/ags/widget/control-center/Tiles.ts b/ags/widget/control-center/Tiles.ts index 364db79..5630a2a 100644 --- a/ags/widget/control-center/Tiles.ts +++ b/ags/widget/control-center/Tiles.ts @@ -5,6 +5,7 @@ import { TileDND } from "./tiles/DoNotDisturb"; import { TileRecording } from "./tiles/Recording"; import { TileNightLight } from "./tiles/NightLight"; import { Pages } from "./Pages"; +import { GObject } from "astal"; export const tileList: Array<() => Gtk.Widget> = [ TileNetwork, @@ -29,10 +30,19 @@ export function Tiles(): Gtk.Widget { } as Gtk.FlowBox.ConstructorProps); tileList.map((item: (() => Gtk.Widget)) => { - tilesFlowBox.insert(item(), -1); + const tile = item(); + tilesFlowBox.insert(tile, -1); const children = tilesFlowBox.get_children(); children[children.length-1]!.set_can_focus(false); + const binding: GObject.Binding = tile.bind_property("visible", + children[children.length-1], "visible", + GObject.BindingFlags.SYNC_CREATE); + + const destroyId: number = tile.connect("destroy-event", (self: typeof tile) => { + binding.unbind(); + self.disconnect(destroyId); + }); }); return new Widget.Box({ diff --git a/ags/widget/control-center/tiles/Bluetooth.ts b/ags/widget/control-center/tiles/Bluetooth.ts index d199667..860fbaa 100644 --- a/ags/widget/control-center/tiles/Bluetooth.ts +++ b/ags/widget/control-center/tiles/Bluetooth.ts @@ -7,6 +7,7 @@ import { TilesPages } from "../Tiles"; export const TileBluetooth = Tile({ title: "Bluetooth", + visible: bind(AstalBluetooth.get_default(), "adapter").as(Boolean), description: bind(AstalBluetooth.get_default(), "isConnected").as((connected) => { const connectedDev = AstalBluetooth.get_default().devices.filter(dev => dev.connected)?.[0]; return connected && connectedDev ? connectedDev.get_alias() : ""