commit 2f32fac349ce8f5fd8aef49a115ced3bf5e951d8
parent 1887b72d1c41a40a7c17e1cf42b0e31d9591ae5e
Author: Daniel Barlow <dan@telent.net>
Date: Tue, 26 Apr 2022 22:13:37 +0100
merge blinkenlicht, add modeline
Diffstat:
7 files changed, 73 insertions(+), 120 deletions(-)
diff --git a/blinkenlicht/bl.fnl b/blinkenlicht/bl.fnl
@@ -1,116 +0,0 @@
-(local {: bar : indicator : stylesheet : run} (require :blinkenlicht))
-
-(local {: view} (require :fennel))
-
-(local iostream (require :iostream))
-(local modem (require :modem))
-
-(local uplink (require :metric.uplink))
-(local battery (require :metric.battery))
-(local cpustat (require :metric.cpustat))
-
-(stylesheet "licht.css")
-
-(fn battery-icon-codepoint [status percent]
- (if (= status "Charging") 0xf0e7
- (> percent 90) 0xf240 ;full
- (> percent 60) 0xf241 ;3/4
- (> percent 40) 0xf242 ;1/2
- (> percent 15) 0xf243 ;1/4
- (>= percent 0) 0xf244 ;empty
- ; 0xf377 ; glyph not present in font-awesome free
- ))
-
-(fn wlan-quality-class [quality]
- (if (< -50 quality) "p100"
- (< -67 quality) "p75"
- (< -70 quality) "p50"
- (< -80 quality) "p25"
- "p0"))
-
-(fn spawn []
- true)
-
-(bar
- {
- ;; bar must be full width to set up an "exclusive zone" (moves
- ;; other windows out of the way), otherwise it will display on
- ;; to of whatever's on the screen already
- :anchor [:top :right :left]
- :orientation :horizontal
- :gravity :end
- :classes ["hey"]
- :indicators
- [
- (let []
- (var previous 0)
- ;; on my laptop, adding this indicator has made the task
- ;; go from ~ 1% cpu to around 3%, which is not ideal
- (indicator {
- :wait-for { :interval (* 1 500) }
- :refresh
- (let [stat (cpustat.new)]
- #(let [current (. (stat:read) :iowait)
- delta (- current previous)
- v (if (> delta 4) "" " ")]
- (set previous current)
- {:text v}))
- }))
-
- (indicator {
- :wait-for {
- :interval (* 4 1000)
- }
- :refresh
- (let [modem (modem.new)]
- #(let [{:m3gpp-operator-name operator
- :signal-quality quality} (modem:read)]
- {:text (.. operator
- ;;" " (. quality 1) "dBm"
- )
- }))
- })
-
- (let [uplink (uplink.new)
- input (iostream.from-descriptor uplink.fd)]
- (indicator {
- :wait-for {
- :input [input]
- }
- :refresh
- #(let [status (uplink:read)
- devtype status.devtype]
- (if status
- {:text (.. (or status.ssid status.name "?")
- " ")
- :classes [devtype
- (and (= devtype "wlan")
- (wlan-quality-class status.quality))]
- }
- {:text "no internet"}
- ))
- }))
-
- (indicator {
- :wait-for { :interval (* 1000 10) }
- :refresh
- (let [battery (battery.new (or (os.getenv "BLINKEN_BATTERY")
- "axp20x-battery"))]
- #(let [{:power-supply-capacity percent
- :power-supply-status status}
- (battery.read)
- icon-code (battery-icon-codepoint
- status (tonumber percent))]
- {:text
- (string.format "%s %d%%" (utf8.char icon-code) percent)
- :classes ["battery" (if (< (tonumber percent) 20) "low" "ok")]
- }))
- })
- (indicator {
- :wait-for { :interval 4000 }
- :refresh #{:text (os.date "%H:%M")}
- })
-
- ]})
-
-(run)
diff --git a/blinkenlicht/blinkenlicht.fnl b/blinkenlicht/init.fnl
diff --git a/default.nix b/default.nix
@@ -1,19 +1,30 @@
{ stdenv
, callPackage
, fennel
+, gobject-introspection
+, gtk3
+, gtk-layer-shell
, lua5_3
} :
let
fennel_ = (fennel.override { lua = lua5_3; });
luaWithPackages = lua5_3.withPackages (ps: with ps; [
(toLuaModule fennel_)
- busted
+ lgi
+ luaposix
]);
- kiwmi = callPackage ./kiwmi.nix { lua = luaWithPackages; };
+ kiwmi = callPackage ./kiwmi.nix { lua = lua5_3; };
in
stdenv.mkDerivation {
pname = "eufon";
version = "0.1";
- buildInputs = [ luaWithPackages kiwmi ];
+ buildInputs = [
+ luaWithPackages
+ kiwmi
+ gobject-introspection.dev
+ gtk-layer-shell
+ gtk3
+ ];
+
src = ./.;
}
diff --git a/fennelrun.lua b/fennelrun.lua
@@ -0,0 +1,4 @@
+local fennel = require("fennel")
+table.insert(package.loaders or package.searchers, fennel.searcher)
+-- print(fennel.view(arg))
+fennel.dofile(arg[0])
diff --git a/blinkenlicht/licht.css b/modeline.css
diff --git a/modeline.fnl b/modeline.fnl
@@ -0,0 +1,52 @@
+(local {: bar : indicator : stylesheet : run} (require :blinkenlicht))
+
+(local {: view} (require :fennel))
+
+(local iostream (require :blinkenlicht.iostream))
+;(local modem (require :blinkenlicht.modem))
+
+;(local uplink (require :blinkenlicht.metric.uplink))
+;(local battery (require :blinkenlicht.metric.battery))
+(local cpustat (require :blinkenlicht.metric.cpustat))
+
+(stylesheet "licht.css")
+
+(fn battery-icon-codepoint [status percent]
+ (if (= status "Charging") 0xf0e7
+ (> percent 90) 0xf240 ;full
+ (> percent 60) 0xf241 ;3/4
+ (> percent 40) 0xf242 ;1/2
+ (> percent 15) 0xf243 ;1/4
+ (>= percent 0) 0xf244 ;empty
+ ; 0xf377 ; glyph not present in font-awesome free
+ ))
+
+(fn wlan-quality-class [quality]
+ (if (< -50 quality) "p100"
+ (< -67 quality) "p75"
+ (< -70 quality) "p50"
+ (< -80 quality) "p25"
+ "p0"))
+
+(fn spawn []
+ true)
+
+(bar
+ {
+ ;; bar must be full width to set up an "exclusive zone" (moves
+ ;; other windows out of the way), otherwise it will display on
+ ;; to of whatever's on the screen already
+ :anchor [:top :right :left]
+ :orientation :horizontal
+ :gravity :end
+ :classes ["hey"]
+ :indicators
+ [
+ (indicator {
+ :wait-for { :interval 4000 }
+ :refresh #{:text (os.date "%H:%M")}
+ })
+
+ ]})
+
+(run)
diff --git a/rc.fnl b/rc.fnl
@@ -1,4 +1,6 @@
(kiwmi:on "output" #(doto $1 (: :set_mode 360 720 0)))
-(kiwmi:spawn "swaybg -c '#ff00ff'")
+
+;(kiwmi:spawn "swaybg -c '#ff00ff'")
+(kiwmi:spawn "lua -l fennelrun modeline.fnl")
(kiwmi:spawn "foot")