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 00e8d9a6e0
commit bf50557800
2 changed files with 15 additions and 11 deletions

View file

@ -133,18 +133,18 @@ export default () => {
]
})]
});
const trackTitle = Scrollable({
const trackTitle = Label({
hexpand: true,
child: Label({
className: 'txt-smallie txt-onSurfaceVariant',
setup: (self) => self.hook(Mpris, label => {
const mpris = Mpris.getPlayer('');
if (mpris)
label.label = `${trimTrackTitle(mpris.trackTitle)}${mpris.trackArtists.join(', ')}`;
else
label.label = 'No media';
}),
})
className: 'txt-smallie txt-onSurfaceVariant',
truncate: 'end',
maxWidthChars: 10, // Doesn't matter, just needs to be non negative
setup: (self) => self.hook(Mpris, label => {
const mpris = Mpris.getPlayer('');
if (mpris)
label.label = `${trimTrackTitle(mpris.trackTitle)}${mpris.trackArtists.join(', ')}`;
else
label.label = 'No media';
}),
})
const musicStuff = Box({
className: 'spacing-h-10',

View file

@ -14,6 +14,8 @@ const WindowTitle = async () => {
children: [
Widget.Label({
xalign: 0,
truncate: 'end',
maxWidthChars: 10, // Doesn't matter, just needs to be non negative
className: 'txt-smaller bar-topdesc txt',
setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
label.label = Hyprland.active.client.class.length === 0 ? 'Desktop' : Hyprland.active.client.class;
@ -21,6 +23,8 @@ const WindowTitle = async () => {
}),
Widget.Label({
xalign: 0,
truncate: 'end',
maxWidthChars: 10, // Doesn't matter, just needs to be non negative
className: 'txt txt-smallie',
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;