From cc0bc0a72f7e9f0ca7f18baa4956a9841c303c92 Mon Sep 17 00:00:00 2001 From: mx Date: Thu, 12 Nov 2026 17:34:51 +0100 Subject: [PATCH] Add kanji workspaces and a notch-only workspace style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - New "kanji" workspace style: 一 … 十, then 十一 … 二十. - Settings → Notch → Workspaces picks a style for notch mode only; "bar" keeps the style from Settings → Bar. Co-Authored-By: Claude Opus 5.5 --- quickshell/bar/modules/WorkspacesModule.qml | 27 +++++++++++++++------ quickshell/config/defaults.json | 3 ++- quickshell/core/BarLayout.qml | 1 + quickshell/core/SettingsRegistry.qml | 4 +-- quickshell/services/ConfigLogic.js | 3 ++- quickshell/settings/pages/Bar.qml | 4 +-- quickshell/settings/pages/Notch.qml | 11 +++++++++ 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/quickshell/bar/modules/WorkspacesModule.qml b/quickshell/bar/modules/WorkspacesModule.qml index 2cabcfb..411553b 100644 --- a/quickshell/bar/modules/WorkspacesModule.qml +++ b/quickshell/bar/modules/WorkspacesModule.qml @@ -6,21 +6,25 @@ import "../../theme" import "../../services" import "../../core" -// Workspace switcher. Styles (bar.workspaces.style): numbers, roman numerals, +// Workspace switcher. Styles (bar.workspaces.style): numbers, roman numerals, kanji, // dots (filled = occupied, ring = empty) and pacman (after Serpantinum: pellets // for empty workspaces, ghosts for occupied ones, Pac-Man on the active one). GlassPill { id: root property var barScreen + // Layout entry; notch islands mark theirs so the notch can use its own style. + property var entry: ({}) // Every bar follows the globally focused workspace, whichever monitor it is on. readonly property int activeId: Hyprland.focusedWorkspace ? Hyprland.focusedWorkspace.id : 0 // Workspaces shown on other monitors get a faint outline. readonly property var visibleIds: Hyprland.monitors.values.map(m => m.activeWorkspace ? m.activeWorkspace.id : 0).filter(id => id > 0 && id !== activeId) readonly property int count: ConfigService.data.bar.workspaces.count - readonly property string style: ConfigService.data.bar.workspaces.style || "numbers" + readonly property string notchStyle: entry && entry.notch && ConfigService.data.notch ? ConfigService.data.notch.workspaceStyle : "bar" + readonly property string style: notchStyle && notchStyle !== "bar" ? notchStyle : ConfigService.data.bar.workspaces.style || "numbers" + readonly property bool textual: style === "numbers" || style === "roman" || style === "kanji" readonly property bool pacman: style === "pacman" readonly property real pacmanScale: 0.95 - readonly property int slotWidth: style === "roman" ? 38 : style === "dots" ? 22 : style === "pacman" ? 24 : 32 + readonly property int slotWidth: style === "roman" ? 38 : style === "kanji" ? (count > 10 ? 40 : 30) : style === "dots" ? 22 : style === "pacman" ? 24 : 32 readonly property int slotHeight: height - 6 readonly property int activeIndex: activeId >= 1 && activeId <= count ? activeId - 1 : -1 width: count * slotWidth + 8 @@ -36,6 +40,13 @@ GlassPill { } return result; } + // Japanese numerals: 一 … 十, then 十一 … 二十. + function kanji(value) { + const digits = ["", "一", "二", "三", "四", "五", "六", "七", "八", "九"]; + if (value < 10) + return digits[value]; + return (value >= 20 ? digits[Math.floor(value / 10)] : "") + "十" + digits[value % 10]; + } Repeater { model: root.pacman ? [] : root.visibleIds.filter(id => id <= root.count) @@ -84,20 +95,20 @@ GlassPill { width: root.slotWidth height: root.slotHeight - // Numbers and roman numerals + // Numbers, roman numerals and kanji Text { - visible: root.style === "numbers" || root.style === "roman" + visible: root.textual anchors.centerIn: parent anchors.verticalCenterOffset: slot.occupied && !slot.active ? -2 : 0 - text: root.style === "roman" ? root.roman(slot.index + 1) : slot.index + 1 - font.pixelSize: root.style === "roman" ? 11 : 12 + text: root.style === "roman" ? root.roman(slot.index + 1) : root.style === "kanji" ? root.kanji(slot.index + 1) : slot.index + 1 + font.pixelSize: root.style === "roman" ? 11 : root.style === "kanji" ? 13 : 12 font.weight: root.style === "roman" ? Font.DemiBold : Font.Normal font.letterSpacing: root.style === "roman" ? 0.5 : 0 color: slot.urgent ? Theme.urgent : slot.active ? Theme.accentText : Theme.text opacity: slot.active || slot.occupied ? 1 : 0.5 } Rectangle { - visible: (root.style === "numbers" || root.style === "roman") && slot.occupied && !slot.active + visible: root.textual && slot.occupied && !slot.active anchors.bottom: parent.bottom anchors.bottomMargin: 1 anchors.horizontalCenter: parent.horizontalCenter diff --git a/quickshell/config/defaults.json b/quickshell/config/defaults.json index 4a975a1..ba04e69 100644 --- a/quickshell/config/defaults.json +++ b/quickshell/config/defaults.json @@ -274,7 +274,8 @@ "glassOnOpen": false, "openSpeed": 100, "closeSpeed": 100, - "colorSpeed": 100 + "colorSpeed": 100, + "workspaceStyle": "bar" }, "dashboard": { "enabled": true, diff --git a/quickshell/core/BarLayout.qml b/quickshell/core/BarLayout.qml index f8083ca..a851960 100644 --- a/quickshell/core/BarLayout.qml +++ b/quickshell/core/BarLayout.qml @@ -27,6 +27,7 @@ Singleton { }, { id: id, enabled: true, + notch: true, position: key === "right" ? "right" : key === "left" ? "left" : "center" })); } diff --git a/quickshell/core/SettingsRegistry.qml b/quickshell/core/SettingsRegistry.qml index 23207a6..1c1ec8c 100644 --- a/quickshell/core/SettingsRegistry.qml +++ b/quickshell/core/SettingsRegistry.qml @@ -68,7 +68,7 @@ Singleton { available: true, group: "shell", icon: "󰕮", - keywords: ["Bar height", "Margin", "Modules", "Show date", "24-hour time", "Show seconds", "Workspace count", "Workspace style", "Pacman", "Roman numerals", "Clock"] + keywords: ["Bar height", "Margin", "Modules", "Show date", "24-hour time", "Show seconds", "Workspace count", "Workspace style", "Pacman", "Roman numerals", "Kanji", "Clock"] }, { id: "notch", @@ -79,7 +79,7 @@ Singleton { available: true, group: "shell", icon: "󰹑", - keywords: ["Notch", "Notch mode", "Notch opacity", "Notch colour", "Glassy when open", "Opening speed", "Closing speed", "Colour change speed", "Open on Media while audio plays", "Pocket-dots", "Left island", "Right island", "Notch strip"] + keywords: ["Notch", "Notch mode", "Notch opacity", "Notch colour", "Workspace style", "Glassy when open", "Opening speed", "Closing speed", "Colour change speed", "Open on Media while audio plays", "Pocket-dots", "Left island", "Right island", "Notch strip"] }, { id: "tray", diff --git a/quickshell/services/ConfigLogic.js b/quickshell/services/ConfigLogic.js index d2c5066..cf1ac9c 100644 --- a/quickshell/services/ConfigLogic.js +++ b/quickshell/services/ConfigLogic.js @@ -23,7 +23,7 @@ function validate(c) { } if (typeof c.animation.reducedMotion !== "boolean" || !Number.isFinite(c.animation.duration) || c.animation.duration < 0 || c.animation.duration > 1000) throw Error("Invalid animation settings"); if (!Number.isFinite(c.bar.height) || c.bar.height < 32 || c.bar.height > 80 || !Number.isFinite(c.bar.margin) || c.bar.margin < 0 || c.bar.margin > 100) throw Error("Invalid bar geometry"); - if(!Number.isInteger(c.bar.workspaces.count) || c.bar.workspaces.count<1 || c.bar.workspaces.count>20 || !["numbers","roman","dots","pacman"].includes(c.bar.workspaces.style) || ["showDate","use24Hour","showSeconds"].some(k=>typeof c.bar.clock[k]!=="boolean"))throw Error("Invalid bar module options"); + if(!Number.isInteger(c.bar.workspaces.count) || c.bar.workspaces.count<1 || c.bar.workspaces.count>20 || !["numbers","roman","kanji","dots","pacman"].includes(c.bar.workspaces.style) || ["showDate","use24Hour","showSeconds"].some(k=>typeof c.bar.clock[k]!=="boolean"))throw Error("Invalid bar module options"); const cava=c.bar.cava; if(!cava || !Number.isInteger(cava.bars) || cava.bars<4 || cava.bars>24 || !["bars","mirror"].includes(cava.style) || typeof cava.hideWhenIdle!=="boolean")throw Error("Invalid bar visualizer preferences"); const validModules = list => { @@ -89,6 +89,7 @@ function validate(c) { if(!Array.isArray(c.notch.controls) || c.notch.controls.some(m=>!m || typeof m.id!=="string" || typeof m.enabled!=="boolean" || ["w","h"].some(k=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<1 || m[k]>4)) || [["x",3],["y",63]].some(([k,max])=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<0 || m[k]>max))))throw Error("Invalid notch controls"); if(!Number.isFinite(c.notch.opacity) || c.notch.opacity<0 || c.notch.opacity>100 || typeof c.notch.color!=="string" || (c.notch.color!=="" && !/^#[0-9a-fA-F]{6}$/.test(c.notch.color)))throw Error("Invalid notch colour"); if(typeof c.notch.glassOnOpen!=="boolean" || ["openSpeed","closeSpeed","colorSpeed"].some(k=>!Number.isFinite(c.notch[k]) || c.notch[k]<25 || c.notch[k]>300))throw Error("Invalid notch animation"); + if(!["bar","numbers","roman","kanji","dots","pacman"].includes(c.notch.workspaceStyle))throw Error("Invalid notch workspace style"); if(typeof c.osd.enabled!=="boolean" || !["slide","drop","fade","shrink"].includes(c.osd.animation) || !["top-right","top-center","bottom-center"].includes(c.osd.position) || !Number.isInteger(c.osd.timeout) || c.osd.timeout<500 || c.osd.timeout>5000 || !Number.isInteger(c.osd.step) || c.osd.step<1 || c.osd.step>20)throw Error("Invalid OSD preferences"); const notes=c.notifications; if(!notes || ["enabled","doNotDisturb","criticalInDnd"].some(k=>typeof notes[k]!=="boolean") || !["slide","drop","fade","shrink"].includes(notes.animation) || !["top-right","top-center"].includes(notes.position) || !Number.isInteger(notes.timeout) || notes.timeout<1000 || notes.timeout>30000 || !Number.isInteger(notes.maxPopups) || notes.maxPopups<1 || notes.maxPopups>6)throw Error("Invalid notification preferences"); diff --git a/quickshell/settings/pages/Bar.qml b/quickshell/settings/pages/Bar.qml index 87ba5b9..0fbb8df 100644 --- a/quickshell/settings/pages/Bar.qml +++ b/quickshell/settings/pages/Bar.qml @@ -134,10 +134,10 @@ SettingsPage { title: "Workspaces" PreferenceChoice { label: "Workspace style" - description: "Numbers, roman numerals, dots (filled when occupied) or Pac-Man" + description: "Numbers, roman numerals, kanji, dots (filled when occupied) or Pac-Man" icon: "󰏘" setting: "bar.workspaces.style" - choices: ["numbers", "roman", "dots", "pacman"] + choices: ["numbers", "roman", "kanji", "dots", "pacman"] } SettingRow { title: "Preview" diff --git a/quickshell/settings/pages/Notch.qml b/quickshell/settings/pages/Notch.qml index 71df2e5..6773d07 100644 --- a/quickshell/settings/pages/Notch.qml +++ b/quickshell/settings/pages/Notch.qml @@ -169,6 +169,17 @@ SettingsPage { } } } + SettingsSection { + title: "Workspaces" + enabled: root.options.enabled + PreferenceChoice { + label: "Workspace style" + description: "Notch mode only; \"bar\" uses the style from Settings → Bar" + icon: "󰏘" + setting: "notch.workspaceStyle" + choices: ["bar", "numbers", "roman", "kanji", "dots", "pacman"] + } + } SettingsSection { title: "Modules" description: "Which bar modules show in notch mode. The strip sits left of the clock in the open notch; the mouse wheel scrolls it sideways when it overflows."