dotfiles

My PC Dotfiles & Website

files/noctalia/hypr-submap/submap.luau (1206B)


 1-- Hyprland Submap Indicator bar widget
 2
 3local glyph = noctalia.getConfig("glyph")
 4local showGlyph = noctalia.getConfig("show_glyph")
 5local aliasList = noctalia.getConfig("aliases")
 6local command = noctalia.getConfig("command")
 7
 8-- Aliases
 9local aliases = {}
10if type(aliasList) == "table" then
11  for _, entry in ipairs(aliasList) do
12    local key, label = string.match(entry, "^([^=]+)=(.*)$")
13    if key ~= nil then
14      aliases[key] = label
15    end
16  end
17end
18
19local function apply(name)
20  if name == nil or name == "" then
21    barWidget.setText("")
22    barWidget.setTooltip("")
23    barWidget.setVisible(false)
24    return
25  end
26
27  local display = aliases[name] or name
28
29  if showGlyph then
30    barWidget.setGlyph(glyph)
31  end
32  barWidget.setText(display)
33  barWidget.setTooltip(noctalia.tr("active") .. display)
34  barWidget.setVisible(true)
35end
36
37-- Static otherwise: slow periodic tick down
38function update()
39  noctalia.setUpdateInterval(60000)
40end
41
42-- Start hidden until first event arrives
43apply("")
44
45if command ~= nil and command ~= "" then
46  noctalia.runStream(command, function(line)
47    local name = string.match(line, "^submap>>(.*)$")
48    if name ~= nil then
49      apply(name)
50    end
51  end)
52end