diff --git a/.config/waybar/config.cgt b/.config/waybar/config.cgt
index a997749..2be7818 100644
--- a/.config/waybar/config.cgt
+++ b/.config/waybar/config.cgt
@@ -1,134 +1,58 @@
-// vim: ft=jsonc
-{
- // "layer": "top", // Waybar at top layer
- // "position": "bottom", // Waybar position (top|bottom|left|right)
- "height": 16, // Waybar height (to be removed for auto height)
- // "width": 1280, // Waybar width
- "spacing": 4, // Gaps between modules (4px)
- "layer": "top",
- //
- "modules-left": [
- "river/tags"
- ],
- "modules-center": [
- "river/window"
- ],
- //
- "modules-left": [
- "hyprland/workspaces",
- "hyprland/window"
- ],
- //
- "modules-right": [
- "mpris",
- "cpu",
- "memory",
- "pulseaudio",
- "gamemode",
- "temperature",
- "battery",
- "battery#bat2",
- "clock",
- "tray"
- ],
- "mpris": {
- "format": "{status_icon} {dynamic}",
- "dynamic-order": [
- "title",
- "artist",
- "position",
- "length"
- ],
- "dynamic-importance-order": [
- "title",
- "position",
- "length",
- "artist",
- "album"
- ],
- "status-icons": {
- "playing": "",
- "paused": "",
- "stopped": ""
- },
- "dynamic-len": 50,
- "dynamic-separator": " "
- },
- "gamemode": {
- "format": "{glyph} {count}"
- },
- "tray": {
- // "icon-size": 21,
- "spacing": 10
- },
- "clock": {
- // "timezone": "America/New_York",
- "tooltip-format": "{:%Y %B}\n{calendar}",
- "format-alt": "{:%Y-%m-%d}"
- },
- "cpu": {
- "format": "{usage}% ",
- "tooltip": false
- },
- "memory": {
- "format": "{}% "
- },
- "temperature": {
- // "thermal-zone": 2,
- "hwmon-path": "<% opt.cpu_temp_hwmon %>",
- "critical-threshold": 80,
- // "format-critical": "{temperatureC}°C {icon}",
- "format": "{temperatureC}°C {icon}",
- "format-icons": [
- "",
- "",
- ""
- ]
- },
- "battery": {
- "states": {
- // "good": 95,
- "warning": 30,
- "critical": 15
- },
- "format": "{capacity}% {icon}",
- "format-charging": "{capacity}% ",
- "format-plugged": "{capacity}% ",
- "format-alt": "{time} {icon}",
- // "format-good": "", // An empty format will hide the module
- // "format-full": "",
- "format-icons": [
- "",
- "",
- "",
- "",
- ""
- ]
- },
- "battery#bat2": {
- "bat": "BAT2"
- },
- "pulseaudio": {
- // "scroll-step": 1, // %, can be a float
- "format": "{volume}% {icon} {format_source}",
- "format-bluetooth": "{volume}% {icon} {format_source}",
- "format-bluetooth-muted": " {icon} {format_source}",
- "format-muted": " {format_source}",
- "format-source": "{volume}% ",
- "format-source-muted": "",
- "format-icons": {
- "headphone": "",
- "hands-free": "",
- "headset": "",
- "phone": "",
- "portable": "",
- "car": "",
- "default": [
- "",
- "",
- ""
- ]
- },
- "on-click": "pavucontrol"
- },
-}
+;
+;; vim: ft=fennel
+{:spacing 4
+ :layer :top
+ ;
+ :modules-left [:river/tags :river/window]
+ ;
+ :modules-left [:hyprland/workspaces :hyprland/window]
+ ;
+ :modules-right [:mpris
+ :cpu
+ :memory
+ :pulseaudio
+ :gamemode
+ :temperature
+ :battery
+ :clock
+ :tray]
+ :mpris {:format "{status_icon} {dynamic}"
+ :dynamic-order [:title :artist :position :length]
+ :dynamic-importance-order [:title :position :length :artist :album]
+ :status-icons {:playing "" :paused "" :stopped ""}
+ :dynamic-len 50
+ :dynamic-separators " "}
+ :gamemode {:format "{glyph} {count}"}
+ :tray {:spacing 10}
+ :clock {:tooltip-format "{:%Y %B}\n{calendar}"
+ :format-alt "{:%Y-%m-%d}"}
+ :cpu {:format "{usage}% "}
+ :memory {:format "{}% "}
+ :temperature {:hwmon-path "<% opt.cpu_temp_hwmon %>"
+ :critical-threshold 80
+ :format "{temperatureC}°C {icon}"
+ :format-icons ["" "" ""]}
+ :battery {:states {:warning 50 :critical 20}
+ :format "{capacity}% {icon}"
+ :format-charging "{capacity}% "
+ :format-plugged "{capacity}% "
+ :format-alt "{time} {icon}"
+ :format-icons ["" "" "" "" ""]}
+ :pulseaudio (let [fstring (fn [muted bluetooth]
+ (.. (if muted "" "{volume}%")
+ (if (and muted (not bluetooth)) "" " {icon}")
+ (if bluetooth "" "") " {format_source}"))]
+ {:format (fstring false false)
+ :format-muted (fstring true false)
+ :format-bluetooth (fstring false true)
+ :format-bluetooth-muted (fstring true true)
+ :format-source "{volume}% "
+ :format-source-muted ""
+ :format-icons {:headphone ""
+ :hands-free ""
+ :headset ""
+ :phone ""
+ :portable ""
+ :car ""
+ :default ["" "" ""]}
+ :on-click :pavucontrol})}
diff --git a/confgen.lua b/confgen.lua
index eddc635..883ceb5 100644
--- a/confgen.lua
+++ b/confgen.lua
@@ -21,6 +21,8 @@ cg.onDone(function(errors)
end
end)
+local fennel = loadfile("/usr/share/lua/5.4/fennel.lua")()
+
-- Recursively merge 2 tables
local function merge(a, b)
if b[1] then -- b is a list
@@ -83,19 +85,11 @@ cg.opt.luaCompile = function(lua)
end
-- Compile the input as fennel. Meant to be used as a post-processor.
-cg.opt.fennelCompile = function(fnl)
- local handle = io.popen("fennel -c - > /tmp/cgfnl", "w")
- if handle == nil then
- error "Failed to spawn fennel"
- end
+cg.opt.fennelCompile = fennel.compileString
- handle:write(fnl)
- handle:close()
-
- local f = io.open "/tmp/cgfnl"
- local res = f:read "*a"
- f:close()
- return res
+-- Evaluate fennel code and JSONify the result. Meant to be used as a post-processor.
+cg.opt.fennelToJSON = function(str)
+ return cg.toJSON(fennel.eval(str))
end
-- Check if the given file exists