Window client title now updates appropriately. (#741)

* Window client title now updates appropriately.

* Update src/components/bar/modules/window_title/helpers/title.ts
This commit is contained in:
Jas Singh
2025-01-25 00:24:15 -08:00
committed by GitHub
parent 562eb64e12
commit 74065af3d2
2 changed files with 24 additions and 1 deletions

View File

@@ -1,6 +1,28 @@
import options from 'src/options'; import options from 'src/options';
import { capitalizeFirstLetter } from 'src/lib/utils'; import { capitalizeFirstLetter } from 'src/lib/utils';
import AstalHyprland from 'gi://AstalHyprland?version=0.1'; import AstalHyprland from 'gi://AstalHyprland?version=0.1';
import { hyprlandService } from 'src/lib/constants/services';
import { bind, Variable } from 'astal';
export const clientTitle = Variable('');
let clientBinding: Variable<void> | undefined;
function trackClientUpdates(client: AstalHyprland.Client): void {
clientBinding?.drop();
clientBinding = undefined;
if (!client) {
return;
}
clientBinding = Variable.derive([bind(client, 'title')], (currentTitle) => {
clientTitle.set(currentTitle);
});
}
Variable.derive([bind(hyprlandService, 'focusedClient')], (client) => {
trackClientUpdates(client);
});
/** /**
* Retrieves the matching window title details for a given window. * Retrieves the matching window title details for a given window.

View File

@@ -5,7 +5,7 @@ import { hyprlandService } from 'src/lib/constants/services';
import AstalHyprland from 'gi://AstalHyprland?version=0.1'; import AstalHyprland from 'gi://AstalHyprland?version=0.1';
import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers'; import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers';
import { bind, Variable } from 'astal'; import { bind, Variable } from 'astal';
import { getTitle, getWindowMatch, truncateTitle } from './helpers/title'; import { clientTitle, getTitle, getWindowMatch, truncateTitle } from './helpers/title';
import { Astal } from 'astal/gtk3'; import { Astal } from 'astal/gtk3';
const { leftClick, rightClick, middleClick, scrollDown, scrollUp } = options.bar.windowtitle; const { leftClick, rightClick, middleClick, scrollDown, scrollUp } = options.bar.windowtitle;
@@ -55,6 +55,7 @@ const ClientTitle = (): BarBoxChild => {
bind(icon), bind(icon),
bind(truncation), bind(truncation),
bind(truncation_size), bind(truncation_size),
bind(clientTitle),
], ],
( (
client: AstalHyprland.Client, client: AstalHyprland.Client,