bar text: truncate instead of having horiz scroll (#320)

This commit is contained in:
end-4
2024-03-10 23:05:41 +07:00
parent 3f05d77664
commit 0b979d9903
2 changed files with 15 additions and 11 deletions
+11 -11
View File
@@ -133,18 +133,18 @@ export default () => {
] ]
})] })]
}); });
const trackTitle = Scrollable({ const trackTitle = Label({
hexpand: true, hexpand: true,
child: Label({ className: 'txt-smallie txt-onSurfaceVariant',
className: 'txt-smallie txt-onSurfaceVariant', truncate: 'end',
setup: (self) => self.hook(Mpris, label => { maxWidthChars: 10, // Doesn't matter, just needs to be non negative
const mpris = Mpris.getPlayer(''); setup: (self) => self.hook(Mpris, label => {
if (mpris) const mpris = Mpris.getPlayer('');
label.label = `${trimTrackTitle(mpris.trackTitle)}${mpris.trackArtists.join(', ')}`; if (mpris)
else label.label = `${trimTrackTitle(mpris.trackTitle)}${mpris.trackArtists.join(', ')}`;
label.label = 'No media'; else
}), label.label = 'No media';
}) }),
}) })
const musicStuff = Box({ const musicStuff = Box({
className: 'spacing-h-10', className: 'spacing-h-10',
@@ -14,6 +14,8 @@ const WindowTitle = async () => {
children: [ children: [
Widget.Label({ Widget.Label({
xalign: 0, xalign: 0,
truncate: 'end',
maxWidthChars: 10, // Doesn't matter, just needs to be non negative
className: 'txt-smaller bar-topdesc txt', className: 'txt-smaller bar-topdesc txt',
setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
label.label = Hyprland.active.client.class.length === 0 ? 'Desktop' : Hyprland.active.client.class; label.label = Hyprland.active.client.class.length === 0 ? 'Desktop' : Hyprland.active.client.class;
@@ -21,6 +23,8 @@ const WindowTitle = async () => {
}), }),
Widget.Label({ Widget.Label({
xalign: 0, xalign: 0,
truncate: 'end',
maxWidthChars: 10, // Doesn't matter, just needs to be non negative
className: 'txt txt-smallie', className: 'txt txt-smallie',
setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
label.label = Hyprland.active.client.title.length === 0 ? `Workspace ${Hyprland.active.workspace.id}` : Hyprland.active.client.title; label.label = Hyprland.active.client.title.length === 0 ? `Workspace ${Hyprland.active.workspace.id}` : Hyprland.active.client.title;