diff options
-rw-r--r-- | pkgs/astal/src/launcher.lua | 10 | ||||
-rw-r--r-- | pkgs/astal/src/shell.lua | 13 | ||||
-rw-r--r-- | pkgs/astal/src/widget/launcher.lua | 16 |
3 files changed, 28 insertions, 11 deletions
diff --git a/pkgs/astal/src/launcher.lua b/pkgs/astal/src/launcher.lua index e645ac4..75d9d72 100644 --- a/pkgs/astal/src/launcher.lua +++ b/pkgs/astal/src/launcher.lua @@ -1,10 +1,12 @@ local App = require("astal.gtk3.app") local lib = require("lib") -local Launcher = require("widget.launcher") - App:start({ - instance_name = "launcher", css = lib.src("main.css"), - main = Launcher, + main = function() + error("must start astal-shell first") + end, + client = function(req) + req("launcher") + end, }) diff --git a/pkgs/astal/src/shell.lua b/pkgs/astal/src/shell.lua index c370349..4baede7 100644 --- a/pkgs/astal/src/shell.lua +++ b/pkgs/astal/src/shell.lua @@ -1,12 +1,15 @@ local App = require("astal.gtk3.app") local lib = require("lib") +local Variable = require("astal").Variable local Bar = require("widget.bar") local Corners = require("widget.corners") local Deck = require("widget.deck") +local Launcher = require("widget.launcher") + +local launcher_visible App:start({ - instance_name = "shell", css = lib.src("main.css"), main = function() for _, mon in pairs(App.monitors) do @@ -14,5 +17,13 @@ App:start({ Corners(mon) Deck(mon) end + launcher_visible = Launcher() + end, + request_handler = function(req, res) + if req == "launcher" then + launcher_visible:set(true) + return res("opening launcher") + end + res("unknown command") end, }) diff --git a/pkgs/astal/src/widget/launcher.lua b/pkgs/astal/src/widget/launcher.lua index cbac6c3..ac69d65 100644 --- a/pkgs/astal/src/widget/launcher.lua +++ b/pkgs/astal/src/widget/launcher.lua @@ -15,6 +15,7 @@ local FlowBoxChild = astalify(Gtk.FlowBoxChild) local apps = Apps.Apps() local text = Variable("") +local visible = Variable(false) local list = text(function(text) return lib.slice(apps:exact_query(text), 0, MAX_ENTRIES) end) @@ -23,13 +24,13 @@ function on_show() text:set("") end -function close() - App:quit() +function hide() + visible:set(false) end function on_key_press(self, event) if event.keyval == Gdk.KEY_Escape then - close() + hide() end end @@ -37,7 +38,7 @@ function on_enter() local found = apps:exact_query(text:get())[1] if found then found:launch() - close() + hide() end end @@ -47,7 +48,7 @@ function Application(app) class_name = "app", on_clicked = function() app:launch() - close() + hide() end, Widget.Box({ halign = "CENTER", @@ -100,7 +101,7 @@ end return function() local Anchor = astal.require('Astal').WindowAnchor - return Widget.Window({ + Widget.Window({ class_name = "launcher", anchor = Anchor.TOP + Anchor.BOTTOM + Anchor.LEFT + Anchor.RIGHT, exclusivity = "EXCLUSIVE", @@ -108,6 +109,9 @@ return function() application = App, on_show = on_show, on_key_press_event = on_key_press, + visible = visible(), Launcher(), }) + + return visible end |