Skip to content

Commit 79470dd

Browse files
committed
Refine shell panel and lock theming
1 parent 3cdfb52 commit 79470dd

9 files changed

Lines changed: 203 additions & 33 deletions

File tree

‎bin/omarchy-theme-set-templates‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,83 @@ add_gradient_function_values() {
290290
done
291291
}
292292

293+
strip_shell_section_header() {
294+
local section="$1"
295+
local file="$2"
296+
297+
awk -v section="$section" '
298+
BEGIN { skipping_header = 0 }
299+
/^[[:space:]]*\[[^]]+\][[:space:]]*($|#)/ {
300+
if ($0 ~ "^[[:space:]]*\\[" section "\\][[:space:]]*($|#)") {
301+
skipping_header = 1
302+
next
303+
}
304+
}
305+
{ print }
306+
' "$file"
307+
}
308+
309+
apply_shell_section_override() {
310+
local override="$1"
311+
local section tmp body
312+
313+
[[ -f $NEXT_THEME_DIR/shell.toml ]] || return
314+
[[ -f $override ]] || return
315+
316+
section=$(basename "$override")
317+
section="${section#shell.}"
318+
section="${section%.toml}"
319+
[[ $section =~ ^[A-Za-z0-9_-]+$ ]] || return
320+
321+
tmp=$(mktemp)
322+
body=$(mktemp)
323+
324+
strip_shell_section_header "$section" "$override" >"$body"
325+
326+
awk -v section="$section" -v body="$body" '
327+
function emit_override() {
328+
if (emitted) return
329+
print "[" section "]"
330+
while ((getline line < body) > 0) print line
331+
close(body)
332+
emitted = 1
333+
}
334+
335+
/^[[:space:]]*\[[^]]+\][[:space:]]*($|#)/ {
336+
if (in_section) {
337+
emit_override()
338+
in_section = 0
339+
}
340+
if ($0 ~ "^[[:space:]]*\\[" section "\\][[:space:]]*($|#)") {
341+
in_section = 1
342+
next
343+
}
344+
}
345+
346+
!in_section { print }
347+
348+
END {
349+
if (in_section || !emitted) {
350+
if (NR > 0) print ""
351+
emit_override()
352+
}
353+
}
354+
' "$NEXT_THEME_DIR/shell.toml" >"$tmp"
355+
356+
mv "$tmp" "$NEXT_THEME_DIR/shell.toml"
357+
rm "$body"
358+
}
359+
360+
apply_shell_section_overrides() {
361+
local override
362+
363+
shopt -s nullglob
364+
for override in "$NEXT_THEME_DIR"/shell.*.toml; do
365+
[[ $(basename "$override") != "shell.toml" ]] || continue
366+
apply_shell_section_override "$override"
367+
done
368+
}
369+
293370
alias_theme_color() {
294371
local key="$1"
295372
local fallback="$2"
@@ -426,3 +503,5 @@ if [[ -f $COLORS_FILE ]]; then
426503

427504
rm "$sed_script"
428505
fi
506+
507+
apply_shell_section_overrides

‎docs/theming.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ The helper does not choose the first color unless you use `gradient_start`.
101101
and bar sizing. The default generated file comes from
102102
`default/themed/shell.toml.tpl`.
103103

104+
Themes can override the entire generated file by shipping `shell.toml`, or just
105+
one section by shipping `shell.<section>.toml`. For example,
106+
`shell.lock.toml` replaces only the `[lock]` section after the default
107+
`shell.toml` has been generated:
108+
109+
```toml
110+
text = "#ffffff"
111+
placeholder = "#ffffff"
112+
border = "#ffffff"
113+
```
114+
115+
The filename decides the target section, so the `[lock]` header is optional.
116+
104117
The running shell reads `shell.toml` into two QML singletons:
105118

106119
- `Color` for palette and surface roles like `Color.menu.border`.

‎shell/Ui/KeyboardPanel.qml‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ import qs.Commons
1414
// their parent surface — so keyboard-summoned popups fell flat without it.
1515
//
1616
// API is a subset of Common.PopupCard: anchorItem, owner, bar, open,
17-
// padding, margin, contentWidth/Height, default contentItem. Missing on
18-
// purpose (for now): centerOnBar, triggerMode ("hover"), containsMouse.
19-
// Hover-mode popups (system-stats, weather) and centered popups
20-
// (calendar week-view) need extra plumbing before migrating; converting
21-
// them is a follow-up.
17+
// padding, margin, contentWidth/Height, centerOnBar, default contentItem.
18+
// Missing on purpose (for now): triggerMode ("hover"), containsMouse.
19+
// Hover-mode popups (system-stats) need extra plumbing before migrating.
2220
//
2321
// Positioning: full-screen layer-shell with the card placed inside at
2422
// `cardOrigin`. We use the bar window's height/width for the perpendicular
@@ -42,6 +40,7 @@ PanelWindow {
4240
property int padding: Style.spacing.popupPadding
4341
property int contentWidth: Style.space(280)
4442
property int contentHeight: Style.space(200)
43+
property bool centerOnBar: false
4544
property bool open: false
4645
property int gap: Style.gapsOut // distance between bar edge and panel
4746
property bool popoutSwitching: false
@@ -173,7 +172,13 @@ PanelWindow {
173172
readonly property point cardOrigin: {
174173
if (!anchorItem || !bar) return Qt.point(margin, margin)
175174
var x = 0, y = 0
176-
if (barPos === "bottom") {
175+
if (centerOnBar && (barPos === "top" || barPos === "bottom")) {
176+
x = screenW / 2 - contentWidth / 2
177+
y = barPos === "bottom" ? screenH - barH - contentHeight - gap : barH + gap
178+
} else if (centerOnBar) {
179+
x = barPos === "left" ? barW + gap : screenW - barW - contentWidth - gap
180+
y = screenH / 2 - contentHeight / 2
181+
} else if (barPos === "bottom") {
177182
x = anchorScreenPos.x + anchorW / 2 - contentWidth / 2
178183
y = screenH - barH - contentHeight - gap
179184
} else if (barPos === "left") {

‎shell/plugins/bar/Bar.qml‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Item {
4040
property bool useTransparentForeground: false
4141
property bool transparent: false
4242
property bool centerSectionHovered: false
43+
property bool centerSectionRevealHeld: false
44+
property bool centerHoverRevealSuppressed: false
4345
property int barConfigSerial: 0
4446
property string position: "top"
4547
// Resolves through fontconfig at paint time (Style.font.family defaults
@@ -374,6 +376,22 @@ Item {
374376

375377
Component.onCompleted: applyBarConfig()
376378

379+
function setCenterSectionHovered(hovered) {
380+
centerSectionHovered = hovered
381+
if (hovered) {
382+
centerSectionRevealTimer.stop()
383+
centerSectionRevealHeld = true
384+
} else {
385+
centerSectionRevealTimer.restart()
386+
}
387+
}
388+
389+
Timer {
390+
id: centerSectionRevealTimer
391+
interval: 120
392+
onTriggered: root.centerSectionRevealHeld = root.centerSectionHovered
393+
}
394+
377395
function run(command) {
378396
if (!command) return
379397

@@ -970,7 +988,7 @@ Item {
970988
CenterGestureArea { anchors.fill: parent }
971989

972990
HoverHandler {
973-
onHoveredChanged: root.centerSectionHovered = hovered
991+
onHoveredChanged: root.setCenterSectionHovered(hovered)
974992
}
975993

976994
ModuleList {
@@ -1001,7 +1019,7 @@ Item {
10011019

10021020
visible: centerRoot.hasAnchor && centerAnchorModule.moduleName === "omarchy.clock"
10031021
clockHovered: centerAnchorModule.hovered
1004-
centerHovered: root.centerSectionHovered
1022+
centerHovered: root.centerSectionRevealHeld && !root.centerHoverRevealSuppressed
10051023
anchors.right: centerAnchorModule.left
10061024
anchors.verticalCenter: centerAnchorModule.verticalCenter
10071025
}
@@ -1025,7 +1043,7 @@ Item {
10251043
CenterGestureArea { anchors.fill: parent }
10261044

10271045
HoverHandler {
1028-
onHoveredChanged: root.centerSectionHovered = hovered
1046+
onHoveredChanged: root.setCenterSectionHovered(hovered)
10291047
}
10301048

10311049
ModuleList {
@@ -1056,7 +1074,7 @@ Item {
10561074

10571075
visible: centerRoot.hasAnchor && centerAnchorModule.moduleName === "omarchy.clock"
10581076
clockHovered: centerAnchorModule.hovered
1059-
centerHovered: root.centerSectionHovered
1077+
centerHovered: root.centerSectionRevealHeld && !root.centerHoverRevealSuppressed
10601078
anchors.bottom: centerAnchorModule.top
10611079
anchors.horizontalCenter: centerAnchorModule.horizontalCenter
10621080
}
@@ -1098,13 +1116,8 @@ Item {
10981116
implicitHeight: button.implicitHeight
10991117
width: implicitWidth
11001118
height: implicitHeight
1101-
opacity: revealed ? 1.0 : 0
11021119
z: 500
11031120

1104-
Behavior on opacity {
1105-
NumberAnimation { duration: 120; easing.type: Easing.OutCubic }
1106-
}
1107-
11081121
HoverHandler { id: controlHover }
11091122

11101123
Component.onCompleted: root.registerConfigControl(configControl)

‎shell/plugins/bar/widgets/Indicators.qml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ BarWidget {
1717
property bool indicatorAreaHovered: false
1818
property bool indicatorItemHovered: false
1919
readonly property bool alwaysShowIndicators: setting("alwaysShow", false) === true
20-
readonly property bool revealInactiveIndicators: alwaysShowIndicators || indicatorAreaHovered || indicatorItemHovered || (bar && bar.centerSectionHovered === true)
20+
readonly property bool revealInactiveIndicators: alwaysShowIndicators || indicatorAreaHovered || indicatorItemHovered || (bar && bar.centerSectionRevealHeld === true && bar.centerHoverRevealSuppressed !== true)
2121

2222
signal refreshRequested()
2323

‎shell/plugins/lock/LockView.qml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Item {
2828
readonly property bool errorState: failureMessage.length > 0
2929
readonly property var inputBorderSpec: errorState
3030
? Border.surfaceSpec("lock", "border-error", Color.lock.borderError, root.outlineThickness, "border-alpha")
31-
: Border.hyprlandActiveSpec(Color.accent, root.outlineThickness)
31+
: Border.surfaceSpec("lock", "border-active", Color.lock.borderActive, root.outlineThickness, "border-alpha")
3232

3333
signal submitPassword(string password)
3434
signal passwordTextEdited(string password)

‎shell/plugins/panels/weather/Panel.qml‎

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,38 @@ Panel {
99
id: root
1010
moduleName: "omarchy.weather"
1111
ipcTarget: "omarchy.weather"
12+
manageIpc: false
1213

1314
property var anchorItem: null
15+
property bool openedFromHotkey: false
1416

1517
function open() {
18+
openedFromHotkey = false
19+
setCenterHoverRevealSuppressed(false)
1620
root.controller.show()
1721
root.refresh()
1822
}
1923

24+
function openFromHotkey() {
25+
openedFromHotkey = true
26+
setCenterHoverRevealSuppressed(true)
27+
root.controller.show()
28+
root.refresh()
29+
}
30+
31+
function close() {
32+
setCenterHoverRevealSuppressed(false)
33+
root.controller.hide()
34+
}
35+
2036
function toggle() {
2137
if (root.opened) root.close()
22-
else root.open()
38+
else root.openFromHotkey()
39+
}
40+
41+
function setCenterHoverRevealSuppressed(value) {
42+
if (root.bar && "centerHoverRevealSuppressed" in root.bar)
43+
root.bar.centerHoverRevealSuppressed = value
2344
}
2445

2546
// Parsed wttr.in j1 response. Kept on failure so stale data stays visible.
@@ -190,29 +211,45 @@ Panel {
190211
onTriggered: root.refresh()
191212
}
192213

193-
PopupCard {
194-
id: popup
214+
IpcHandler {
215+
target: root.ipcTarget
216+
217+
function open(): void { root.openFromHotkey() }
218+
function close(): void { root.close() }
219+
function show(): void { root.openFromHotkey() }
220+
function hide(): void { root.close() }
221+
function toggle(): void { root.toggle() }
222+
}
223+
224+
KeyboardPanel {
225+
id: panel
195226
anchorItem: root.anchorItem
196227
owner: root
197228
bar: root.bar
198229
open: root.opened
199230
centerOnBar: true
200-
triggerMode: "click"
201-
contentWidth: popup.fittedContentWidth(Style.space(480))
202-
contentHeight: popup.fittedContentHeight(weatherColumn.implicitHeight)
231+
focusTarget: keyCatcher
232+
contentWidth: panel.fittedContentWidth(Style.space(480))
233+
contentHeight: panel.fittedContentHeight(weatherColumn.implicitHeight)
203234

204-
Flickable {
205-
id: weatherScroll
235+
PanelKeyCatcher {
236+
id: keyCatcher
206237
anchors.fill: parent
207-
contentWidth: width
208-
contentHeight: weatherColumn.implicitHeight
209-
clip: true
210-
boundsBehavior: Flickable.StopAtBounds
238+
onCloseRequested: root.close()
239+
onTabRequested: function(direction) { root.switchPanel(direction) }
211240

212-
Column {
213-
id: weatherColumn
214-
width: weatherScroll.width
215-
spacing: Style.space(14)
241+
Flickable {
242+
id: weatherScroll
243+
anchors.fill: parent
244+
contentWidth: width
245+
contentHeight: weatherColumn.implicitHeight
246+
clip: true
247+
boundsBehavior: Flickable.StopAtBounds
248+
249+
Column {
250+
id: weatherColumn
251+
width: weatherScroll.width
252+
spacing: Style.space(14)
216253

217254
// ---- Hero row: big icon + temp on the left; location and stats stacked on the right.
218255
Item {
@@ -431,6 +468,7 @@ Panel {
431468
}
432469
}
433470
}
471+
}
434472

435473
// Poll the weather pill text/class every minute. Local to this widget.
436474
Process {

‎test/cli‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ bright-magenta={{ bright_magenta }}
264264
legacy-bright-purple={{ bright_purple }}
265265
EOF
266266

267+
cat >"$NEXT_THEME/shell.lock.toml" <<'EOF'
268+
text = "#ffffff"
269+
placeholder = "#ffffff"
270+
border = "#ffffff"
271+
EOF
272+
267273
OMARCHY_PATH="$ROOT" HOME="$PI_TMPDIR" "$ROOT/bin/omarchy-theme-set-templates"
268274
grep -qx 'mix=#808080' "$NEXT_THEME/mix-test.txt" || fail "theme template mix helper works"
269275
grep -qx 'strip=808080' "$NEXT_THEME/mix-test.txt" || fail "theme template mix_strip helper works"
@@ -291,6 +297,16 @@ grep -qx 'fallback-shell=#336699' "$NEXT_THEME/gradient-test.txt" || fail "theme
291297
grep -qx 'fallback-shell-gradient=#336699' "$NEXT_THEME/gradient-test.txt" || fail "theme template shell_gradient fallback works"
292298
pass "theme template gradient helpers work"
293299

300+
awk '
301+
/^\[lock\]$/ { in_lock = 1; next }
302+
/^\[/ { in_lock = 0 }
303+
in_lock && /^text = "#ffffff"$/ { text = 1 }
304+
in_lock && /^placeholder = "#ffffff"$/ { placeholder = 1 }
305+
in_lock && /^border = "#ffffff"$/ { border = 1 }
306+
END { exit(text && placeholder && border ? 0 : 1) }
307+
' "$NEXT_THEME/shell.toml" || fail "theme shell section override is merged"
308+
pass "theme shell section override is merged"
309+
294310
jq -e '.name == "omarchy-system" and .vars.panel == "#0f0f0f" and .vars.border == "#4d4d4d" and .colors.accent == "accent"' "$NEXT_THEME/pi.json" >/dev/null
295311
pass "pi theme template is generated from standard themed templates"
296312
cp "$NEXT_THEME/pi.json" "$CURRENT_THEME/pi.json"

‎themes/tokyo-night/shell.lock.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
text = "#a9b1d6"
2+
placeholder = "#a9b1d6"
3+
text-error = "#a9b1d6"
4+
border = "#a9b1d6"
5+
border-active = "#a9b1d6"
6+
border-error = "#a9b1d6"

0 commit comments

Comments
 (0)