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
15 changes: 10 additions & 5 deletions bin/omarchy-bar
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ Usage: omarchy bar <command> [args...]

Placement:
--section <section> Target section: left, centerBegin,
center, centerEnd, tray, or right;
tray is the tray's drawer
center, centerEnd, tray, right, or
drawer:<id>; tray is the tray's
drawer, drawer:<id> a drawer's
--index <n> Target index
--before <id> Insert before a widget
--after <id> Insert after a widget
Expand Down Expand Up @@ -68,8 +69,8 @@ bar_option_exists() {
}

validate_section() {
[[ $1 =~ ^(left|centerBegin|center|centerEnd|tray|right)$ ]] ||
fail "section must be left, centerBegin, center, centerEnd, tray, or right"
[[ $1 =~ ^(left|centerBegin|center|centerEnd|tray|right|drawer:[A-Za-z0-9_.-]{1,64})$ ]] ||
fail "section must be left, centerBegin, center, centerEnd, tray, right, or drawer:<id>"
}

validate_index() {
Expand Down Expand Up @@ -446,7 +447,11 @@ cmd_get() {
(( $# == 2 )) || fail "get takes a widget id and a setting key"

jq -e -r --arg id "$id" --arg key "$key" '
first(.bar.layout[]?[]? | select(.id == $id) | .[$key] | select(. != null))
first(.bar.layout
# Drawers count only while their entry is on the bar itself, as in the shell.
| [(.left, .centerBegin, .center, .centerEnd, .right) | arrays | .[] | select(type == "object" and .type == "drawer") | .id] as $drawers
| (.left, .centerBegin, .center, .centerEnd, .right, .tray, ($drawers[] as $drawer | .drawers[$drawer]?)) | arrays | .[]
| select(type == "object" and .id == $id) | .[$key] | select(. != null))
| if type == "string" then . else tojson end
' "$(source_file)" 2>/dev/null || exit 1
}
Expand Down
4 changes: 4 additions & 0 deletions default/i18n/en/shell.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@
"bar.allowNotifications": "Allow Notifications",
"bar.dayLight": "Day Light",
"bar.disablePasswordlessSudo": "Disable Passwordless Sudo",
"bar.drawerWidgets": {
"one": "%1 widget",
"other": "%1 widgets"
},
"bar.microphoneInUse": "Microphone in use",
"bar.microphoneLive": "Microphone live",
"bar.microphoneMuted": "Microphone muted",
Expand Down
15 changes: 14 additions & 1 deletion docs/omarchy-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ Rules:
The sections are `left`, `centerBegin`, `center`, `centerEnd`, `tray`
and `right`. `tray` is
drawn inside the tray's drawer, after the app icons, and shows only while
`omarchy.tray` is on the bar; it cannot hold the tray itself.
`omarchy.tray` is on the bar; it cannot hold the tray itself. Each drawer on
the bar adds a section `drawer:<id>`, kept under `bar.layout.drawers.<id>`
(see *Drawers* below).
Comment on lines +175 to +177

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 Added prose breaks Markdown style

The added drawer description is hard-wrapped across several Markdown lines. AGENTS.md requires full lines in docs/, with breaks only at structural boundaries.

Keep the added prose on one line rather than extending the existing hard wrapping. This repository requirement must be satisfied before merging.

Suggested change
`omarchy.tray` is on the bar; it cannot hold the tray itself. Each drawer on
the bar adds a section `drawer:<id>`, kept under `bar.layout.drawers.<id>`
(see *Drawers* below).
`omarchy.tray` is on the bar; it cannot hold the tray itself. Each drawer on the bar adds a section `drawer:<id>`, kept under `bar.layout.drawers.<id>` (see *Drawers* below).

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

3. Settings are inline on the entry. No `config:` sub-object, no
merge layers.
4. Built-in bar widget ids are namespaced (`omarchy.clock`, `omarchy.audio`, …).
Expand Down Expand Up @@ -425,6 +427,17 @@ If a full plugin is overkill, declare a one-off module inline in

Output is plain text or Waybar-style JSON (`{ "text": ..., "tooltip": ..., "class": ... }`).

A drawer holds widgets of its own, folded away behind one button, the way the tray's drawer holds the tray section:

```json
"right": [ { "id": "home", "type": "drawer", "name": "Home", "icon": "󰋜", "color": "#f38d70" } ],
"drawers": { "home": [ { "id": "omarchy.bluetooth" }, { "id": "omarchy.audio" } ] }
```

The id names the drawer and its section, `drawer:home`; it is letters, digits, `.`, `_` and `-`. A drawer goes in `left`, `centerBegin`, `center`, `centerEnd` or `right`, never in the tray section or another drawer, and neither does the tray. `name` is the tooltip, `icon` the button's glyph and `color` (`#rrggbb`) tints the button and the line under the open drawer. It starts closed; `"collapsed": false` starts it open, and `"reveal": "hover"` opens it while the pointer is over it instead of on a click.

While a widget is dragged along the bar every drawer opens, and a drop anywhere over a drawer, its button included, goes into it; a drop on the neighbouring widget lands beside it. A panel open from a widget in a drawer keeps the drawer open. A drawer opens away from the edge its section keeps to, as the tray does: toward the middle of the bar on the right, outward beside the center box. Widgets under `drawers` whose drawer is no longer on the bar are not drawn and count as off the bar.

For a custom QML widget:

```json
Expand Down
3 changes: 3 additions & 0 deletions manual/05-the-top-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ The middle of the bar is a box: whatever is in it stays centered as one group, a

A widget you want around but not always in view can go in the tray's drawer: drag it onto the tray, and the drawer opens to take it. It sits there after the app icons, shows up whenever the drawer does, and keeps its drawer open while its panel is up. Drag it back out onto the bar to put it back.

For more than one such place, add drawers of your own: a button on the bar that folds a group of widgets away, like Home for the lights and the heating. Each drawer is one entry in `~/.config/omarchy/shell.json` with `"type": "drawer"`, a name and an icon; while you drag a widget along the bar every drawer opens, so you can drop it into one. A click on the drawer's button opens and closes it.

If you'd rather pick from a menu, **Appearance → Menu Bar** has the position, and **Bar Background** picks how the bar is drawn: **Opaque Bar**, **Glassy Bar** (see-through, with what's behind it blurred), or **Clear Bar**.

The same things have commands, which is what you want for a [dotfiles](31-dotfiles.md) setup:
Expand All @@ -97,6 +99,7 @@ omarchy bar position bottom
omarchy bar background glassy # opaque, glassy, none, or cycle
omarchy bar move omarchy.weather --section centerBegin --index 0
omarchy bar move omarchy.bluetooth --section tray # into the tray's drawer
omarchy bar move omarchy.bluetooth --section drawer:home # into the drawer "home"
omarchy bar set omarchy.clock format "HH:mm"
omarchy bar defaults # back to the shipped layout
```
Expand Down
132 changes: 132 additions & 0 deletions shell/Commons/BarLayout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// Sections of the bar layout.
//
// left, centerBegin, center, centerEnd and right are the bar itself, as
// Util.barSections runs them. tray is drawn inside the tray's drawer. A
// drawer is a bar entry with "type": "drawer" and an id of its own; its
// widgets are a section too, named drawer:<id> and kept under
// layout.drawers[<id>]. Drawers sit on the bar itself, never inside the tray
// or another drawer, so only the bar's own sections can name one.

var BAR_SECTIONS = ["left", "centerBegin", "center", "centerEnd", "right"]
var BASE_SECTIONS = ["left", "centerBegin", "center", "centerEnd", "right", "tray"]
var DRAWER_PREFIX = "drawer:"

function isPlainObject(value) {
return value !== null && typeof value === "object" && !Array.isArray(value)
}

function entryId(entry) {
if (typeof entry === "string") return entry
if (isPlainObject(entry) && entry.id !== undefined && entry.id !== null) return String(entry.id)
return ""
}

function validDrawerId(id) {
return /^[A-Za-z0-9_.-]{1,64}$/.test(String(id || ""))
}

function isDrawerEntry(entry) {
return isPlainObject(entry) && entry.type === "drawer" && validDrawerId(entryId(entry))
}

function drawerSection(id) {
return validDrawerId(id) ? DRAWER_PREFIX + String(id) : ""
}

function drawerIdOf(section) {
var name = String(section || "")
if (name.indexOf(DRAWER_PREFIX) !== 0) return ""
var id = name.slice(DRAWER_PREFIX.length)
return validDrawerId(id) ? id : ""
}

// The sections drawn inside another widget: the tray's and every drawer's.
function isHostedSection(section) {
return section === "tray" || drawerIdOf(section) !== ""
}

function isSectionName(section) {
return BASE_SECTIONS.indexOf(String(section || "")) !== -1 || drawerIdOf(section) !== ""
}

// The ids of the drawers placed on the bar, in bar order, each once.
function drawerIds(layout) {
var ids = []
if (!isPlainObject(layout)) return ids
for (var s = 0; s < BAR_SECTIONS.length; s++) {
var entries = layout[BAR_SECTIONS[s]]
if (!Array.isArray(entries)) continue
for (var i = 0; i < entries.length; i++) {
if (!isDrawerEntry(entries[i])) continue
var id = entryId(entries[i])
if (ids.indexOf(id) === -1) ids.push(id)
}
}
return ids
}

// Every section a widget can be in: the fixed ones, then one per drawer
// on the bar. A drawers[] list whose drawer is gone is not a section: its
// widgets are not drawn and not counted as on the bar.
function sectionNames(layout) {
var names = BASE_SECTIONS.slice()
var ids = drawerIds(layout)
for (var i = 0; i < ids.length; i++) names.push(DRAWER_PREFIX + ids[i])
return names
}

// The entries of one section, or null when the layout has none.
function sectionEntries(layout, section) {
if (!isPlainObject(layout)) return null
var id = drawerIdOf(section)
if (id) {
var drawers = layout.drawers
return isPlainObject(drawers) && Array.isArray(drawers[id]) ? drawers[id] : null
}
if (BASE_SECTIONS.indexOf(String(section || "")) === -1) return null
return Array.isArray(layout[section]) ? layout[section] : null
}

// The entries of one section in a layout being edited, created when missing.
// Returns null for a name that is no section.
function ensureSection(layout, section) {
if (!isPlainObject(layout)) return null
var id = drawerIdOf(section)
if (id) {
if (!isPlainObject(layout.drawers)) layout.drawers = {}
if (!Array.isArray(layout.drawers[id])) layout.drawers[id] = []
return layout.drawers[id]
}
if (BASE_SECTIONS.indexOf(String(section || "")) === -1) return null
if (!Array.isArray(layout[section])) layout[section] = []
return layout[section]
}

// Every section's entries as one plain object keyed by section name.
function sections(layout) {
var out = {}
var names = sectionNames(layout)
for (var i = 0; i < names.length; i++) {
var entries = sectionEntries(layout, names[i])
out[names[i]] = Array.isArray(entries) ? entries : []
}
return out
}

if (typeof module !== "undefined") {
module.exports = {
BAR_SECTIONS: BAR_SECTIONS,
BASE_SECTIONS: BASE_SECTIONS,
validDrawerId: validDrawerId,
isDrawerEntry: isDrawerEntry,
drawerSection: drawerSection,
drawerIdOf: drawerIdOf,
isHostedSection: isHostedSection,
isSectionName: isSectionName,
drawerIds: drawerIds,
sectionNames: sectionNames,
sectionEntries: sectionEntries,
ensureSection: ensureSection,
sections: sections
}
}
15 changes: 15 additions & 0 deletions shell/Commons/Util.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pragma Singleton
import Quickshell
import QtQuick
import "BarLayout.js" as BarLayout

// Shared utility helpers used across plugins. Pure functions only — no
// state. Anything stateful belongs on Color, Style, or a service.
Expand Down Expand Up @@ -183,6 +184,20 @@ QtObject {
var out = {}
for (var i = 0; i < barSections.length; i++)
out[barSections[i]] = normalizeLayoutSection(src[barSections[i]])
// Only drawers on the bar keep their widgets; see BarLayout.js.
out.drawers = {}
var ids = BarLayout.drawerIds(out)
for (var d = 0; d < ids.length; d++)
out.drawers[ids[d]] = normalizeLayoutSection(BarLayout.sectionEntries(src, BarLayout.drawerSection(ids[d])))
return out
}

// Bar layout sections, drawers included: see BarLayout.js.
function layoutSectionNames(layout) { return BarLayout.sectionNames(layout) }
function layoutSectionEntries(layout, section) { return BarLayout.sectionEntries(layout, section) }
function ensureLayoutSection(layout, section) { return BarLayout.ensureSection(layout, section) }
function layoutSections(layout) { return BarLayout.sections(layout) }
function isLayoutSection(section) { return BarLayout.isSectionName(section) }
function isHostedLayoutSection(section) { return BarLayout.isHostedSection(section) }
function drawerLayoutSection(id) { return BarLayout.drawerSection(id) }
}
Loading