From 5489883e0199632b8aa269ae268739c96c4b272e Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 4 Nov 2024 02:15:18 -0300 Subject: core: smol lua fixes --- lang/lua/astal/binding.lua | 9 ++++---- lang/lua/astal/gtk3/app.lua | 50 +++++++++++++++++----------------------- lang/lua/astal/gtk3/astalify.lua | 4 +--- lang/lua/astal/variable.lua | 12 ++++++---- 4 files changed, 33 insertions(+), 42 deletions(-) diff --git a/lang/lua/astal/binding.lua b/lang/lua/astal/binding.lua index 2944ec4..610f3a6 100644 --- a/lang/lua/astal/binding.lua +++ b/lang/lua/astal/binding.lua @@ -7,7 +7,7 @@ local GObject = lgi.require("GObject", "2.0") ---@field transform_fn function local Binding = {} ----@param emitter table +---@param emitter table | userdata ---@param property? string ---@return Binding function Binding.new(emitter, property) @@ -28,11 +28,11 @@ function Binding:__tostring() return str .. ">" end +---@return any function Binding:get() if self.property ~= nil and GObject.Object:is_type_of(self.emitter) then return self.transform_fn(self.emitter[self.property]) - end - if type(self.emitter.get) == "function" then + elseif type(self.emitter.get) == "function" then return self.transform_fn(self.emitter:get()) end error("can not get: Not a GObject or a Variable " + self) @@ -58,8 +58,7 @@ function Binding:subscribe(callback) return function() GObject.signal_handler_disconnect(self.emitter, id) end - end - if type(self.emitter.subscribe) == "function" then + elseif type(self.emitter.subscribe) == "function" then return self.emitter:subscribe(function() callback(self:get()) end) diff --git a/lang/lua/astal/gtk3/app.lua b/lang/lua/astal/gtk3/app.lua index 7895f69..e0ae65a 100644 --- a/lang/lua/astal/gtk3/app.lua +++ b/lang/lua/astal/gtk3/app.lua @@ -24,30 +24,28 @@ end local app = AstalLua() ----@class StartConfig ----@field icons? string ----@field instance_name? string ----@field gtk_theme? string ----@field icon_theme? string ----@field cursor_theme? string ----@field css? string ----@field hold? boolean ----@field request_handler? fun(msg: string, response: fun(res: any)) ----@field main? fun(...): unknown ----@field client? fun(message: fun(msg: string): string, ...): unknown +--- @alias StartConfig { +--- icons?: string, +--- instance_name?: string, +--- gtk_theme?: string, +--- icon_theme?: string, +--- cursor_theme?: string, +--- css?: string, +--- hold?: boolean, +--- request_handler?: fun(msg: string, response: fun(res: any)), +--- main?: fun(...), +--- client?: fun(message: fun(msg: string): string, ...), +---} ----@param config StartConfig | nil +---@param config? StartConfig function Astal.Application:start(config) - if config == nil then - config = {} - end + config = config or {} - if config.client == nil then - config.client = function() + config.client = config.client + or function() print('Astal instance "' .. app.instance_name .. '" is already running') os.exit(1) end - end if config.hold == nil then config.hold = true @@ -61,17 +59,11 @@ function Astal.Application:start(config) if config.icons then self:add_icons(config.icons) end - if config.instance_name then - self.instance_name = config.instance_name - end - if config.gtk_theme then - self.gtk_theme = config.gtk_theme - end - if config.icon_theme then - self.icon_theme = config.icon_theme - end - if config.cursor_theme then - self.cursor_theme = config.cursor_theme + + for _, key in ipairs({ "instance_name", "gtk_theme", "icon_theme", "cursor_theme" }) do + if config[key] then + self[key] = config[key] + end end app.on_activate = function() diff --git a/lang/lua/astal/gtk3/astalify.lua b/lang/lua/astal/gtk3/astalify.lua index 211a1d4..95faa2c 100644 --- a/lang/lua/astal/gtk3/astalify.lua +++ b/lang/lua/astal/gtk3/astalify.lua @@ -163,9 +163,7 @@ return function(ctor) end return function(tbl) - if tbl == nil then - tbl = {} - end + tbl = tbl or {} local bindings = {} local setup = tbl.setup diff --git a/lang/lua/astal/variable.lua b/lang/lua/astal/variable.lua index 2305a71..f06fd16 100644 --- a/lang/lua/astal/variable.lua +++ b/lang/lua/astal/variable.lua @@ -40,7 +40,7 @@ function Variable.new(value) return variable end ----@param transform? fun(v: any): any +---@param transform? fun(v: any): any ---@return Binding function Variable:__call(transform) if type(transform) == "nil" then @@ -54,10 +54,13 @@ function Variable:__tostring() return "Variable<" .. tostring(self:get()) .. ">" end +---@return any function Variable:get() return self._value end +---@param value any +---@return nil function Variable:set(value) if value ~= self:get() then self._value = value @@ -107,7 +110,6 @@ function Variable:start_watch() end) end - function Variable:stop_poll() if self:is_polling() then self._poll.cancel() @@ -122,7 +124,6 @@ function Variable:stop_watch() self._watch = nil end - function Variable:drop() self.variable.emit_dropped() end @@ -180,8 +181,9 @@ end ---@param exec string | string[] ---@param transform? fun(next: any, prev: any): any +---@return Variable function Variable:watch(exec, transform) - transform = transform or function (next) + transform = transform or function(next) return next end @@ -272,4 +274,4 @@ return setmetatable(Variable, { __call = function(_, v) return Variable.new(v) end, -}) \ No newline at end of file +}) -- cgit v1.2.3 From b697dd8e1d936d6a789c73fbacfc65698d2dab39 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 4 Nov 2024 02:17:00 -0300 Subject: core: smol lua fixes --- lang/lua/astal/binding.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lang/lua/astal/binding.lua b/lang/lua/astal/binding.lua index 610f3a6..81d2177 100644 --- a/lang/lua/astal/binding.lua +++ b/lang/lua/astal/binding.lua @@ -34,8 +34,9 @@ function Binding:get() return self.transform_fn(self.emitter[self.property]) elseif type(self.emitter.get) == "function" then return self.transform_fn(self.emitter:get()) + else + error("can not get: Not a GObject or a Variable " + self) end - error("can not get: Not a GObject or a Variable " + self) end ---@param transform fun(value: any): any @@ -62,8 +63,9 @@ function Binding:subscribe(callback) return self.emitter:subscribe(function() callback(self:get()) end) + else + error("can not subscribe: Not a GObject or a Variable " + self) end - error("can not subscribe: Not a GObject or a Variable " + self) end Binding.__index = Binding -- cgit v1.2.3 From f02e58342c61b4ae312344be2805aa019d65541d Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 5 Nov 2024 15:53:23 -0300 Subject: core: typing for lua --- lang/lua/astal/binding.lua | 9 +++++++-- lang/lua/astal/gtk3/widget.lua | 2 ++ lang/lua/astal/variable.lua | 9 +++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lang/lua/astal/binding.lua b/lang/lua/astal/binding.lua index 81d2177..9708ef8 100644 --- a/lang/lua/astal/binding.lua +++ b/lang/lua/astal/binding.lua @@ -5,7 +5,9 @@ local GObject = lgi.require("GObject", "2.0") ---@field emitter table|Variable ---@field property? string ---@field transform_fn function +---@overload fun(emitter: table | userdata, property?: string): Binding local Binding = {} +Binding.__index = Binding ---@param emitter table | userdata ---@param property? string @@ -68,5 +70,8 @@ function Binding:subscribe(callback) end end -Binding.__index = Binding -return Binding +return setmetatable(Binding, { + __call = function(_, emitter, prop) + return Binding.new(emitter, prop) + end, +}) diff --git a/lang/lua/astal/gtk3/widget.lua b/lang/lua/astal/gtk3/widget.lua index beaad6c..1a4454e 100644 --- a/lang/lua/astal/gtk3/widget.lua +++ b/lang/lua/astal/gtk3/widget.lua @@ -3,7 +3,9 @@ local Astal = lgi.require("Astal", "3.0") local Gtk = lgi.require("Gtk", "3.0") local astalify = require("astal.gtk3.astalify") +---@overload fun(ctor: any): function local Widget = { + ---@overload fun(ctor: any): function astalify = astalify, Box = astalify(Astal.Box), Button = astalify(Astal.Button), diff --git a/lang/lua/astal/variable.lua b/lang/lua/astal/variable.lua index f06fd16..7a0d712 100644 --- a/lang/lua/astal/variable.lua +++ b/lang/lua/astal/variable.lua @@ -17,6 +17,7 @@ local Process = require("astal.process") ---@field private poll_fn? function ---@field private watch_transform? fun(next: any, prev: any): any ---@field private watch_exec? string[] | string +---@overload fun(value?: any): Variable local Variable = {} Variable.__index = Variable @@ -24,19 +25,19 @@ Variable.__index = Variable ---@return Variable function Variable.new(value) local v = Astal.VariableBase() - local variable = setmetatable({ - variable = v, - _value = value, - }, Variable) + local variable = setmetatable({ variable = v, _value = value }, Variable) + v.on_dropped = function() variable:stop_watch() variable:stop_poll() end + v.on_error = function(_, err) if variable.err_handler then variable.err_handler(err) end end + return variable end -- cgit v1.2.3 From b1da91dcced3803c764d22d4da1a49c23d7e97ed Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 5 Nov 2024 16:13:49 -0300 Subject: oops --- lang/lua/astal/binding.lua | 4 ++-- lang/lua/astal/gtk3/widget.lua | 1 - lang/lua/astal/init.lua | 1 + lang/lua/astal/variable.lua | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lang/lua/astal/binding.lua b/lang/lua/astal/binding.lua index 9708ef8..dd2df7f 100644 --- a/lang/lua/astal/binding.lua +++ b/lang/lua/astal/binding.lua @@ -2,14 +2,14 @@ local lgi = require("lgi") local GObject = lgi.require("GObject", "2.0") ---@class Binding ----@field emitter table|Variable +---@field emitter table | Variable | userdata ---@field property? string ---@field transform_fn function ---@overload fun(emitter: table | userdata, property?: string): Binding local Binding = {} Binding.__index = Binding ----@param emitter table | userdata +---@param emitter table | Variable | userdata ---@param property? string ---@return Binding function Binding.new(emitter, property) diff --git a/lang/lua/astal/gtk3/widget.lua b/lang/lua/astal/gtk3/widget.lua index 1a4454e..c8857e7 100644 --- a/lang/lua/astal/gtk3/widget.lua +++ b/lang/lua/astal/gtk3/widget.lua @@ -5,7 +5,6 @@ local astalify = require("astal.gtk3.astalify") ---@overload fun(ctor: any): function local Widget = { - ---@overload fun(ctor: any): function astalify = astalify, Box = astalify(Astal.Box), Button = astalify(Astal.Button), diff --git a/lang/lua/astal/init.lua b/lang/lua/astal/init.lua index 5630ba4..190994a 100644 --- a/lang/lua/astal/init.lua +++ b/lang/lua/astal/init.lua @@ -7,6 +7,7 @@ local Binding = require("astal.binding") local File = require("astal.file") local Process = require("astal.process") local Time = require("astal.time") +---@type Variable | fun(v: any): Variable local Variable = require("astal.variable") return { diff --git a/lang/lua/astal/variable.lua b/lang/lua/astal/variable.lua index 7a0d712..9f67715 100644 --- a/lang/lua/astal/variable.lua +++ b/lang/lua/astal/variable.lua @@ -17,7 +17,7 @@ local Process = require("astal.process") ---@field private poll_fn? function ---@field private watch_transform? fun(next: any, prev: any): any ---@field private watch_exec? string[] | string ----@overload fun(value?: any): Variable +---@overload fun(transform?: fun(v: any): any): Binding local Variable = {} Variable.__index = Variable -- cgit v1.2.3 From 588c349bd04833a68c982ea5437f034bad98ef6b Mon Sep 17 00:00:00 2001 From: toino Date: Thu, 7 Nov 2024 20:31:07 +0100 Subject: fix: network manager device state values --- lib/network/network.vala | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/network/network.vala b/lib/network/network.vala index fb7efa0..96e19c8 100644 --- a/lib/network/network.vala +++ b/lib/network/network.vala @@ -149,19 +149,19 @@ public enum AstalNetwork.Connectivity { // alias for NM.DeviceState public enum AstalNetwork.DeviceState { - UNKNOWN, - UNMANAGED, - UNAVAILABLE, - DISCONNECTED, - PREPARE, - CONFIG, - NEED_AUTH, - IP_CONFIG, - IP_CHECK, - SECONDARIES, - ACTIVATED, - DEACTIVATING, - FAILED; + UNKNOWN = 0, + UNMANAGED = 10, + UNAVAILABLE = 20, + DISCONNECTED = 30, + PREPARE = 40, + CONFIG = 50, + NEED_AUTH = 60, + IP_CONFIG = 70, + IP_CHECK = 80, + SECONDARIES = 90, + ACTIVATED = 100, + DEACTIVATING = 110, + FAILED = 120; public string to_string() { switch (this) { -- cgit v1.2.3 From 44710fb30105f5e76fc84845e9379787440f3c4c Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 8 Nov 2024 00:01:57 -0300 Subject: stoopid zed --- lang/lua/astal/gtk3/app.lua | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lang/lua/astal/gtk3/app.lua b/lang/lua/astal/gtk3/app.lua index e0ae65a..58564ce 100644 --- a/lang/lua/astal/gtk3/app.lua +++ b/lang/lua/astal/gtk3/app.lua @@ -24,18 +24,17 @@ end local app = AstalLua() ---- @alias StartConfig { ---- icons?: string, ---- instance_name?: string, ---- gtk_theme?: string, ---- icon_theme?: string, ---- cursor_theme?: string, ---- css?: string, ---- hold?: boolean, ---- request_handler?: fun(msg: string, response: fun(res: any)), ---- main?: fun(...), ---- client?: fun(message: fun(msg: string): string, ...), ----} +---@class StartConfig +---@field icons string? +---@field instance_name string? +---@field gtk_theme string? +---@field icon_theme string? +---@field cursor_theme string? +---@field css string? +---@field hold boolean? +---@field request_handler fun(msg: string, response: fun(res: any)): nil +---@field main fun(...): nil +---@field client fun(message: fun(msg: string): string, ...): nil ---@param config? StartConfig function Astal.Application:start(config) -- cgit v1.2.3 From 321350f7d52a65afae095cd5b874c1866084fb64 Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 8 Nov 2024 18:31:49 +0000 Subject: docs: swap install and usage sections on lib pages --- docs/guide/libraries/apps.md | 68 +++++++++++++------------- docs/guide/libraries/auth.md | 90 +++++++++++++++++----------------- docs/guide/libraries/battery.md | 78 ++++++++++++++--------------- docs/guide/libraries/bluetooth.md | 78 ++++++++++++++--------------- docs/guide/libraries/cava.md | 80 +++++++++++++++--------------- docs/guide/libraries/greet.md | 78 ++++++++++++++--------------- docs/guide/libraries/hyprland.md | 68 +++++++++++++------------- docs/guide/libraries/mpris.md | 92 +++++++++++++++++------------------ docs/guide/libraries/network.md | 68 +++++++++++++------------- docs/guide/libraries/notifd.md | 68 +++++++++++++------------- docs/guide/libraries/powerprofiles.md | 78 ++++++++++++++--------------- docs/guide/libraries/references.md | 2 + docs/guide/libraries/river.md | 68 +++++++++++++------------- docs/guide/libraries/tray.md | 68 +++++++++++++------------- docs/guide/libraries/wireplumber.md | 68 +++++++++++++------------- 15 files changed, 527 insertions(+), 525 deletions(-) diff --git a/docs/guide/libraries/apps.md b/docs/guide/libraries/apps.md index 1871d18..f1748db 100644 --- a/docs/guide/libraries/apps.md +++ b/docs/guide/libraries/apps.md @@ -3,40 +3,6 @@ Library and CLI tool for querying and launching applications that have a corresponding `.desktop` file. -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala json-glib gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac libjson-glib-dev gobject-introspection -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/apps -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Apps reference](https://aylur.github.io/libastal/apps). @@ -106,3 +72,37 @@ foreach (var app in apps.fuzzy_query("firefox")) { ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala json-glib gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac libjson-glib-dev gobject-introspection +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/apps +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/auth.md b/docs/guide/libraries/auth.md index d5f0a49..b52e38a 100644 --- a/docs/guide/libraries/auth.md +++ b/docs/guide/libraries/auth.md @@ -2,51 +2,6 @@ Library and CLI tool for authentication using [pam](https://github.com/linux-pam/linux-pam). -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson pam gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson pam-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -# Not yet documented -``` - -::: - -::: warning On NixOS you have to add `astal-auth` to `security.pam`. -::: code-group - -```nix [configuration.nix] -{ - security.pam.services.astal-auth = {} -} -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/auth -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Auth reference](https://aylur.github.io/libastal/auth). @@ -105,3 +60,48 @@ end) ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson pam gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson pam-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +# Not yet documented +``` + +::: + +::: warning On NixOS you have to add `astal-auth` to `security.pam`. +::: code-group + +```nix [configuration.nix] +{ + security.pam.services.astal-auth = {} +} +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/auth +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/battery.md b/docs/guide/libraries/battery.md index 56f955c..7e6fe24 100644 --- a/docs/guide/libraries/battery.md +++ b/docs/guide/libraries/battery.md @@ -2,45 +2,6 @@ Library and CLI tool for monitoring [upowerd](https://upower.freedesktop.org/) devices. -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala json-glib gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac libjson-glib-dev gobject-introspection -``` - -::: - -::: info -Although UPower is not a direct build dependency, -it should be self-explanatory that the daemon is required to be available at runtime. -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/battery -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Battery reference](https://aylur.github.io/libastal/battery). @@ -84,3 +45,42 @@ print(battery.percentage) ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala json-glib gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac libjson-glib-dev gobject-introspection +``` + +::: + +::: info +Although UPower is not a direct build dependency, +it should be self-explanatory that the daemon is required to be available at runtime. +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/battery +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/bluetooth.md b/docs/guide/libraries/bluetooth.md index 03ac9c9..9a3e5b8 100644 --- a/docs/guide/libraries/bluetooth.md +++ b/docs/guide/libraries/bluetooth.md @@ -2,45 +2,6 @@ Library for monitoring [bluez](https://www.bluez.org/) over dbus. -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac gobject-introspection -``` - -::: - -::: info -Although bluez is not a direct build dependency, -it should be self-explanatory that the daemon is required to be available at runtime. -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/bluetooth -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Bluetooth reference](https://aylur.github.io/libastal/bluetooth). @@ -91,3 +52,42 @@ end ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac gobject-introspection +``` + +::: + +::: info +Although bluez is not a direct build dependency, +it should be self-explanatory that the daemon is required to be available at runtime. +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/bluetooth +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/cava.md b/docs/guide/libraries/cava.md index e695e16..60b2824 100644 --- a/docs/guide/libraries/cava.md +++ b/docs/guide/libraries/cava.md @@ -2,6 +2,46 @@ Audio visualizer using [cava](https://github.com/karlstav/cava). +## Usage + +You can browse the [Cava reference](https://aylur.github.io/libastal/cava). + +### CLI + +There is no CLI for this library, use the one provided by cava. + +```sh +cava +``` + +### Library + +:::code-group + +```js [ JavaScript] +import Cava from "gi://AstalCava" + +const cava = Cava.get_default() + +cava.connect("notify::values", () => { + print(cava.get_values()) +}) +``` + +```py [ Python] +# Not yet documented +``` + +```lua [ Lua] +-- Not yet documented +``` + +```vala [ Vala] +// Not yet documented +``` + +::: + ## Installation 1. install dependencies @@ -49,43 +89,3 @@ meson setup --prefix /usr build ``` ::: - -## Usage - -You can browse the [Cava reference](https://aylur.github.io/libastal/cava). - -### CLI - -There is no CLI for this library, use the one provided by cava. - -```sh -cava -``` - -### Library - -:::code-group - -```js [ JavaScript] -import Cava from "gi://AstalCava" - -const cava = Cava.get_default() - -cava.connect("notify::values", () => { - print(cava.get_values()) -}) -``` - -```py [ Python] -# Not yet documented -``` - -```lua [ Lua] --- Not yet documented -``` - -```vala [ Vala] -// Not yet documented -``` - -::: diff --git a/docs/guide/libraries/greet.md b/docs/guide/libraries/greet.md index f0cd012..47f98b9 100644 --- a/docs/guide/libraries/greet.md +++ b/docs/guide/libraries/greet.md @@ -2,45 +2,6 @@ Library and CLI tool for sending requests to [greetd](https://sr.ht/~kennylevinsen/greetd/). -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala json-glib gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac libjson-glib-dev gobject-introspection -``` - -::: - -::: info -Although `greetd` is not a direct build dependency, -it should be self-explanatory that the daemon is required to be available at runtime. -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/greet -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Greet reference](https://aylur.github.io/libastal/greet). @@ -92,3 +53,42 @@ try { ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala json-glib gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac libjson-glib-dev gobject-introspection +``` + +::: + +::: info +Although `greetd` is not a direct build dependency, +it should be self-explanatory that the daemon is required to be available at runtime. +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/greet +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/hyprland.md b/docs/guide/libraries/hyprland.md index 94a398f..82d9e9d 100644 --- a/docs/guide/libraries/hyprland.md +++ b/docs/guide/libraries/hyprland.md @@ -2,40 +2,6 @@ Library and CLI tool for monitoring the [Hyprland socket](https://wiki.hyprland.org/IPC/). -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala json-glib gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac libjson-glib-dev gobject-introspection -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/hyprland -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Hyprland reference](https://aylur.github.io/libastal/hyprland). @@ -84,3 +50,37 @@ end ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala json-glib gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac libjson-glib-dev gobject-introspection +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/hyprland +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/mpris.md b/docs/guide/libraries/mpris.md index 30f3d13..c2283cc 100644 --- a/docs/guide/libraries/mpris.md +++ b/docs/guide/libraries/mpris.md @@ -6,52 +6,6 @@ exposing an mpris interface through dbus. An alternative for [playerctl](https://github.com/altdesktop/playerctl) that better integrates with astal. -:::warning -In order for network cover art urls to be cached (spotify for example) -make sure `gvfs` is enabled. - -:::code-group - -```nix [ configuration.nix] -services.gvfs.enable = true; -``` - -::: - -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala gvfs json-glib gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc gvfs json-glib-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac gvfs libjson-glib-dev gobject-introspection -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/mpris -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Mpris reference](https://aylur.github.io/libastal/mpris). @@ -99,3 +53,49 @@ end ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala gvfs json-glib gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc gvfs json-glib-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac gvfs libjson-glib-dev gobject-introspection +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/mpris +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` + +:::warning +In order for network cover art urls to be cached (spotify for example) +make sure `gvfs` is enabled. + +:::code-group + +```nix [ configuration.nix] +services.gvfs.enable = true; +``` + +::: diff --git a/docs/guide/libraries/network.md b/docs/guide/libraries/network.md index 21c7b10..79a217c 100644 --- a/docs/guide/libraries/network.md +++ b/docs/guide/libraries/network.md @@ -2,40 +2,6 @@ Wrapper library over [networkmanager](https://networkmanager.dev/) to better integrate with Astal. -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala libnm gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc NetworkManager-libnm-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac libnm-dev gobject-introspection -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/network -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Network reference](https://aylur.github.io/libastal/network). @@ -81,3 +47,37 @@ print(network.wifi.ssid) ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala libnm gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc NetworkManager-libnm-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac libnm-dev gobject-introspection +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/network +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/notifd.md b/docs/guide/libraries/notifd.md index 4208700..1d61099 100644 --- a/docs/guide/libraries/notifd.md +++ b/docs/guide/libraries/notifd.md @@ -6,40 +6,6 @@ A [notification daemon](https://specifications.freedesktop.org/notification-spec The first instantiation of the [Notifd](https://aylur.github.io/libastal/notifd/class.Notifd.html) class will become the daemon and every subsequent instantiation will queue up to act as the daemon and will act as a client in the meantime. This means this library can be used throughout multiple processes. -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala gdk-pixbuf2 json-glib gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc gdk-pixbuf2-devel json-glib-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac libgdk-pixbuf-2.0-dev libjson-glib-dev gobject-introspection -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/notifd -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Notifd reference](https://aylur.github.io/libastal/notifd). @@ -93,3 +59,37 @@ end ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala gdk-pixbuf2 json-glib gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc gdk-pixbuf2-devel json-glib-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac libgdk-pixbuf-2.0-dev libjson-glib-dev gobject-introspection +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/notifd +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/powerprofiles.md b/docs/guide/libraries/powerprofiles.md index bdafcde..b42d7c6 100644 --- a/docs/guide/libraries/powerprofiles.md +++ b/docs/guide/libraries/powerprofiles.md @@ -2,45 +2,6 @@ Library and CLI tool for monitoring [upowerd](https://upower.freedesktop.org/) powerprofiles. -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala json-glib gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson valac libjson-glib-dev gobject-introspection -``` - -::: - -::: info -Although UPower is not a direct build dependency, -it should be self-explanatory that the daemon is required to be available at runtime. -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/powerprofiles -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [PowerProfiles reference](https://aylur.github.io/libastal/powerprofiles). @@ -84,3 +45,42 @@ print(powerprofiles.active_profile) ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala json-glib gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson valac libjson-glib-dev gobject-introspection +``` + +::: + +::: info +Although UPower is not a direct build dependency, +it should be self-explanatory that the daemon is required to be available at runtime. +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/powerprofiles +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/references.md b/docs/guide/libraries/references.md index 3a85d73..f8ab4d8 100644 --- a/docs/guide/libraries/references.md +++ b/docs/guide/libraries/references.md @@ -33,6 +33,8 @@ Reading their documentation will vary depending on the language they are used in - [Auth](https://aylur.github.io/libastal/auth): Authentication library using PAM - [Battery](https://aylur.github.io/libastal/battery): DBus proxy library for upower daemon - [Bluetooth](https://aylur.github.io/libastal/bluetooth): Library to control bluez over dbus +- [Cava](https://aylur.github.io/libastal/cava): Audio visualizer library using cava +- [Greet](https://aylur.github.io/libastal/greet): Library and CLI tool for sending requests to greetd - [Hyprland](https://aylur.github.io/libastal/hyprland): Library and cli tool for Hyprland IPC socket - [Mpris](https://aylur.github.io/libastal/mpris): Library and cli tool for controlling media players - [Network](https://aylur.github.io/libastal/network): NetworkManager wrapper library diff --git a/docs/guide/libraries/river.md b/docs/guide/libraries/river.md index 299aa8c..dc1c71e 100644 --- a/docs/guide/libraries/river.md +++ b/docs/guide/libraries/river.md @@ -2,40 +2,6 @@ Library and CLI tool for monitoring the [River Wayland Compositor](https://isaacfreund.com/software/river/). -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson json-glib gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson gcc json-glib-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson libjson-glib-dev gobject-introspection -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/river -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [River reference](https://aylur.github.io/libastal/river). @@ -84,3 +50,37 @@ end ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson json-glib gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson gcc json-glib-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson libjson-glib-dev gobject-introspection +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/river +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/tray.md b/docs/guide/libraries/tray.md index b5cccc7..39dffc1 100644 --- a/docs/guide/libraries/tray.md +++ b/docs/guide/libraries/tray.md @@ -2,40 +2,6 @@ Library for managing the systemtray by implementing the [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/) protocol. -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson gtk3 gobject-introspection libdbusmenu-gtk3 -``` - -```sh [ Fedora] -sudo dnf install meson gcc gtk3-devel libdbusmenu-gtk3 gobject-introspection-devel -``` - -```sh [ Ubuntu] -sudo apt install meson libgtk-3-dev libdbusmenu-gtk3-dev gobject-introspection -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/tray -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Tray reference](https://aylur.github.io/libastal/tray). @@ -84,3 +50,37 @@ end ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson gtk3 gobject-introspection libdbusmenu-gtk3 +``` + +```sh [ Fedora] +sudo dnf install meson gcc gtk3-devel libdbusmenu-gtk3 gobject-introspection-devel +``` + +```sh [ Ubuntu] +sudo apt install meson libgtk-3-dev libdbusmenu-gtk3-dev gobject-introspection +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/tray +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` diff --git a/docs/guide/libraries/wireplumber.md b/docs/guide/libraries/wireplumber.md index c06161e..d6faea1 100644 --- a/docs/guide/libraries/wireplumber.md +++ b/docs/guide/libraries/wireplumber.md @@ -2,40 +2,6 @@ Wrapper library over [wireplumber](https://pipewire.pages.freedesktop.org/wireplumber/) to better integrate with Astal. -## Installation - -1. install dependencies - -:::code-group - -```sh [ Arch] -sudo pacman -Syu meson vala wireplumber gobject-introspection -``` - -```sh [ Fedora] -sudo dnf install meson vala valadoc wireplumber-devel gobject-introspection-devel -``` - -```sh [ Ubuntu] -# Not yet documented -``` - -::: - -2. clone repo - -```sh -git clone https://github.com/aylur/astal.git -cd astal/lib/wireplumber -``` - -3. install - -```sh -meson setup --prefix /usr build -meson install -C build -``` - ## Usage You can browse the [Wireplumber reference](https://aylur.github.io/libastal/wireplumber). @@ -81,3 +47,37 @@ print(audio.default_speaker.volume) ``` ::: + +## Installation + +1. install dependencies + +:::code-group + +```sh [ Arch] +sudo pacman -Syu meson vala wireplumber gobject-introspection +``` + +```sh [ Fedora] +sudo dnf install meson vala valadoc wireplumber-devel gobject-introspection-devel +``` + +```sh [ Ubuntu] +# Not yet documented +``` + +::: + +2. clone repo + +```sh +git clone https://github.com/aylur/astal.git +cd astal/lib/wireplumber +``` + +3. install + +```sh +meson setup --prefix /usr build +meson install -C build +``` -- cgit v1.2.3 From 48b6b0742fb21a298985dc6c86605099e6d5abd1 Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 8 Nov 2024 20:54:11 +0000 Subject: example: fix applauncher text reset --- examples/js/applauncher/widget/Applauncher.scss | 14 ++++++++++++++ examples/js/applauncher/widget/Applauncher.tsx | 24 ++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/examples/js/applauncher/widget/Applauncher.scss b/examples/js/applauncher/widget/Applauncher.scss index 86c5e87..ae2453d 100644 --- a/examples/js/applauncher/widget/Applauncher.scss +++ b/examples/js/applauncher/widget/Applauncher.scss @@ -41,5 +41,19 @@ window#launcher { color: gtkalpha($fg-color, .8); } } + + box.not-found { + padding: 1rem; + + icon { + font-size: 6em; + color: gtkalpha($fg-color, .7); + } + + label { + color: gtkalpha($fg-color, .9); + font-size: 1.2em; + } + } } } diff --git a/examples/js/applauncher/widget/Applauncher.tsx b/examples/js/applauncher/widget/Applauncher.tsx index d92b5e3..f52780b 100644 --- a/examples/js/applauncher/widget/Applauncher.tsx +++ b/examples/js/applauncher/widget/Applauncher.tsx @@ -27,13 +27,12 @@ function AppButton({ app }: { app: Apps.Application }) { } export default function Applauncher() { + const { CENTER } = Gtk.Align const apps = new Apps.Apps() - const list = Variable(apps.get_list().slice(0, MAX_ITEMS)) - const hide = () => App.get_window("launcher")!.hide() - function search(text: string) { - list.set(apps.fuzzy_query(text).slice(0, MAX_ITEMS)) - } + const text = Variable("") + const list = text(text => apps.fuzzy_query(text).slice(0, MAX_ITEMS)) + const hide = () => App.get_window("launcher")!.hide() return list.set(apps.get_list().slice(0, MAX_ITEMS))} + onShow={() => text.set("")} onKeyPressEvent={function (self, event: Gdk.Event) { if (event.get_keyval()[1] === Gdk.KEY_Escape) self.hide() @@ -53,16 +52,21 @@ export default function Applauncher() { search(text)} + text={text()} + onChanged={self => text.set(self.text)} /> - {list(list => list.map(app => ( + {list.as(list => list.map(app => ( )))} - l.length === 0)}> + l.length === 0)}> - No match found + -- cgit v1.2.3 From 302fcae7ae0b58767518e6003d0a80966d7ca4bb Mon Sep 17 00:00:00 2001 From: Aylur Date: Fri, 8 Nov 2024 21:23:07 +0000 Subject: example(applauncher): hide on app launch --- examples/js/applauncher/widget/Applauncher.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/js/applauncher/widget/Applauncher.tsx b/examples/js/applauncher/widget/Applauncher.tsx index f52780b..c7bac68 100644 --- a/examples/js/applauncher/widget/Applauncher.tsx +++ b/examples/js/applauncher/widget/Applauncher.tsx @@ -4,8 +4,14 @@ import { Variable } from "astal" const MAX_ITEMS = 8 +function hide() { + App.get_window("launcher")!.hide() +} + function AppButton({ app }: { app: Apps.Application }) { - return