diff --git a/modules/bar/SideEffects.ts b/modules/bar/SideEffects.ts index 8b055bf..e4aabec 100644 --- a/modules/bar/SideEffects.ts +++ b/modules/bar/SideEffects.ts @@ -13,3 +13,17 @@ showTime.connect('changed', () => { 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; + } +}); diff --git a/modules/bar/window_title/index.ts b/modules/bar/window_title/index.ts index 07856d6..d0f1143 100644 --- a/modules/bar/window_title/index.ts +++ b/modules/bar/window_title/index.ts @@ -1,7 +1,9 @@ const hyprland = await Service.import('hyprland'); import { BarBoxChild } from 'lib/types/bar'; import options from 'options'; +import { Child } from 'lib/types/widget'; import { ActiveClient } from 'types/service/hyprland'; +import Label from 'types/widgets/label'; const filterTitle = (windowtitle: ActiveClient): Record => { const windowTitleMap = [ @@ -177,24 +179,18 @@ const ClientTitle = (): BarBoxChild => { truncation_size.bind('value'), ], (client, useCustomTitle, useClassName, showLabel, showIcon, truncate, truncationSize) => { + const children: Label[] = []; if (showIcon) { - return [ + children.push( Widget.Label({ class_name: 'bar-button-icon windowtitle txt-icon bar', 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) { - return [ + children.push( Widget.Label({ class_name: `bar-button-label windowtitle ${showIcon ? '' : 'no-icon'}`, label: truncateTitle( @@ -202,10 +198,10 @@ const ClientTitle = (): BarBoxChild => { truncate ? truncationSize : -1, ), }), - ]; + ); } - return []; + return children; }, ), }),