1、咖啡因快捷键与系统复制路径快捷键相冲突,修改咖啡因快捷键
2、修改Json显示快捷键逻辑
3、修复内存占用显示有误问题
4、修复窗口切换问题
This commit is contained in:
sugood 2022-04-10 21:16:29 +08:00
parent eae3fe48e1
commit af7df6d3f5
4 changed files with 40 additions and 27 deletions

View File

@ -4,7 +4,7 @@
--- DateTime: 2020/10/24 14:13
---
local console = require("hs.console")
version = "v0.1.4"
version = "v0.1.8"
configPath= "~/.hammerspoon/data/config.json"
initConfigPath= "~/.hammerspoon/data/initConfig.json"
config = {}
@ -284,7 +284,7 @@ hs.hotkey.bind(hyperCmd, "P", function ()
openColorDialog()
end)
--设置颜色拾取快键键
hs.hotkey.bind(hyperCmd, "C", function ()
--设置咖啡因开关
hs.hotkey.bind(hyperCmd, "S", function ()
switchCaffeine()
end)

View File

@ -6,13 +6,6 @@
--
--
--- KSheet:hide()
--- Method
--- Hide the cheatsheet view.
function hide(time)
sheetView:hide(time)
end
function init()
local cscreen = hs.screen.mainScreen()
local cres = cscreen:fullFrame()
@ -20,9 +13,9 @@ function init()
x = cres.x+cres.w*0.15/2,
y = cres.y+cres.h*0.25/2,
w = cres.w*0.85,
h = cres.h*0.75
h = cres.h*1.0
})
sheetView:windowTitle("CheatSheets")
sheetView:windowTitle("JsonFormat")
sheetView:windowStyle("utility")
sheetView:titleVisibility("hidden")
sheetView:allowGestures(true)
@ -35,17 +28,25 @@ function init()
sheetView:shadow(true)
sheetView:alpha(1)
sheetView:level(hs.drawing.windowLevels.mainMenu)
sheetView:url("https://i.sugood.xyz/pages/jsonweb.html")
end
--- KSheet:hide()
--- Method
--- Hide the JsonFormat view.
function hide(time)
sheetView:hide(time)
end
--- KSheet:show()
--- Method
--- Show current application's keybindings in a view.
--- Show JsonFormat.
function show(time)
bindCopyKey()
local str = hs.pasteboard.getContents()
-- local webcontent = generateHtml()
-- sheetView:html(webcontent, "http://localhost")
sheetView:url("https://i.sugood.xyz/pages/jsonweb.html")
-- sheetView:url("https://i.sugood.xyz/pages/jsonweb.html")
sheetView:show(time)
end

View File

@ -156,21 +156,31 @@ end
function getVmStats()
local vmStats = hs.host.vmStat()
--1024^2
local megDiv = 1048576
local megMulti = vmStats.pageSize / megDiv
-- --1024^2
-- local megDiv = 1048576
-- local megMulti = vmStats.pageSize / megDiv
local totalMegs = vmStats.memSize / megDiv --总内存
local megsCached = vmStats.fileBackedPages * megMulti --缓存内存
local freeMegs = vmStats.pagesFree * megMulti --空闲内存
-- local totalMegs = vmStats.memSize / megDiv --总内存
-- local megsCached = vmStats.fileBackedPages * megMulti --缓存内存
-- local freeMegs = vmStats.pagesFree * megMulti --空闲内存
--第一种方法使用 APP内存+联动内存+被压缩内存 = 已使用内存
-- local megsUsed = vmStats.pagesWiredDown * megMulti -- 联动内存
-- megsUsed = megsUsed + vmStats.pagesUsedByVMCompressor * megMulti -- 被压缩内存
-- megsUsed = megsUsed + (vmStats.pagesActive +vmStats.pagesSpeculative)* megMulti -- APP内存
-- --第一种方法使用 APP内存+联动内存+被压缩内存 = 已使用内存
-- --local megsUsed = vmStats.pagesWiredDown * megMulti -- 联动内存
-- --megsUsed = megsUsed + vmStats.pagesUsedByVMCompressor * megMulti -- 被压缩内存
-- --megsUsed = megsUsed + (vmStats.pagesActive +vmStats.pagesSpeculative)* megMulti -- APP内存
--第二种方法使用 总内存-缓存内存-空闲内存 = 已使用内存
local megsUsed = totalMegs - megsCached - freeMegs
-- --第二种方法使用 总内存-缓存内存-空闲内存 = 已使用内存
-- local megsUsed = totalMegs - megsCached - freeMegs
--第三种方法由于部分设备pageSize获取不正确所以只能通过已使用页数+缓存页数+空闲页数计算总页数
local megsUsed = vmStats.pagesWiredDown -- 联动内存
megsUsed = megsUsed + vmStats.pagesUsedByVMCompressor -- 被压缩内存
megsUsed = megsUsed + vmStats.pagesActive +vmStats.pagesSpeculative -- APP内存
local megsCached = vmStats.fileBackedPages --缓存内存
local freeMegs = vmStats.pagesFree --空闲内存
local totalMegs = megsUsed + megsCached + freeMegs
local usedMem = megsUsed/totalMegs * 100
return formatPercent(usedMem)

View File

@ -131,7 +131,9 @@ function focusScreen(screen)
window.orderedWindows(),
fnutils.partial(isInScreen, screen))
local windowToFocus = #windows > 0 and windows[1] or window.desktop()
if(windowToFocus ~=nil ) then
windowToFocus:focus()
end
-- move cursor to center of screen
local pt = geometry.rectMidPoint(screen:fullFrame())