fix(ags): update current-client and fix network hover
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
386a4cfde4
commit
a1df7028f1
3 changed files with 35 additions and 46 deletions
|
@ -16,16 +16,17 @@ export default () => {
|
|||
const focusedIcon = Variable<string>('');
|
||||
const focusedTitle = Variable<string>('');
|
||||
|
||||
let lastFocusedAddress: string | null;
|
||||
// FIXME: readd this once client titles are fixed
|
||||
// let lastFocusedAddress: string | null;
|
||||
|
||||
|
||||
const updateVars = (
|
||||
client: AstalHyprland.Client | null = hyprland.get_focused_client(),
|
||||
) => {
|
||||
lastFocusedAddress = client ? client.get_address() : null;
|
||||
// lastFocusedAddress = client ? client.address : null;
|
||||
|
||||
const app = applications.fuzzy_query(
|
||||
client?.get_class() ?? '',
|
||||
client?.class ?? '',
|
||||
)[0];
|
||||
|
||||
const icon = app?.iconName;
|
||||
|
@ -38,21 +39,21 @@ export default () => {
|
|||
visibleIcon.set(false);
|
||||
}
|
||||
|
||||
focusedTitle.set(client?.get_title() ?? '');
|
||||
const id = client?.connect('notify::title', (c) => {
|
||||
focusedTitle.set(client?.title ?? '');
|
||||
/* const id = client?.connect('notify::title', (c) => {
|
||||
if (c.get_address() !== lastFocusedAddress) {
|
||||
c.disconnect(id);
|
||||
}
|
||||
console.log(c.get_title());
|
||||
focusedTitle.set(c.get_title());
|
||||
});
|
||||
});*/
|
||||
};
|
||||
|
||||
updateVars();
|
||||
hyprland.connect('notify::focused-client', () => updateVars());
|
||||
hyprland.connect('client-removed', () => updateVars());
|
||||
hyprland.connect('client-added', async() => {
|
||||
// hyprland.connect('notify::focused-client', () => updateVars());
|
||||
hyprland.connect('event', async() => {
|
||||
try {
|
||||
updateVars(hyprland.get_client(JSON.parse(await hyprMessage('j/activewindow')).address));
|
||||
updateVars(JSON.parse(await hyprMessage('j/activewindow')));
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
|
@ -85,6 +86,7 @@ export default () => {
|
|||
<label
|
||||
label={bind(focusedTitle)}
|
||||
truncate
|
||||
maxWidthChars={45}
|
||||
/>
|
||||
</box>
|
||||
</box>
|
||||
|
|
|
@ -5,6 +5,7 @@ import AstalApps from 'gi://AstalApps';
|
|||
import AstalHyprland from 'gi://AstalHyprland';
|
||||
|
||||
import Separator from '../../misc/separator';
|
||||
|
||||
import { hyprMessage } from '../../../lib';
|
||||
|
||||
|
||||
|
@ -15,16 +16,18 @@ export default () => {
|
|||
const visibleIcon = Variable<boolean>(false);
|
||||
const focusedIcon = Variable<string>('');
|
||||
|
||||
let lastFocusedAddress: string | null;
|
||||
// FIXME: readd this once client titles are fixed
|
||||
// let lastFocusedAddress: string | null;
|
||||
|
||||
|
||||
const updateVars = (
|
||||
client: AstalHyprland.Client | null = hyprland.get_focused_client(),
|
||||
) => {
|
||||
lastFocusedAddress = client ? client.get_address() : null;
|
||||
// lastFocusedAddress = client ? client.address : null;
|
||||
|
||||
const app = client ?
|
||||
applications.fuzzy_query(client.get_class())[0] :
|
||||
null;
|
||||
const app = applications.fuzzy_query(
|
||||
client?.class ?? '',
|
||||
)[0];
|
||||
|
||||
const icon = app?.iconName;
|
||||
|
||||
|
@ -35,20 +38,13 @@ export default () => {
|
|||
else {
|
||||
visibleIcon.set(false);
|
||||
}
|
||||
|
||||
const id = client?.connect('notify::title', (c) => {
|
||||
if (c.get_address() !== lastFocusedAddress) {
|
||||
c.disconnect(id);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
updateVars();
|
||||
hyprland.connect('notify::focused-client', () => updateVars());
|
||||
hyprland.connect('client-removed', () => updateVars());
|
||||
hyprland.connect('client-added', async() => {
|
||||
// hyprland.connect('notify::focused-client', () => updateVars());
|
||||
hyprland.connect('event', async() => {
|
||||
try {
|
||||
updateVars(hyprland.get_client(JSON.parse(await hyprMessage('j/activewindow')).address));
|
||||
updateVars(JSON.parse(await hyprMessage('j/activewindow')));
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
|
|
|
@ -14,8 +14,8 @@ export default () => {
|
|||
className="bar-item network"
|
||||
cursor="pointer"
|
||||
|
||||
onEnterNotifyEvent={() => Hovered.set(true)}
|
||||
onLeaveNotifyEvent={() => Hovered.set(false)}
|
||||
onHover={() => Hovered.set(true)}
|
||||
onHoverLost={() => Hovered.set(false)}
|
||||
>
|
||||
{bind(network, 'primary').as((primary) => {
|
||||
if (primary === AstalNetwork.Primary.UNKNOWN) {
|
||||
|
@ -24,29 +24,20 @@ export default () => {
|
|||
else if (primary === AstalNetwork.Primary.WIFI) {
|
||||
const Wifi = network.get_wifi();
|
||||
|
||||
if (!Wifi) { return; }
|
||||
if (!Wifi || Wifi.accessPoints.length === 0) { return; }
|
||||
|
||||
return (
|
||||
<box>
|
||||
{/* Make sure the AP is there before binding to it */}
|
||||
{bind(Wifi, 'accessPoints').as((aps) => {
|
||||
if (aps.length === 0) { return; }
|
||||
<icon icon={bind(Wifi, 'iconName')} />
|
||||
|
||||
return (
|
||||
<>
|
||||
<icon icon={bind(Wifi, 'iconName')} />
|
||||
|
||||
<revealer
|
||||
revealChild={bind(Hovered)}
|
||||
transitionType={Gtk.RevealerTransitionType.SLIDE_LEFT}
|
||||
>
|
||||
{bind(Wifi, 'activeAccessPoint').as((ap) => ap && (
|
||||
<label label={bind(ap, 'ssid')} />
|
||||
))}
|
||||
</revealer>
|
||||
</>
|
||||
);
|
||||
})}
|
||||
<revealer
|
||||
revealChild={bind(Hovered)}
|
||||
transitionType={Gtk.RevealerTransitionType.SLIDE_LEFT}
|
||||
>
|
||||
{bind(Wifi, 'activeAccessPoint').as((ap) => ap && (
|
||||
<label label={bind(ap, 'ssid')} />
|
||||
))}
|
||||
</revealer>
|
||||
</box>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue