Fixes the window title label option (#272)

* fix window title label option not being respected

* add window title icon and label side effects

* add new line to SideEffects.ts

* fix window title children type
This commit is contained in:
painerp
2024-09-21 08:44:54 +02:00
committed by GitHub
parent f27e742be6
commit afb245f8d6
2 changed files with 22 additions and 12 deletions

View File

@@ -13,3 +13,17 @@ showTime.connect('changed', () => {
showIcon.value = true; showIcon.value = true;
} }
}); });
const { label, icon } = options.bar.windowtitle;
label.connect('changed', () => {
if (!label.value && !icon.value) {
icon.value = true;
}
});
icon.connect('changed', () => {
if (!label.value && !icon.value) {
label.value = true;
}
});

View File

@@ -1,7 +1,9 @@
const hyprland = await Service.import('hyprland'); const hyprland = await Service.import('hyprland');
import { BarBoxChild } from 'lib/types/bar'; import { BarBoxChild } from 'lib/types/bar';
import options from 'options'; import options from 'options';
import { Child } from 'lib/types/widget';
import { ActiveClient } from 'types/service/hyprland'; import { ActiveClient } from 'types/service/hyprland';
import Label from 'types/widgets/label';
const filterTitle = (windowtitle: ActiveClient): Record<string, string> => { const filterTitle = (windowtitle: ActiveClient): Record<string, string> => {
const windowTitleMap = [ const windowTitleMap = [
@@ -177,24 +179,18 @@ const ClientTitle = (): BarBoxChild => {
truncation_size.bind('value'), truncation_size.bind('value'),
], ],
(client, useCustomTitle, useClassName, showLabel, showIcon, truncate, truncationSize) => { (client, useCustomTitle, useClassName, showLabel, showIcon, truncate, truncationSize) => {
const children: Label<Child>[] = [];
if (showIcon) { if (showIcon) {
return [ children.push(
Widget.Label({ Widget.Label({
class_name: 'bar-button-icon windowtitle txt-icon bar', class_name: 'bar-button-icon windowtitle txt-icon bar',
label: filterTitle(client).icon, label: filterTitle(client).icon,
}), }),
Widget.Label({ );
class_name: `bar-button-label windowtitle ${showIcon ? '' : 'no-icon'}`,
label: truncateTitle(
getTitle(client, useCustomTitle, useClassName),
truncate ? truncationSize : -1,
),
}),
];
} }
if (showLabel) { if (showLabel) {
return [ children.push(
Widget.Label({ Widget.Label({
class_name: `bar-button-label windowtitle ${showIcon ? '' : 'no-icon'}`, class_name: `bar-button-label windowtitle ${showIcon ? '' : 'no-icon'}`,
label: truncateTitle( label: truncateTitle(
@@ -202,10 +198,10 @@ const ClientTitle = (): BarBoxChild => {
truncate ? truncationSize : -1, truncate ? truncationSize : -1,
), ),
}), }),
]; );
} }
return []; return children;
}, },
), ),
}), }),