diff options
Diffstat (limited to 'lib')
27 files changed, 448 insertions, 130 deletions
diff --git a/lib/apps/default.nix b/lib/apps/default.nix new file mode 100644 index 0000000..64466a2 --- /dev/null +++ b/lib/apps/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-apps"; + src = ./.; + packages = [pkgs.json-glib]; + + libname = "apps"; + gir-suffix = "Apps"; + authors = "Aylur"; + description = "Application query library"; +} diff --git a/lib/astal/gtk3/default.nix b/lib/astal/gtk3/default.nix new file mode 100644 index 0000000..c86f3de --- /dev/null +++ b/lib/astal/gtk3/default.nix @@ -0,0 +1,21 @@ +{ + mkAstalPkg, + pkgs, + self, +}: +mkAstalPkg { + pname = "astal3"; + src = ./.; + packages = [ + self.packages.${pkgs.system}.io + pkgs.gtk3 + pkgs.gtk-layer-shell + ]; + + libname = "astal3"; + gir-suffix = ""; + authors = "Aylur"; + description = "Astal GTK3 widget library"; + dependencies = ["AstalIO-0.1" "Gtk-3.0"]; + repo-path = "astal/gtk3"; +} diff --git a/lib/astal/gtk3/src/widget/icon.vala b/lib/astal/gtk3/src/widget/icon.vala index 9a20359..ee6808c 100644 --- a/lib/astal/gtk3/src/widget/icon.vala +++ b/lib/astal/gtk3/src/widget/icon.vala @@ -9,7 +9,21 @@ public class Astal.Icon : Gtk.Image { private double size { get; set; default = 14; } public new Gdk.Pixbuf pixbuf { get; set; } - public GLib.Icon g_icon { get; set; } + + private static bool gicon_warned = false; + [Version (deprecated = true, deprecated_since = "0.1.0", replacement = "gicon")] + public GLib.Icon g_icon { + owned get { + return this.gicon; + } + set { + if( !gicon_warned ) { + GLib.warning("g-icon is deprecated. Use gicon instead."); + gicon_warned = true; + } + this.gicon = value; + } + } /** * Either a named icon or a path to a file. @@ -57,7 +71,6 @@ public class Astal.Icon : Gtk.Image { break; case IconType.GICON: pixel_size = (int)size; - gicon = g_icon; break; } @@ -86,7 +99,7 @@ public class Astal.Icon : Gtk.Image { display_icon.begin(); }); - notify["g-icon"].connect(() => { + notify["gicon"].connect(() => { type = IconType.GICON; display_icon.begin(); }); diff --git a/lib/astal/gtk4/default.nix b/lib/astal/gtk4/default.nix new file mode 100644 index 0000000..0bca3c0 --- /dev/null +++ b/lib/astal/gtk4/default.nix @@ -0,0 +1,21 @@ +{ + mkAstalPkg, + pkgs, + self, +}: +mkAstalPkg { + pname = "astal4"; + src = ./.; + packages = [ + self.packages.${pkgs.system}.io + pkgs.gtk4 + pkgs.gtk4-layer-shell + ]; + + libname = "astal4"; + gir-suffix = ""; + authors = "Aylur"; + description = "Astal GTK4 widget library"; + dependencies = ["AstalIO-0.1" "Gtk-4.0"]; + repo-path = "astal/gtk4"; +} diff --git a/lib/astal/io/default.nix b/lib/astal/io/default.nix new file mode 100644 index 0000000..c33132a --- /dev/null +++ b/lib/astal/io/default.nix @@ -0,0 +1,12 @@ +{mkAstalPkg, ...}: +mkAstalPkg { + pname = "astal"; + src = ./.; + + libname = "io"; + gir-suffix = "IO"; + authors = "Aylur"; + description = "Astal Core library"; + repo-path = "astal/io"; + website-path = "io"; +} diff --git a/lib/auth/default.nix b/lib/auth/default.nix new file mode 100644 index 0000000..3b8b276 --- /dev/null +++ b/lib/auth/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-auth"; + src = ./.; + packages = [pkgs.pam]; + + libname = "auth"; + gir-suffix = "Auth"; + authors = "kotontrion"; + description = "Authentication using pam"; +} diff --git a/lib/battery/default.nix b/lib/battery/default.nix new file mode 100644 index 0000000..17bf67a --- /dev/null +++ b/lib/battery/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-battery"; + src = ./.; + packages = [pkgs.json-glib]; + + libname = "battery"; + authors = "Aylur"; + gir-suffix = "Battery"; + description = "DBus proxy for upowerd devices"; +} diff --git a/lib/bluetooth/default.nix b/lib/bluetooth/default.nix new file mode 100644 index 0000000..f2d58c8 --- /dev/null +++ b/lib/bluetooth/default.nix @@ -0,0 +1,10 @@ +{mkAstalPkg, ...}: +mkAstalPkg { + pname = "astal-bluetooth"; + src = ./.; + + libname = "bluetooth"; + authors = "Aylur"; + gir-suffix = "Bluetooth"; + description = "DBus proxy for bluez"; +} diff --git a/lib/cava/default.nix b/lib/cava/default.nix new file mode 100644 index 0000000..5472e8c --- /dev/null +++ b/lib/cava/default.nix @@ -0,0 +1,56 @@ +{ + mkAstalPkg, + pkgs, + ... +}: let + libcava = pkgs.stdenv.mkDerivation rec { + pname = "cava"; + version = "0.10.3"; + + src = pkgs.fetchFromGitHub { + owner = "LukashonakV"; + repo = "cava"; + rev = "0.10.3"; + hash = "sha256-ZDFbI69ECsUTjbhlw2kHRufZbQMu+FQSMmncCJ5pagg="; + }; + + buildInputs = with pkgs; [ + alsa-lib + libpulseaudio + ncurses + iniparser + sndio + SDL2 + libGL + portaudio + jack2 + pipewire + ]; + + propagatedBuildInputs = with pkgs; [ + fftw + ]; + + nativeBuildInputs = with pkgs; [ + autoreconfHook + autoconf-archive + pkgconf + meson + ninja + ]; + + preAutoreconf = '' + echo ${version} > version + ''; + }; +in + mkAstalPkg { + pname = "astal-cava"; + src = ./.; + packages = [libcava]; + + libname = "cava"; + authors = "kotontrion"; + gir-suffix = "Cava"; + description = "Audio visualization library using cava"; + } diff --git a/lib/greet/default.nix b/lib/greet/default.nix new file mode 100644 index 0000000..22b9456 --- /dev/null +++ b/lib/greet/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-greet"; + src = ./.; + packages = [pkgs.json-glib]; + + libname = "greet"; + authors = "Aylur"; + gir-suffix = "Greet"; + description = "IPC client for greetd"; +} diff --git a/lib/hyprland/default.nix b/lib/hyprland/default.nix new file mode 100644 index 0000000..6b5e15d --- /dev/null +++ b/lib/hyprland/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-hyprland"; + src = ./.; + packages = [pkgs.json-glib]; + + libname = "hyprland"; + authors = "Aylur"; + gir-suffix = "Hyprland"; + description = "IPC client for Hyprland"; +} diff --git a/lib/mpris/default.nix b/lib/mpris/default.nix new file mode 100644 index 0000000..082c647 --- /dev/null +++ b/lib/mpris/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-mpris"; + src = ./.; + packages = with pkgs; [gvfs json-glib]; + + libname = "mpris"; + authors = "Aylur"; + gir-suffix = "Mpris"; + description = "Control mpris players"; +} diff --git a/lib/network/default.nix b/lib/network/default.nix new file mode 100644 index 0000000..cfa2378 --- /dev/null +++ b/lib/network/default.nix @@ -0,0 +1,16 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-network"; + src = ./.; + packages = [pkgs.networkmanager]; + + libname = "network"; + authors = "Aylur"; + gir-suffix = "Network"; + description = "NetworkManager wrapper library"; + dependencies = ["NM-1.0"]; +} diff --git a/lib/notifd/default.nix b/lib/notifd/default.nix new file mode 100644 index 0000000..e23528c --- /dev/null +++ b/lib/notifd/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-notifd"; + src = ./.; + packages = with pkgs; [json-glib gdk-pixbuf]; + + libname = "notifd"; + authors = "Aylur"; + gir-suffix = "Notifd"; + description = "Notification daemon library"; +} diff --git a/lib/powerprofiles/default.nix b/lib/powerprofiles/default.nix new file mode 100644 index 0000000..f35f9e5 --- /dev/null +++ b/lib/powerprofiles/default.nix @@ -0,0 +1,15 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-powerprofiles"; + src = ./.; + packages = [pkgs.json-glib]; + + libname = "powerprofiles"; + authors = "Aylur"; + gir-suffix = "PowerProfiles"; + description = "DBus proxy for upowerd profiles"; +} diff --git a/lib/river/default.nix b/lib/river/default.nix new file mode 100644 index 0000000..15c6eb4 --- /dev/null +++ b/lib/river/default.nix @@ -0,0 +1,21 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-river"; + src = ./.; + packages = [pkgs.json-glib]; + + libname = "river"; + authors = "kotontrion"; + gir-suffix = "River"; + description = "IPC client for River"; + + postUnpack = '' + rm -rf $sourceRoot/subprojects + mkdir -p $sourceRoot/subprojects + cp -r --remove-destination ${../wayland-glib} $sourceRoot/subprojects/wayland-glib + ''; +} diff --git a/lib/river/include/wayland-source.h b/lib/river/include/wayland-source.h deleted file mode 100644 index b219589..0000000 --- a/lib/river/include/wayland-source.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __WAYLAND_SOURCE_H__ -#define __WAYLAND_SOURCE_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _WLSource WLSource; - -WLSource* wl_source_new(); -void wl_source_free(WLSource* self); -struct wl_display* wl_source_get_display(WLSource* source); - -G_END_DECLS - -#endif /* __WAYLAND_SOURCE_H__ */ diff --git a/lib/river/meson.build b/lib/river/meson.build index aa5e23b..2f98315 100644 --- a/lib/river/meson.build +++ b/lib/river/meson.build @@ -13,6 +13,9 @@ lib_so_version = version_split[0] + '.' + version_split[1] pkg_config = import('pkgconfig') gnome = import('gnome') +wayland_glib = subproject('wayland-glib') +wayland_glib_dep = wayland_glib.get_variable('wayland_glib') + subdir('protocols') subdir('include') subdir('src') diff --git a/lib/river/src/meson.build b/lib/river/src/meson.build index b7ce20d..9c58e41 100644 --- a/lib/river/src/meson.build +++ b/lib/river/src/meson.build @@ -1,7 +1,6 @@ srcs = files( 'river-output.c', - 'river.c', - 'wayland-source.c', + 'river.c' ) deps = [ @@ -9,6 +8,7 @@ deps = [ dependency('gio-2.0'), dependency('wayland-client'), dependency('json-glib-1.0'), + wayland_glib_dep ] astal_river_lib = library( diff --git a/lib/river/src/river.c b/lib/river/src/river.c index 124cb20..6f94c9c 100644 --- a/lib/river/src/river.c +++ b/lib/river/src/river.c @@ -6,7 +6,8 @@ #include "river-control-unstable-v1-client.h" #include "river-private.h" #include "river-status-unstable-v1-client.h" -#include "wayland-source.h" +// #include "wayland-source.h" +#include <wayland-glib.h> struct _AstalRiverRiver { GObject parent_instance; @@ -22,7 +23,7 @@ typedef struct { struct wl_registry* wl_registry; struct wl_seat* seat; struct wl_display* display; - WLSource* wl_source; + WlGlibWlSource* wl_source; struct zriver_status_manager_v1* river_status_manager; struct zriver_control_v1* river_control; struct zriver_seat_status_v1* river_seat_status; @@ -340,7 +341,7 @@ static gboolean astal_river_river_initable_init(GInitable* initable, GCancellabl if (priv->init) return TRUE; - priv->wl_source = wl_source_new(NULL, NULL); + priv->wl_source = wl_glib_wl_source_new(); if (priv->wl_source == NULL) { g_set_error_literal(error, G_IO_ERROR, G_IO_ERROR_FAILED, @@ -348,7 +349,7 @@ static gboolean astal_river_river_initable_init(GInitable* initable, GCancellabl return FALSE; } - priv->display = wl_source_get_display(priv->wl_source); + priv->display = priv->wl_source->display; priv->wl_registry = wl_display_get_registry(priv->display); wl_registry_add_listener(priv->wl_registry, ®istry_listener, self); @@ -449,7 +450,8 @@ static void astal_river_river_finalize(GObject* object) { if (priv->seat != NULL) wl_seat_destroy(priv->seat); if (priv->display != NULL) wl_display_flush(priv->display); - if (priv->wl_source != NULL) wl_source_free(priv->wl_source); + // if (priv->wl_source != NULL) wl_source_free(priv->wl_source); + if (priv->wl_source != NULL) g_source_unref((GSource*)(priv->wl_source)); g_free(self->focused_view); g_free(self->focused_output); diff --git a/lib/river/src/wayland-source.c b/lib/river/src/wayland-source.c deleted file mode 100644 index 875c32c..0000000 --- a/lib/river/src/wayland-source.c +++ /dev/null @@ -1,104 +0,0 @@ - -#include "wayland-source.h" - -#include <errno.h> -#include <glib.h> -#include <wayland-client.h> - -struct _WLSource { - GSource source; - struct wl_display *display; - gpointer fd; - int error; -}; - -static gboolean wl_source_prepare(GSource *source, gint *timeout) { - WLSource *self = (WLSource *)source; - - *timeout = 0; - if (wl_display_prepare_read(self->display) != 0) - return TRUE; - else if (wl_display_flush(self->display) < 0) { - self->error = errno; - return TRUE; - } - *timeout = -1; - return FALSE; -} - -static gboolean wl_source_check(GSource *source) { - WLSource *self = (WLSource *)source; - - if (self->error > 0) return TRUE; - - GIOCondition revents; - revents = g_source_query_unix_fd(source, self->fd); - - if (revents & G_IO_IN) { - if (wl_display_read_events(self->display) < 0) self->error = errno; - } else - wl_display_cancel_read(self->display); - - return revents > 0; -} - -static gboolean wl_source_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { - WLSource *self = (WLSource *)source; - GIOCondition revents; - - revents = g_source_query_unix_fd(source, self->fd); - if ((self->error > 0) || (revents & (G_IO_ERR | G_IO_HUP))) { - errno = self->error; - self->error = 0; - if (callback != NULL) return callback(user_data); - return G_SOURCE_REMOVE; - } - - if (wl_display_dispatch_pending(self->display) < 0) { - if (callback != NULL) return callback(user_data); - return G_SOURCE_REMOVE; - } - - return G_SOURCE_CONTINUE; -} - -static void wl_source_finalize(GSource *source) { - WLSource *self = (WLSource *)source; - wl_display_disconnect(self->display); -} - -static GSourceFuncs wl_source_funcs = { - .prepare = wl_source_prepare, - .check = wl_source_check, - .dispatch = wl_source_dispatch, - .finalize = wl_source_finalize, -}; - -WLSource *wl_source_new() { - struct wl_display *display; - WLSource *self; - GSource *source; - - display = wl_display_connect(NULL); - if (display == NULL) return NULL; - - source = g_source_new(&wl_source_funcs, sizeof(WLSource)); - self = (WLSource *)source; - self->display = display; - - self->fd = g_source_add_unix_fd(source, wl_display_get_fd(self->display), - G_IO_IN | G_IO_ERR | G_IO_HUP); - - g_source_attach(source, NULL); - - return self; -} - -void wl_source_free(WLSource *self) { - GSource *source = (GSource *)self; - g_return_if_fail(source != NULL); - g_source_destroy(source); - g_source_unref(source); -} - -struct wl_display *wl_source_get_display(WLSource *self) { return self->display; } diff --git a/lib/river/subprojects/wayland-glib b/lib/river/subprojects/wayland-glib new file mode 120000 index 0000000..41372cf --- /dev/null +++ b/lib/river/subprojects/wayland-glib @@ -0,0 +1 @@ +../../wayland-glib
\ No newline at end of file diff --git a/lib/tray/default.nix b/lib/tray/default.nix new file mode 100644 index 0000000..6dd0d61 --- /dev/null +++ b/lib/tray/default.nix @@ -0,0 +1,41 @@ +{ + mkAstalPkg, + pkgs, + ... +}: let + vala-panel-appmenu = pkgs.fetchFromGitLab { + owner = "vala-panel-project"; + repo = "vala-panel-appmenu"; + rev = "24.05"; + hash = "sha256-8GWauw7r3zKhvGF2TNOI8GDVctUFDhtG/Vy1cNUpsVo="; + }; + + appmenu-glib-translator = pkgs.stdenv.mkDerivation { + pname = "appmenu-glib-translator"; + version = "24.05"; + + src = "${vala-panel-appmenu}/subprojects/appmenu-glib-translator"; + + buildInputs = with pkgs; [ + glib + ]; + + nativeBuildInputs = with pkgs; [ + gobject-introspection + meson + pkg-config + ninja + vala + ]; + }; +in + mkAstalPkg { + pname = "astal-tray"; + src = ./.; + packages = [pkgs.json-glib appmenu-glib-translator]; + + libname = "tray"; + authors = "kotontrion"; + gir-suffix = "Tray"; + description = "StatusNotifierItem implementation"; + } diff --git a/lib/wayland-glib/meson.build b/lib/wayland-glib/meson.build new file mode 100644 index 0000000..3d93ac0 --- /dev/null +++ b/lib/wayland-glib/meson.build @@ -0,0 +1,40 @@ +project( + 'wayland-glib', + 'vala', + 'c', + version: run_command('cat', join_paths(meson.project_source_root(), 'version')).stdout().strip(), + meson_version: '>= 0.62.0', + default_options: [ + 'warning_level=2', + 'werror=false', + 'c_std=gnu11', + ], +) + +version_split = meson.project_version().split('.') + +deps = [ + dependency('glib-2.0'), + dependency('gio-2.0'), + dependency('gobject-2.0'), + dependency('wayland-client'), +] + +sources = [ + 'wl-source.vala', +] + +lib = static_library( + meson.project_name(), + sources, + dependencies: deps, + vala_header: meson.project_name() + '.h', + vala_vapi: meson.project_name() + '.vapi', +) + +wayland_glib = declare_dependency( + link_with: lib, + include_directories: include_directories('.') + ) + + diff --git a/lib/wayland-glib/version b/lib/wayland-glib/version new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/lib/wayland-glib/version @@ -0,0 +1 @@ +0.1.0 diff --git a/lib/wayland-glib/wl-source.vala b/lib/wayland-glib/wl-source.vala new file mode 100644 index 0000000..f8472fb --- /dev/null +++ b/lib/wayland-glib/wl-source.vala @@ -0,0 +1,44 @@ +namespace WlGlib { +public class WlSource : Source { + + public Wl.Display display; + public void* fd; + public int error; + + public override bool dispatch(SourceFunc callback) { + IOCondition revents = this.query_unix_fd(this.fd); + if (this.error > 0 || (revents & (IOCondition.ERR | IOCondition.HUP)) != 0) { + errno = this.error; + if(callback != null) return callback(); + return Source.REMOVE; + } + if (((revents & IOCondition.IN) != 0) && this.display.dispatch() < 0) { + if(callback != null) return callback(); + return Source.REMOVE; + } + return Source.CONTINUE; + } + + public override bool check() { + IOCondition revents = this.query_unix_fd(this.fd); + return revents > 0; + } + + public override bool prepare(out int timeout) { + if(this.display.flush() < 0) + this.error = errno; + timeout = -1; + return false; + } + + public WlSource() { + base(); + this.display = new Wl.Display.connect(null); + if(this.display == null) return; + this.fd = this.add_unix_fd(this.display.get_fd(), + IOCondition.IN | IOCondition.ERR | IOCondition.HUP); + this.attach(null); + } +} +} + diff --git a/lib/wireplumber/default.nix b/lib/wireplumber/default.nix new file mode 100644 index 0000000..f9eb832 --- /dev/null +++ b/lib/wireplumber/default.nix @@ -0,0 +1,16 @@ +{ + mkAstalPkg, + pkgs, + ... +}: +mkAstalPkg { + pname = "astal-wireplumber"; + src = ./.; + packages = [pkgs.wireplumber]; + + libname = "wireplumber"; + authors = "kotontrion"; + gir-suffix = "Wp"; + description = "Wrapper library over the wireplumber API"; + dependencies = ["WP-0.5"]; +} |