Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion bin/omarchy-bar
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# omarchy:summary=Configure the bar and its widget layout
# omarchy:group=bar
# omarchy:args=use <id> | reset | defaults | position <top|bottom|left|right> | transparent <true|false|toggle> | put <id> [placement] | move <id> [placement] | set <id> <key> <value> [--json] [placement]
# omarchy:args=use <id> | reset | defaults | position <top|bottom|left|right> | transparent <true|false|toggle> | floating <true|false|toggle> | put <id> [placement] | move <id> [placement] | set <id> <key> <value> [--json] [placement]
# omarchy:examples=omarchy bar use local.neon-bar | omarchy bar put omarchy.keyboard-layout --after omarchy.clock | omarchy bar move omarchy.clock --section center --index 0 | omarchy bar set omarchy.clock format HH:mm

set -euo pipefail
Expand All @@ -18,6 +18,7 @@ Usage: omarchy bar <command> [args...]
defaults Restore the default bar and service widgets
position <top|bottom|left|right> Bar position
transparent <true|false|toggle> Bar transparency
floating <true|false|toggle> Float the bar off the screen edge
put <id> [placement] Put a widget on the bar, leaving one
that is already there where it is
move <id> [placement] Move a widget within or between sections
Expand Down Expand Up @@ -218,6 +219,20 @@ cmd_transparent() {
fi
}

cmd_floating() {
local floating="${1:-}"
[[ -n $floating ]] || fail "floating is required"
(( $# == 1 )) || fail "floating takes a single value"
[[ $floating =~ ^(true|false|toggle)$ ]] || fail "floating must be true, false, or toggle"
if [[ $floating == "toggle" ]]; then
commit "$NORMALIZE | .bar.floating = (.bar.floating != true)"
echo "Bar floating toggled"
else
commit "$NORMALIZE | .bar.floating = \$floating" --argjson floating "$floating"
echo "Bar floating set to $floating"
fi
}

bar_widget_default_section() {
local catalog
catalog=$(omarchy-plugin-catalog 2>/dev/null) || {
Expand Down Expand Up @@ -385,6 +400,9 @@ case "$command" in
transparent)
cmd_transparent "$@"
;;
floating)
cmd_floating "$@"
;;
put)
cmd_put "$@"
;;
Expand Down
3 changes: 2 additions & 1 deletion docs/omarchy-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ You can still install by hand: drop a plugin into
`~/.config/omarchy/plugins/<id>/`, run `omarchy-shell shell rescanPlugins`, then
`omarchy plugin enable <id>`. A bar widget starts in its declared default
section; enabling a full bar replaces the one in use. `omarchy bar` drives the
bar from the CLI — `use | reset | defaults | position | transparent | put |
bar from the CLI — `use | reset | defaults | position | transparent | floating | put |
move | set`, with placement flags such as `--section` and `--index`.
The lower-level IPC methods remain available through `omarchy-shell shell ...`.

Expand Down Expand Up @@ -148,6 +148,7 @@ string on a miss.
"id": "omarchy.bar",
"position": "top",
"transparent": false,
"floating": false,
"centerAnchor": "omarchy.clock",
"layout": {
"left": [ { "id": "omarchy.menu" } ],
Expand Down
6 changes: 6 additions & 0 deletions manual/05-the-top-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ The same things have commands, which is what you want for a [dotfiles](31-dotfil
```bash
omarchy bar position bottom
omarchy bar transparent toggle
omarchy bar floating toggle
omarchy bar move omarchy.clock --section center --index 0
omarchy bar set omarchy.clock format "HH:mm"
omarchy bar defaults # back to the shipped layout
Expand All @@ -102,6 +103,10 @@ omarchy plugin enable omarchy.media --section center
omarchy plugin disable omarchy.weather
```

## Floating the bar

`omarchy bar floating true` lifts the bar off the screen edge. It sits one window gap away from the edge and both sides, so it lines up with your windows, and takes the same corner rounding they do. Toggling window gaps (`Super + Shift + Backspace`) tucks it back against the edge along with the windows. `omarchy bar floating false` docks it again.

## Hiding the bar

`Super + Shift + Space` toggles the bar off and back on without killing the shell — panels and hotkeys keep working, you just get the pixels back. It's also in the menu under **Trigger → Toggle → Menu Bar**.
Expand All @@ -116,6 +121,7 @@ All of it is stored in `~/.config/omarchy/shell.json`, under the `bar` key. Here
"bar": {
"position": "top",
"transparent": false,
"floating": false,
"centerAnchor": "omarchy.clock",
"layout": {
"left": [{ "id": "omarchy.menu" }, { "id": "omarchy.workspaces" }],
Expand Down
120 changes: 98 additions & 22 deletions shell/plugins/bar/Bar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,38 @@ Item {
property bool requestedTransparent: false
property bool useTransparentForeground: false
property bool transparent: false

// `bar.floating` detaches the bar from its screen edge: it sits one
// Hyprland gaps_out away from the edge and both sides, lining up with
// window edges, with the corner radius windows get from
// decoration:rounding. Style.gapsOut is half of gaps_out.
property bool floating: false
// `omarchy toggle window-gaps` zeroes gaps and rounding. Style re-polls
// Hyprland only after the reload settles, so the bar watches the toggle
// flag itself and keeps the last real gap and radius meanwhile; that way
// it moves with the windows instead of snapping after them.
property bool windowGapsOff: false
property int lastGap: 0
property int lastRadius: 0
readonly property int floatGap: floating && !windowGapsOff ? (Style.gapsOut > 0 ? Style.gapsOut * 2 : lastGap) : 0
readonly property int floatRadius: floating && !windowGapsOff ? (Style.cornerRadius > 0 ? Style.cornerRadius : lastRadius) : 0
Comment on lines +69 to +70

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Bar keeps old gaps

Cached gaps and rounding never expire when the restored value stays zero. For example, start with rounding 12, turn gaps off, change the configured rounding to 0, then turn gaps back on. Style.cornerRadius stays 0, so onCornerRadiusChanged() never runs again and floatRadius keeps using 12. The same problem affects a gap changed to zero while gaps are off. Refresh the cached values after the restore poll completes, even when the values did not change.

// Reserved space follows the target at once; the layer window never
// resizes for a gap change (a resized layer surface can show one stale,
// stretched frame), so a floating bar's window always spans the floating
// footprint and only its reserved space and card inset change.
readonly property int barExtent: barSize + floatGap
readonly property int windowExtent: barSize + (floating ? Math.max(lastGap, floatGap) : 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Panels keep an extra gap

Keeping the layer window larger than the docked card breaks the spacing used by KeyboardPanel. It places panels using anchorWindow.height or anchorWindow.width, not the visible card edge. With a floating top bar and a remembered gap of 10, turning gaps off leaves the clock and weather panels 10 pixels below the flush bar even though gap is now zero. Update panel placement to use the visible bar edge rather than the fixed window size.

Knowledge Base Used: Shell UI and desktop interactions

// Animated on the default Hyprland `windows` curve (easeOutQuint, 3.79).
property real shownGap: floatGap
property real shownRadius: floatRadius
Behavior on shownGap { NumberAnimation { duration: 379; easing.type: Easing.BezierSpline; easing.bezierCurve: [0.23, 1, 0.32, 1, 1, 1] } }
Behavior on shownRadius { NumberAnimation { duration: 379; easing.type: Easing.BezierSpline; easing.bezierCurve: [0.23, 1, 0.32, 1, 1, 1] } }

Connections {
target: Style
function onGapsOutChanged() { if (Style.gapsOut > 0 || !root.windowGapsOff) root.lastGap = Style.gapsOut * 2 }
function onCornerRadiusChanged() { if (Style.cornerRadius > 0 || !root.windowGapsOff) root.lastRadius = Style.cornerRadius }
}
property bool centerSectionHovered: false
// One bar surface exists per monitor and each reports into this count, so a
// pointer crossing from one monitor's bar to another's stays counted however
Expand Down Expand Up @@ -583,6 +615,7 @@ Item {

position = normalizePosition(config.position)
setRequestedTransparency(config.transparent === true)
floating = config.floating === true
centerAnchor = Util.canonicalWidgetId(config.centerAnchor || "")

// layoutEntries feeds plain JS arrays to the module Repeaters, and QML
Expand Down Expand Up @@ -805,7 +838,11 @@ Item {
return source ? Util.fileUrl(source) : ""
}

Component.onCompleted: applyBarConfig()
Component.onCompleted: {
lastGap = Style.gapsOut * 2
lastRadius = Style.cornerRadius
applyBarConfig()
}

// Revealing the indicators widens their section, which can slide a neighbour
// under a stationary pointer. Collapsing on that un-hover would move it back
Expand Down Expand Up @@ -1063,7 +1100,7 @@ Item {
transparentForegroundProc.command = [
"omarchy-bar-text-color",
root.position,
String(root.barSize),
String(root.barExtent),
colorHex(root.themeForeground),
colorHex(root.themeContrastForeground)
]
Expand All @@ -1072,6 +1109,7 @@ Item {

onRequestedTransparentChanged: scheduleTransparentForegroundRefresh()
onPositionChanged: scheduleTransparentForegroundRefresh()
onBarExtentChanged: scheduleTransparentForegroundRefresh()
onThemeForegroundChanged: scheduleTransparentForegroundRefresh()
onThemeContrastForegroundChanged: scheduleTransparentForegroundRefresh()

Expand Down Expand Up @@ -1178,6 +1216,20 @@ Item {
onFileChanged: barHiddenProbe.running = true
}

// Same pattern for the window-gaps flag, which lives one level down.
Process {
id: windowGapsProbe
running: true
command: ["bash", "-c", "[[ -f $HOME/.local/state/omarchy/toggles/hypr/window-no-gaps.lua ]] && echo yes || echo no"]
stdout: SplitParser { onRead: function(line) { root.windowGapsOff = String(line).trim() === "yes" } }
}
FileView {
path: root.home + "/.local/state/omarchy/toggles/hypr"
watchChanges: true
printErrors: false
onFileChanged: windowGapsProbe.running = true
Comment on lines +1226 to +1230

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Bar misses gap toggles

The new directory watch has no recovery path if it misses a gap toggle. The existing bar-off watch documents this failure and uses syncHidden() to recover, but windowGapsProbe only runs at startup and on directory events. After quick toggles, windowGapsOff can stay stale even after Style refreshes, leaving the floating bar docked or inset incorrectly until the shell restarts. Add a refresh call from the toggle command or another way to re-read the flag.

}

// The directory watch can permanently stop delivering events after flag
// changes land in quick succession, stranding the bar off screen until the
// shell restarts. `omarchy-toggle-bar` nudges this after flipping the flag
Expand Down Expand Up @@ -1240,18 +1292,19 @@ Item {
// textures — which measures ~150ms against ~20ms to tear down. Parking
// keeps the surface alive, so showing is only a margin change.
visible: !remapGuard.remapping
exclusionMode: root.barHidden ? ExclusionMode.Ignore : ExclusionMode.Auto
exclusionMode: root.barHidden ? ExclusionMode.Ignore : ExclusionMode.Normal
exclusiveZone: root.barExtent

ScreenMoveRemap {
id: remapGuard
window: barWindow
}

margins {
top: root.barHidden && root.position === "top" ? -root.barSize : 0
bottom: root.barHidden && root.position === "bottom" ? -root.barSize : 0
left: root.barHidden && root.position === "left" ? -root.barSize : 0
right: root.barHidden && root.position === "right" ? -root.barSize : 0
top: root.barHidden && root.position === "top" ? -root.windowExtent : 0
bottom: root.barHidden && root.position === "bottom" ? -root.windowExtent : 0
left: root.barHidden && root.position === "left" ? -root.windowExtent : 0
right: root.barHidden && root.position === "right" ? -root.windowExtent : 0
}

anchors {
Expand All @@ -1261,25 +1314,48 @@ Item {
right: root.position === "right" || !root.vertical
}

implicitWidth: root.vertical ? root.barSize : 0
implicitHeight: root.vertical ? 0 : root.barSize
color: root.transparent ? "transparent" : root.background
implicitWidth: root.vertical ? root.windowExtent : 0
implicitHeight: root.vertical ? 0 : root.windowExtent
// The window is clear; barSurface carries the background so a floating
// bar can inset from the edge and round its corners. Only the surface
// takes input, so the floating gap passes clicks through.
color: "transparent"
surfaceFormat.opaque: false
mask: Region { item: barSurface }
WlrLayershell.namespace: "omarchy-bar"
WlrLayershell.layer: WlrLayer.Top

Loader {
anchors.fill: parent
sourceComponent: root.vertical ? verticalBar : horizontalBar

// A child of the loader, not a sibling of the sections: an ancestor stays
// hovered while the pointer is over a widget, where a sibling would lose
// hover to the section the pointer entered.
HoverHandler {
onHoveredChanged: root.setBarHovered(hovered)
// Unplugging a monitor destroys its bar without a leave event, which
// would strand this surface's tally and hold the peek open for good.
Component.onDestruction: if (hovered) root.setBarHovered(false)
Rectangle {
id: barSurface

// Pinned to the outer edge with the floating gap as its inset, keeping
// its own size while the window holds the full floating extent.
anchors.top: root.position !== "bottom" ? parent.top : undefined
anchors.bottom: root.position !== "top" ? parent.bottom : undefined
anchors.left: root.position !== "right" ? parent.left : undefined
anchors.right: root.position !== "left" ? parent.right : undefined
anchors.topMargin: root.position !== "bottom" ? root.shownGap : 0
anchors.bottomMargin: root.position !== "top" ? root.shownGap : 0
anchors.leftMargin: root.position !== "right" ? root.shownGap : 0
anchors.rightMargin: root.position !== "left" ? root.shownGap : 0
width: root.vertical ? root.barSize : undefined
height: root.vertical ? undefined : root.barSize
radius: Math.min(root.shownRadius, Math.min(width, height) / 2)
color: root.transparent ? "transparent" : root.background

Loader {
anchors.fill: parent
sourceComponent: root.vertical ? verticalBar : horizontalBar

// A child of the loader, not a sibling of the sections: an ancestor stays
// hovered while the pointer is over a widget, where a sibling would lose
// hover to the section the pointer entered.
HoverHandler {
onHoveredChanged: root.setBarHovered(hovered)
// Unplugging a monitor destroys its bar without a leave event, which
// would strand this surface's tally and hold the peek open for good.
Component.onDestruction: if (hovered) root.setBarHovered(false)
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion shell/plugins/bar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ the shell for its whole session.

The bar config lives under the `bar:` key of [`~/.config/omarchy/shell.json`](../../../docs/omarchy-shell.md#shelljson). Out of the box the shell uses [`config/omarchy/shell.json`](../../../config/omarchy/shell.json). Once you customize anything via the bar gestures, `omarchy bar ...`, or by editing shell.json directly, your file is canonical — there is no deep-merge.

The bar is configured directly on the bar itself: drag empty bar space (or click-and-hold) to move the bar to another screen edge, double-left-click empty center-bar space to toggle transparency, and drag widgets to reorder them. The `omarchy bar position`, `omarchy bar transparent`, `omarchy bar move`, and `omarchy bar set` commands do the same from scripts. Enable or disable widgets with `omarchy plugin enable` and `omarchy plugin disable` (widget ids come from `omarchy plugin list`).
The bar is configured directly on the bar itself: drag empty bar space (or click-and-hold) to move the bar to another screen edge, double-left-click empty center-bar space to toggle transparency, and drag widgets to reorder them. The `omarchy bar position`, `omarchy bar transparent`, `omarchy bar move`, and `omarchy bar set` commands do the same from scripts. `omarchy bar floating` (or `"floating": true`) lifts the bar off its screen edge by one Hyprland `gaps_out`, with the window corner radius from `decoration:rounding`; the bar window keeps a fixed size and only the card inside it moves, so toggling window gaps animates it without resizing the layer surface. Enable or disable widgets with `omarchy plugin enable` and `omarchy plugin disable` (widget ids come from `omarchy plugin list`).

Example `shell.json` (bar subtree only shown):

Expand All @@ -26,6 +26,7 @@ Example `shell.json` (bar subtree only shown):
"bar": {
"position": "top",
"transparent": false,
"floating": false,
"centerAnchor": "omarchy.clock",
"layout": {
"left": [
Expand Down
6 changes: 5 additions & 1 deletion shell/plugins/notifications/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ Item {
readonly property bool barVertical: barPosition === "left" || barPosition === "right"
readonly property int defaultBarSize: barVertical ? Style.bar.sizeVertical : Style.bar.sizeHorizontal
readonly property int liveBarSize: shell && shell.bar && !shell.bar.barHidden ? Math.max(0, shell.bar.barSize) : defaultBarSize
readonly property int barClearance: liveBarSize + Style.gapsOut
// A floating bar reaches past barSize + gapsOut; clear its full extent when
// the bar reports one, else the plain size plus the gap.
readonly property int liveBarExtent: shell && shell.bar && !shell.bar.barHidden && shell.bar.barExtent !== undefined
? Math.max(0, shell.bar.barExtent) : -1
readonly property int barClearance: Math.max(liveBarExtent, liveBarSize + Style.gapsOut)

// Live Notification objects by originalId, kept OUT of the ListModels: a
// QObject stored in a model role becomes a dangling C++ pointer when the
Expand Down
26 changes: 24 additions & 2 deletions test/shell.d/bar-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,38 @@ assert(
'bar stays mapped while hidden so revealing it does not rebuild the surface'
)
assert(
/exclusionMode: root\.barHidden \? ExclusionMode\.Ignore : ExclusionMode\.Auto/.test(barSource),
/exclusionMode: root\.barHidden \? ExclusionMode\.Ignore : ExclusionMode\.Normal/.test(barSource),
'a hidden bar reserves no space for itself'
)
for (const edge of ['top', 'bottom', 'left', 'right']) {
assert(
new RegExp(`${edge}: root\\.barHidden && root\\.position === "${edge}" \\? -root\\.barSize : 0`).test(barSource),
new RegExp(`${edge}: root\\.barHidden && root\\.position === "${edge}" \\? -root\\.windowExtent : 0`).test(barSource),
`a hidden bar parks past the ${edge} edge`
)
}

// A floating bar insets its card by one Hyprland gaps_out (Style.gapsOut is
// half of it) and reserves only the space it covers.
assert(/floatGap: floating && !windowGapsOff \? \(Style\.gapsOut > 0 \? Style\.gapsOut \* 2 : lastGap\) : 0/.test(barSource), 'a floating bar insets by one Hyprland gaps_out')
assert(/exclusiveZone: root\.barExtent/.test(barSource), 'the bar reserves its card plus the floating gap')
// Resizing a layer surface can show one stale, stretched frame, so a gap
// change (window-gaps toggle) must only move the card inside a window of
// fixed size, never resize the window itself.
assert(/implicitHeight: root\.vertical \? 0 : root\.windowExtent/.test(barSource), 'the bar window height does not follow the animated gap')
assert(/implicitWidth: root\.vertical \? root\.windowExtent : 0/.test(barSource), 'the bar window width does not follow the animated gap')
assert(/windowExtent: barSize \+ \(floating \? Math\.max\(lastGap, floatGap\) : 0\)/.test(barSource), 'a floating bar window keeps its size when gaps turn off')
assert(/mask: Region \{ item: barSurface \}/.test(barSource), 'the floating gap passes clicks through to the desktop')
assert(/toggles\/hypr\/window-no-gaps\.lua/.test(barSource), 'the bar follows the window-gaps toggle without waiting for Style')
assert(/floating = config\.floating === true/.test(barSource), 'the bar reads bar.floating from shell.json')
// The last real gap is captured at startup, not bound, so the first window-gaps
// toggle starts from the live value; a gaps_out of 0 only counts as real while
// the toggle flag is off.
assert(/property int lastGap: 0/.test(barSource) && /lastGap = Style\.gapsOut \* 2/.test(barSource), 'the last gap is captured at startup instead of bound')
assert(/onGapsOutChanged\(\) \{ if \(Style\.gapsOut > 0 \|\| !root\.windowGapsOff\) root\.lastGap/.test(barSource), 'a toggled-off gap is not remembered as the last real gap')
// Toasts clear a floating bar's full extent, not just its size plus one gap.
const notificationsSource = fs.readFileSync(root + '/shell/plugins/notifications/Service.qml', 'utf8')
assert(/barClearance: Math\.max\(liveBarExtent, liveBarSize \+ Style\.gapsOut\)/.test(notificationsSource), 'toasts clear a floating bar')

// The center section declares two arrangements and shows one; the hidden one
// must not build its modules or every center widget exists twice.
const moduleList = barSource.slice(barSource.indexOf('component ModuleList'), barSource.indexOf('component ModuleSlot'))
Expand Down
Loading