Skip to content

Commit

Permalink
Updates from kiryo
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsj committed Dec 24, 2019
1 parent aa00a04 commit 424d6e5
Show file tree
Hide file tree
Showing 11 changed files with 863 additions and 634 deletions.
28 changes: 27 additions & 1 deletion Spoons/Caffeine.spoon/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
""
],
"name" : "bindHotkeys",
"parameters" : [
" * mapping - A table containing hotkey modifier\/key details for the following items:",
" * toggle - This will toggle the state of display sleep prevention, and update the menubar graphic",
""
],
"notes" : [

],
Expand All @@ -65,6 +70,10 @@
""
],
"name" : "start",
"parameters" : [
" * None",
""
],
"notes" : [

],
Expand All @@ -87,6 +96,10 @@
""
],
"name" : "stop",
"parameters" : [
" * None",
""
],
"notes" : [

],
Expand All @@ -112,6 +125,11 @@
""
],
"name" : "bindHotkeys",
"parameters" : [
" * mapping - A table containing hotkey modifier\/key details for the following items:",
" * toggle - This will toggle the state of display sleep prevention, and update the menubar graphic",
""
],
"notes" : [

],
Expand All @@ -134,6 +152,10 @@
""
],
"name" : "start",
"parameters" : [
" * None",
""
],
"notes" : [

],
Expand All @@ -156,6 +178,10 @@
""
],
"name" : "stop",
"parameters" : [
" * None",
""
],
"notes" : [

],
Expand All @@ -170,4 +196,4 @@
],
"name" : "Caffeine"
}
]
]
14 changes: 0 additions & 14 deletions Spoons/Caffeine.spoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,9 @@ obj.__gc = function(t)
t:stop()
end

-- Metadata
obj.name = "Caffeine"
obj.version = "1.0"
obj.author = "Chris Jones <[email protected]>"
obj.homepage = "https://github.com/Hammerspoon/Spoons"
obj.license = "MIT - https://opensource.org/licenses/MIT"

obj.menuBarItem = nil
obj.hotkeyToggle = nil

-- Internal function used to find our location, so we know where to load files from
local function script_path()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*/)")
end
obj.spoonPath = script_path()

function obj:init()
end

Expand Down
9 changes: 9 additions & 0 deletions Spoons/Caffeine.spoon/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Caffeine",
"version": "1.0",
"author": "Chris Jones",
"author_email": "[email protected]",
"homepage": "https://github.com/Hammerspoon/Spoons",
"license": "MIT",
"license_url": "https://opensource.org/licenses/MIT"
}
58 changes: 43 additions & 15 deletions Spoons/Seal.spoon/seal_apps.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
--- === Seal.plugins.apps ===
---
--- A plugin to add launchable apps/scripts, making Seal act as a launch bar
local obj = {}
obj.__index = obj
obj.__name = "seal_apps"
obj.appCache = {}

--- Seal.plugins.apps.appSearchPaths
--- Variable
--- Table containing the paths to search for launchable items
---
--- Notes:
--- * If you change this, you will need to call `spoon.Seal.plugins.apps:restart()` to force Spotlight to search for new items.
obj.appSearchPaths = {
"/Applications",
"/System/Applications",
"~/Applications",
"/Developer/Applications",
"/Applications/Xcode.app/Contents/Applications",
Expand All @@ -19,25 +30,27 @@ obj.appSearchPaths = {

local modifyNameMap = function(info, add)
for _, item in ipairs(info) do
icon = nil
local displayname = item.kMDItemDisplayName or hs.fs.displayName(item.kMDItemPath)
displayname = displayname:gsub("%.app$", "", 1)
if string.find(item.kMDItemPath, "%.prefPane$") then
displayname = displayname .. " preferences"
if add then
icon = hs.image.iconForFile(item.kMDItemPath)
end
end
if add then
bundleID = item.kMDItemCFBundleIdentifier
icon = nil
if bundleID then
icon = hs.image.imageFromAppBundle(bundleID)
end
local displayname = item.kMDItemDisplayName
displayname = displayname:gsub("%.app$", "", 1)
if string.find(item.kMDItemPath, "%.prefPane$") then
displayname = item.kMDItemDisplayName .. " preferences"
icon = hs.image.iconForFile(item.kMDItemPath)
if (not icon) and (bundleID) then
icon = hs.image.imageFromAppBundle(bundleID)
end
obj.appCache[displayname] = {
path = item.kMDItemPath,
bundleID = bundleID,
icon = icon
}
else
obj.appCache[item.kMDItemDisplayName] = nil
obj.appCache[displayname] = nil
end
end
end
Expand All @@ -54,12 +67,27 @@ local updateNameMap = function(obj, msg, info)
end
end

function obj:start()
obj.spotlight = hs.spotlight.new():queryString([[ (kMDItemContentType = "com.apple.application-bundle") || (kMDItemContentType = "com.apple.systempreference.prefpane") || (kMDItemContentType = "com.apple.applescript.text") || (kMDItemContentType = "com.apple.applescript.script") ]])
:callbackMessages("didUpdate", "inProgress")
:setCallback(updateNameMap)
:searchScopes(obj.appSearchPaths)
:start()
end

function obj:stop()
obj.spotlight:stop()
obj.spotlight = nil
obj.appCache = {}
end

function obj:restart()
self:stop()
self:start()
end

hs.application.enableSpotlightForNameSearches(true)
obj.spotlight = hs.spotlight.new():queryString([[ (kMDItemContentType = "com.apple.application-bundle") || (kMDItemContentType = "com.apple.systempreference.prefpane") || (kMDItemContentType = "com.apple.applescript.text") || (kMDItemContentType = "com.apple.applescript.script") ]])
:callbackMessages("didUpdate", "inProgress")
:setCallback(updateNameMap)
:searchScopes(obj.appSearchPaths)
:start()
obj:start()

function obj:commands()
return {kill = {
Expand Down
3 changes: 3 additions & 0 deletions Spoons/Seal.spoon/seal_pasteboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function obj.checkPasteboard()
-- FIXME: Filter out things with UTIs documented at http://nspasteboard.org/
if (#obj.itemBuffer == 0) or (pasteboard ~= obj.itemBuffer[#obj.itemBuffer]["text"]) then
local currentTypes = hs.pasteboard.allContentTypes()[1]
if currentTypes == nil then
return
end
for _,aType in pairs(currentTypes) do
for _,uti in pairs({"de.petermaurer.TransientPasteboardType",
"com.typeit4me.clipping",
Expand Down
Loading

0 comments on commit 424d6e5

Please sign in to comment.