Feature: Shorter bar labels on narrow screens

Bar.qml switches ActiveWindow and MediaPlayer to tighter truncation
limits when the bar is narrower than compactBarWidth (1600px), so on
the laptop's eDP-1 they don't crowd the centre clock/weather group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 09:24:49 +01:00
parent 7d9905f73b
commit e563ec22d2
4 changed files with 18 additions and 4 deletions

View File

@@ -36,6 +36,13 @@ QtObject {
// with "…" (ActiveWindow.qml and MediaPlayer.qml). // with "…" (ActiveWindow.qml and MediaPlayer.qml).
readonly property int activeWindowMaxChars: 50 readonly property int activeWindowMaxChars: 50
readonly property int mediaMaxChars: 40 readonly property int mediaMaxChars: 40
// Tighter limits for narrow screens (the laptop's eDP-1 is 1440 logical
// px wide), where the full-length labels nearly run into the centre
// clock/weather group. Bar.qml switches when it's narrower than
// compactBarWidth.
readonly property int compactBarWidth: 1600
readonly property int activeWindowMaxCharsCompact: 32
readonly property int mediaMaxCharsCompact: 28
// Counts code points rather than UTF-16 units so emoji / some CJK // Counts code points rather than UTF-16 units so emoji / some CJK
// aren't split in half at the cut. // aren't split in half at the cut.

View File

@@ -4,8 +4,9 @@ import Quickshell.Hyprland
import "../../config" import "../../config"
Text { Text {
property bool compact: false
font.family: Appearance.fontFamily font.family: Appearance.fontFamily
font.pixelSize: Appearance.fontSizeSmall font.pixelSize: Appearance.fontSizeSmall
color: Colors.muted color: Colors.muted
text: Hyprland.activeToplevel ? Appearance.truncate(Hyprland.activeToplevel.title, Appearance.activeWindowMaxChars) : "" text: Hyprland.activeToplevel ? Appearance.truncate(Hyprland.activeToplevel.title, compact ? Appearance.activeWindowMaxCharsCompact : Appearance.activeWindowMaxChars) : ""
} }

View File

@@ -16,6 +16,10 @@ PanelWindow {
exclusiveZone: implicitHeight exclusiveZone: implicitHeight
color: "transparent" color: "transparent"
// Narrow screen (laptop): shorten the left-side free-text labels so they
// don't crowd the centre group.
readonly property bool compact: width < Appearance.compactBarWidth
WlrLayershell.layer: WlrLayer.Top WlrLayershell.layer: WlrLayer.Top
WlrLayershell.namespace: "quickshell:bar" WlrLayershell.namespace: "quickshell:bar"
@@ -32,8 +36,8 @@ PanelWindow {
} }
spacing: Appearance.spacing spacing: Appearance.spacing
Workspaces { screen: bar.screen } Workspaces { screen: bar.screen }
MediaPlayer { barWindow: bar } MediaPlayer { barWindow: bar; compact: bar.compact }
ActiveWindow {} ActiveWindow { compact: bar.compact }
} }
RowLayout { RowLayout {

View File

@@ -20,6 +20,8 @@ Item {
// to the bar so it sits flush under it rather than under this label's // to the bar so it sits flush under it rather than under this label's
// (shorter) text box. // (shorter) text box.
required property var barWindow required property var barWindow
// Set by Bar.qml on narrow screens — shortens the label.
property bool compact: false
// Last player seen playing. Becomes null by itself if that player's // Last player seen playing. Becomes null by itself if that player's
// process exits and Quickshell destroys the object. // process exits and Quickshell destroys the object.
@@ -121,7 +123,7 @@ Item {
return "" return ""
const title = root.player.trackTitle || root.player.identity const title = root.player.trackTitle || root.player.identity
const artist = root.player.trackArtist const artist = root.player.trackArtist
return Appearance.truncate(artist ? artist + " — " + title : title, Appearance.mediaMaxChars) return Appearance.truncate(artist ? artist + " — " + title : title, root.compact ? Appearance.mediaMaxCharsCompact : Appearance.mediaMaxChars)
} }
} }
} }