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
58 changes: 51 additions & 7 deletions Launcher.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Quickshell.Io
import Quickshell.Hyprland
import qs.Commons
import "ui"
import "core/RootSearch.js" as RootSearch

Item {
id: root
Expand Down Expand Up @@ -35,10 +36,16 @@ Item {
}


function show() {
if (root.opened) return
if (root.shell && root.shell.summon(root.pluginId, "{}")) return
root.open("{}")
// filter: a RootSearch.FILTERS id to open on (omacast:toggle-<filter>);
// "" keeps whatever the launcher was left on.
function show(filter) {
if (root.opened) {
if (filter) launcher.prepare({ filter: filter })
return
}
var payload = JSON.stringify(filter ? { filter: filter } : {})
if (root.shell && root.shell.summon(root.pluginId, payload)) return
root.open(payload)
}

function hide() {
Expand All @@ -50,9 +57,11 @@ Item {
root.close()
}

function toggle() {
if (root.opened) root.hide()
else root.show()
// A filtered toggle closes only when that filter's root is on screen;
// otherwise it switches the open launcher to it.
function toggle(filter) {
if (root.opened && (!filter || (launcher.atRoot && launcher.rootFilter === filter))) root.hide()
else root.show(filter)
}

// A command's own hotkey toggles it: a second press while its view is on
Expand Down Expand Up @@ -110,6 +119,29 @@ Item {
onPressed: root.toggle()
}

// Open on one root filter: hl.dsp.global("omacast:toggle-applications"),
// "omacast:toggle-commands" or "omacast:toggle-all".
GlobalShortcut {
appid: "omacast"
name: "toggle-all"
description: "Toggle omacast on All"
onPressed: root.toggle("all")
}

GlobalShortcut {
appid: "omacast"
name: "toggle-applications"
description: "Toggle omacast on Applications"
onPressed: root.toggle("applications")
}

GlobalShortcut {
appid: "omacast"
name: "toggle-commands"
description: "Toggle omacast on Commands"
onPressed: root.toggle("commands")
}

// Toggles Switch Theme directly: hl.dsp.global("omacast:theme").
GlobalShortcut {
appid: "omacast"
Expand Down Expand Up @@ -147,6 +179,18 @@ Item {
return "shown"
}

function toggleFilter(filter: string): string {
if (!RootSearch.isFilter(filter)) return "unknown-filter"
root.toggle(filter)
return root.opened ? "shown" : "hidden"
}

function showFilter(filter: string): string {
if (!RootSearch.isFilter(filter)) return "unknown-filter"
root.show(filter)
return "shown"
}

function hide(): string {
root.hide()
return "hidden"
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ disabled command, use Undo on the toast (`Ctrl+T`), or remove its `"enabled": fa

```sh
omacast toggle | show | hide
omacast toggle applications # open on one root filter: all, applications or commands
omacast run <commandId> # e.g. builtin:emoji-picker, app:com.mitchellh.ghostty, omarchy:appearance.theme
omacast call <method> [json] # call any backend method; omacast call system.info lists them
omacast doctor # checks the shell, IPC, the backend, QML errors in the shell log, and the hotkey
Expand All @@ -293,9 +294,19 @@ omacast build-search # build the optional search helper (needs cargo)
omacast install | uninstall
```

Global shortcuts for Hyprland binds: `omacast:toggle`, `omacast:clipboard`, `omacast:emoji`, `omacast:theme`.
Global shortcuts for Hyprland binds: `omacast:toggle`, `omacast:toggle-all`, `omacast:toggle-applications`,
`omacast:toggle-commands`, `omacast:clipboard`, `omacast:emoji`, `omacast:theme`.
Bind them with `submap_universal = true` so they still work while omacast is open.

The `toggle-<filter>` shortcuts open the launcher on that root filter, the way Omarchy splits
Super+Space (menu) and Super+Alt+Space (apps). Pressed while omacast shows another filter or view,
they switch to it; pressed again, they close it. Plain `omacast:toggle` keeps the filter you left.

```lua
o.bind("ALT + SPACE", "omacast", hl.dsp.global("omacast:toggle-all"), { submap_universal = true })
o.bind("SUPER + ALT + SPACE", "omacast apps", hl.dsp.global("omacast:toggle-applications"), { submap_universal = true })
```

### Dependencies and network access

omacast needs only what Omarchy ships: `omarchy-shell` (Quickshell), Hyprland, bash, `jq` and `socat`.
Expand Down
15 changes: 12 additions & 3 deletions bin/omacast
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ usage() {
Usage: omacast <command> [args]

Launcher
toggle Show or hide the launcher
show | hide Show or hide it
toggle [filter] Show or hide the launcher; filter opens it on
all, applications or commands
show [filter] | hide Show or hide it
run <commandId> Open a command directly
call <method> [json] Call a backend method, e.g. omacast call system.info

Expand Down Expand Up @@ -355,7 +356,15 @@ cmd_doctor() {
}

case "${1:-}" in
toggle|show|hide) need_shell; ipc "$1" >/dev/null ;;
hide) need_shell; ipc hide >/dev/null ;;
toggle|show)
need_shell
if [[ -n ${2:-} ]]; then
[[ $(ipc "${1}Filter" "$2") != unknown-filter ]] || die "unknown filter: $2 (all, applications or commands)"
else
ipc "$1" >/dev/null
fi
;;
run) need_shell; [[ -n ${2:-} ]] || die "usage: omacast run <commandId>"; ipc run "$2" ;;
call) need_shell; [[ -n ${2:-} ]] || die "usage: omacast call <method> [json]"; ipc call "$2" "${3:-}" ;;
ping) need_shell; ipc ping ;;
Expand Down
5 changes: 5 additions & 0 deletions core/RootSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ var FILTERS = [
{ id: "commands", title: "Commands" }
]

function isFilter(id) {
return FILTERS.some(function(f) { return f.id === id })
}

function passesFilter(candidate, filter) {
if (!filter || filter === "all") return true
return (candidate.type === "application") === (filter === "applications")
Expand Down Expand Up @@ -510,6 +514,7 @@ if (typeof module !== "undefined") {
FALLBACKS: FALLBACKS,
BUILTINS: BUILTINS,
FILTERS: FILTERS,
isFilter: isFilter,
fillArguments: fillArguments,
missingArgument: missingArgument,
confirmationFor: confirmationFor,
Expand Down
5 changes: 5 additions & 0 deletions tests/rootsearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ test("the root filter narrows by type and drops calculator and fallbacks", () =>
assert.deepEqual(RS.FILTERS.map((f) => f.id), ["all", "applications", "commands"])
})

test("isFilter accepts only the root filter ids", () => {
for (const f of RS.FILTERS) assert.equal(RS.isFilter(f.id), true)
for (const bad of ["", "apps", "All", undefined, null, 1]) assert.equal(RS.isFilter(bad), false)
})

test("power commands and delete-all ask for confirmation", () => {
assert.equal(RS.confirmationFor("omarchy:system.shutdown", "open").primary, "Shut Down")
assert.equal(RS.confirmationFor("omarchy:system.shutdown", "copy-command"), null)
Expand Down
15 changes: 11 additions & 4 deletions ui/LauncherWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,18 @@ PanelWindow {

function prepare(payload) {
popTimer.stop()
if (typeof payload.query === "string") window.query = payload.query
// A filtered hotkey (omacast:toggle-<filter>) lands on an empty root with
// that filter, wherever the launcher was left.
var filter = RootSearch.isFilter(payload.filter) ? payload.filter : ""
var reset = filter !== "" && !(window.atRoot && window.query === "" && window.rootFilter === filter)
if (reset) window.popToRoot(filter)
else if (typeof payload.query === "string") window.query = payload.query
window.closePopups()
window.historyIndex = -1
// Hiding pops to root and rebuilds, so an unchanged root list is reused
// and the card shows on the next frame instead of after a search.
if (typeof payload.query === "string" || window.rootKey() !== window.builtRootKey) window.rebuild(true)
if (reset) {} // popToRoot already rebuilt
else if (typeof payload.query === "string" || window.rootKey() !== window.builtRootKey) window.rebuild(true)
else window.select(window.nextSelectable(-1, 1), 0)
Qt.callLater(function() { keyCatcher.forceActiveFocus() })
}
Expand Down Expand Up @@ -275,10 +281,11 @@ PanelWindow {
onTriggered: window.popToRoot()
}

function popToRoot() {
// filter: a RootSearch.FILTERS id to land on; "all" when omitted.
function popToRoot(filter) {
window.stack = [{ kind: "root", title: "omacast", query: "" }]
window.query = ""
window.rootFilter = "all"
window.rootFilter = filter || "all"
window.clipboardFilter = "all"
window.rebuild(true)
}
Expand Down