Skip to content

[FEATURE] Add executable option for evtest in Bongo Cat plugin #4

Description

@NousadS

(Copied from the main github repository, since there aren't any templates configured for this repo.)

Submission checklist

  • I have searched existing issues and confirmed this has not been requested before.
  • I have checked existing pull requests for similar changes.

Feature type

Configuration / customization

Feature summary

Add an option for the path to the evtest executable in the Bongo Cat plugin.

Motivation / use case

The path to evtest is currently hardcoded (bongocat.luau#L232-L241). This breaks functionality/philosophy on non-FHS systems like NixOS, where binaries live in isolated store paths rather than a global PATH. Adding a configuration setting to manually define the path would fix this.

Proposed solution

bongocat/plugin.toml:

# ...

[[widget]]
id = "cat"
entry = "bongocat.luau"

  [[widget.setting]]
  key = "executable_path"
  type = "file"
  label_key = "settings.executable_path.label" # ! Needs to be translated
  description_key = "settings.executable_path.description" # ! Needs to be translated
  default = "/usr/bin/evtest" # or just "evtest"

# ...

bongocat/bongocat.luau:

# ...

local function startInputReader()
  local devices = barWidget.getConfig("input_devices")
  if devices == nil then
    return
  end
  if type(devices) ~= "table" then
    noctalia.notifyError("Bongo Cat", "Invalid input_devices (expected a list of /dev/input paths or globs)")
    return
  end

  local patterns = {}
  local seen = {}
  local warnedEventPath = false
  for _, pattern in ipairs(devices) do
    if not validateInputPattern(pattern) then
      noctalia.notifyError("Bongo Cat", `Invalid input_devices entry: {tostring(pattern)}`)
      return
    end
    if pattern:match("^/dev/input/event") ~= nil and not warnedEventPath then
      warnedEventPath = true
      noctalia.notify("Bongo Cat", "Prefer /dev/input/by-id or /dev/input/by-path; /dev/input/eventN can change.")
    end
    if seen[pattern] == nil then
      seen[pattern] = true
      table.insert(patterns, pattern)
    end
  end
  if #patterns == 0 then
    return
  end

  local executable = barWidget.getConfig("executable_path") or "evtest"

  if not noctalia.commandExists(executable) then
    noctalia.notifyError("Bongo Cat", "the evtest path is invalid (" .. executable .. ") — cannot read input devices")
    return
  end

  local command = "for device in " .. table.concat(patterns, " ")
      .. '; do [ -e "$device" ] || continue; ' .. executable 
      .. ' "$device" 2>/dev/null & done; wait'

  if not noctalia.runStream(command, onEvtestLine) then
    noctalia.notifyError("Bongo Cat", "Unable to start input device reader")
  end
end

# ...
@@ -229,13 +229,18 @@ 
local function startInputReader()
   if #patterns == 0 then
     return
   end
-  if not noctalia.commandExists("evtest") then
-    noctalia.notifyError("Bongo Cat", "evtest is not installed — cannot read input devices")
+
+  local executable = barWidget.getConfig("executable_path") or "evtest"
+
+  if not noctalia.commandExists(executable) then
+    noctalia.notifyError("Bongo Cat", "the evtest path is invalid (" .. executable .. ") — cannot read input devices")
     return
   end

   local command = "for device in " .. table.concat(patterns, " ")
-      .. '; do [ -e "$device" ] || continue; evtest "$device" 2>/dev/null & done; wait'
+      .. '; do [ -e "$device" ] || continue; ' .. executable
+      .. ' "$device" 2>/dev/null & done; wait'
+
   if not noctalia.runStream(command, onEvtestLine) then
     noctalia.notifyError("Bongo Cat", "Unable to start input device reader")
   end

References / related projects

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions