diff --git a/blinkenlicht/README.md b/blinkenlicht/README.md index 3d68c64..c3e4d29 100644 --- a/blinkenlicht/README.md +++ b/blinkenlicht/README.md @@ -11,9 +11,8 @@ 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 +* [X] update only at relevant intervals +* [X] cache icon pixbufs * [] update image/label widget instead of destroying * [] allow height customisation diff --git a/blinkenlicht/blinkenlicht.fnl b/blinkenlicht/blinkenlicht.fnl index 9614aec..191182b 100644 --- a/blinkenlicht/blinkenlicht.fnl +++ b/blinkenlicht/blinkenlicht.fnl @@ -29,13 +29,22 @@ GdkPixbuf.InterpType.BILINEAR))))) found) -(fn find-icon [name] +(local found-icons {}) + +(fn load-icon [name] (if (= (name:sub 1 1) "/") ;; From a direct path (GdkPixbuf.Pixbuf.new_from_file_at_scale name HEIGHT -1 true) ;; From icon theme (Gtk.Image.new_from_pixbuf (find-icon-pixbuf name)))) +(fn find-icon [name] + (let [icon (. found-icons name)] + (or icon + (let [icon (load-icon name)] + (tset found-icons name icon) + icon)))) + (fn update-button [button icon text] (match (button:get_child) it (button:remove it)) (let [i (resolve icon)]