diff --git a/dotfiles/.config/quickshell/config/Appearance.qml b/dotfiles/.config/quickshell/config/Appearance.qml index 77711e4..a1e01ba 100644 --- a/dotfiles/.config/quickshell/config/Appearance.qml +++ b/dotfiles/.config/quickshell/config/Appearance.qml @@ -36,6 +36,13 @@ QtObject { // with "…" (ActiveWindow.qml and MediaPlayer.qml). readonly property int activeWindowMaxChars: 50 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 // aren't split in half at the cut. diff --git a/dotfiles/.config/quickshell/modules/bar/ActiveWindow.qml b/dotfiles/.config/quickshell/modules/bar/ActiveWindow.qml index 943e7be..339ff81 100644 --- a/dotfiles/.config/quickshell/modules/bar/ActiveWindow.qml +++ b/dotfiles/.config/quickshell/modules/bar/ActiveWindow.qml @@ -4,8 +4,9 @@ import Quickshell.Hyprland import "../../config" Text { + property bool compact: false font.family: Appearance.fontFamily font.pixelSize: Appearance.fontSizeSmall 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) : "" } diff --git a/dotfiles/.config/quickshell/modules/bar/Bar.qml b/dotfiles/.config/quickshell/modules/bar/Bar.qml index dd8c2ed..8598067 100644 --- a/dotfiles/.config/quickshell/modules/bar/Bar.qml +++ b/dotfiles/.config/quickshell/modules/bar/Bar.qml @@ -16,6 +16,10 @@ PanelWindow { exclusiveZone: implicitHeight 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.namespace: "quickshell:bar" @@ -32,8 +36,8 @@ PanelWindow { } spacing: Appearance.spacing Workspaces { screen: bar.screen } - MediaPlayer { barWindow: bar } - ActiveWindow {} + MediaPlayer { barWindow: bar; compact: bar.compact } + ActiveWindow { compact: bar.compact } } RowLayout { diff --git a/dotfiles/.config/quickshell/modules/bar/MediaPlayer.qml b/dotfiles/.config/quickshell/modules/bar/MediaPlayer.qml index 162f493..4ec3540 100644 --- a/dotfiles/.config/quickshell/modules/bar/MediaPlayer.qml +++ b/dotfiles/.config/quickshell/modules/bar/MediaPlayer.qml @@ -20,6 +20,8 @@ Item { // to the bar so it sits flush under it rather than under this label's // (shorter) text box. 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 // process exits and Quickshell destroys the object. @@ -121,7 +123,7 @@ Item { return "" const title = root.player.trackTitle || root.player.identity 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) } } }