Skip to content

Commit

Permalink
Adjust require() calls so they work in a Spoon
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed Jan 25, 2023
1 parent bc47aed commit 68074b2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
3 changes: 2 additions & 1 deletion application.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local application = {}

local utils = require((...):gsub("[^.]+$", "utils"))
local knu = hs.loadSpoon("Knu")
local utils = knu.utils

local registry = {}

Expand Down
5 changes: 3 additions & 2 deletions chord.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ local chord = {}
local keyDown = hs.eventtap.event.types.keyDown
local keyUp = hs.eventtap.event.types.keyUp

local utils = require((...):gsub("[^.]+$", "utils"))
local runtime = require((...):gsub("[^.]+$", "runtime"))
local knu = hs.loadSpoon("Knu")
local utils = knu.utils
local runtime = knu.runtime

local activeChords = {}

Expand Down
3 changes: 2 additions & 1 deletion http.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local http = {}

local fnutils = hs.fnutils
local utils = require((...):gsub("[^.]+$", "utils"))
local knu = hs.loadSpoon("Knu")
local utils = knu.utils

-- This is a wrapperr of hs.http.urlParts() that adds a "params" table
-- and lowercases the "scheme" and "host" fields.
Expand Down
6 changes: 2 additions & 4 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local __namespace__, __file__ = ...
__namespace__ = __namespace__:gsub("%.init$", "") -- just in case
local __dir__ = __file__:match("^(.*)/[^/]+$")
local __dir__ = hs.spoons.scriptPath()

local knu = {
name = "Knu",
Expand All @@ -11,7 +9,7 @@ local knu = {
}

local function loadModule(name)
knu[name] = require(__namespace__ .. "." .. name)
knu[name] = dofile(hs.spoons.resourcePath(name .. ".lua"))
return knu[name]
end

Expand Down
3 changes: 2 additions & 1 deletion keyboard.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local keyboard = {}

local utils = require((...):gsub("[^.]+$", "utils"))
local knu = hs.loadSpoon("Knu")
local utils = knu.utils

-- Some of the known Japanese input source IDs:
-- com.apple.inputmethod.Kotoeri.Japanese
Expand Down
3 changes: 2 additions & 1 deletion mouse.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local mouse = {}

local runtime = require((...):gsub("[^.]+$", "runtime"))
local knu = hs.loadSpoon("Knu")
local runtime = knu.runtime

-- Creates a hold-to-scroll button mode
--
Expand Down
7 changes: 4 additions & 3 deletions photkey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ local photkey = {}

local keyDown = hs.eventtap.event.types.keyDown

local runtime = require((...):gsub("[^.]+$", "runtime"))
local utils = require((...):gsub("[^.]+$", "utils"))
local keyboard = require((...):gsub("[^.]+$", "keyboard"))
local knu = hs.loadSpoon("Knu")
local runtime = knu.runtime
local utils = knu.utils
local keyboard = knu.keyboard

photkey.methods = {
-- Provide hotkey compatible API for convenience
Expand Down

0 comments on commit 68074b2

Please sign in to comment.