From afb245f8d69f329d3cda60ce5a5a2c5e7966520e Mon Sep 17 00:00:00 2001 From: painerp <8081128+painerp@users.noreply.github.com> Date: Sat, 21 Sep 2024 08:44:54 +0200 Subject: [PATCH] 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 --- modules/bar/SideEffects.ts | 14 ++++++++++++++ modules/bar/window_title/index.ts | 20 ++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) 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; }, ), }),