commit 10154115bfba8c03416dcbe25386c1f01c84923c
parent 76b919baed142843604b3f06d9b74dccea99a19c
Author: Daniel Barlow <dan@telent.net>
Date: Wed, 23 Mar 2022 23:20:53 +0000
add layer-shell, todo list
Diffstat:
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/blinkenlicht/README.md b/blinkenlicht/README.md
@@ -8,6 +8,16 @@ More seriously: you might prefer this over another status bar program
if you want fine-grained control over what is shown in your bar and
you are happy to exert that control in a Lua-based Lisp language.
+## Plan
+
+* [X] use gtk-layer-shell to put it in a layer
+* [] update only at relevant intervals
+* [] do we need file poll support? prolly not if we're calling every 200ms
+* [] cache icon pixbufs
+* [] update image/label widget instead of destroying
+* [] allow height customisation
+
+
```fennel
(bar
{
diff --git a/blinkenlicht/blinkenlicht.fnl b/blinkenlicht/blinkenlicht.fnl
@@ -1,4 +1,5 @@
(local {: Gtk
+ : GtkLayerShell
: Gdk
: GdkPixbuf
: GLib
@@ -61,6 +62,24 @@
: update
}))
+(fn make-layer-shell [window layer exclusive? anchors]
+ (let [s GtkLayerShell]
+ (s.init_for_window window)
+ (s.set_layer window (. {
+ :top GtkLayerShell.Layer.TOP
+ }
+ layer))
+ (if exclusive? (s.auto_exclusive_zone_enable window))
+
+ (each [edge margin (pairs anchors)]
+ (let [edge (. {:top GtkLayerShell.Edge.TOP
+ :bottom GtkLayerShell.Edge.BOTTOM
+ :left GtkLayerShell.Edge.LEFT
+ :right GtkLayerShell.Edge.RIGHT}
+ edge)]
+ (GtkLayerShell.set_margin window edge margin)
+ (GtkLayerShell.set_anchor window edge 1)))))
+
(local bars [])
(fn bar [{ : anchor : orientation : indicators }]
@@ -85,6 +104,9 @@
(indicator:update)))
true))
(each [_ b (ipairs bars)]
+ (make-layer-shell b.window :top true
+ (collect [_ edge (ipairs b.anchor)]
+ edge 1))
(b.window:show_all))
(Gtk.main))
diff --git a/blinkenlicht/default.nix b/blinkenlicht/default.nix
@@ -4,6 +4,7 @@
, fetchurl
, gobject-introspection
, gtk3
+, gtk-layer-shell
, lib
, librsvg
, lua53Packages
@@ -33,7 +34,12 @@ in stdenv.mkDerivation {
inherit fennel;
- buildInputs = [ lua gtk3 gobject-introspection.dev ];
+ buildInputs = [
+ gobject-introspection.dev
+ gtk-layer-shell
+ gtk3
+ lua
+ ];
nativeBuildInputs = [ lua makeWrapper ];
makeFlags = [ "PREFIX=${placeholder "out"}" ];