Skip to content

Instantly share code, notes, and snippets.

@jakemayeux
Created April 22, 2017 02:52
Show Gist options
  • Save jakemayeux/3d3d71ff0fd4061b8b0df13e845c107e to your computer and use it in GitHub Desktop.
Save jakemayeux/3d3d71ff0fd4061b8b0df13e845c107e to your computer and use it in GitHub Desktop.
icon = hs.menubar.new()
-- icon2 = hs.menubar.new()
icon:setMenu({
{ title = hs.battery.capacity().." mAh"},
})
icon:setTitle(hs.battery.amperage().." mAh")
function mAhUpdate()
icon:setTitle(hs.battery.amperage().." mAh")
end
hs.timer.doEvery(30, mAhUpdate)
function mouseMove()
hs.window.focusedWindow():setTopLeft(hs.geometry.copy(winpos):move(hs.geometry(hs.mouse.getAbsolutePosition()):move(smpos)))
end
moveTimer = hs.timer.new(0.02, mouseMove)
hs.hotkey.bind('alt', 'a', function ()
smpos = hs.geometry(hs.mouse.getAbsolutePosition()):scale(-1)
winpos = hs.window.focusedWindow():topLeft()
moveTimer:start()
end, function()
moveTimer:stop()
end)
function mouseSize()
dx = hs.mouse.getAbsolutePosition().x - sx
dy = hs.mouse.getAbsolutePosition().y - sy
hs.window.focusedWindow():setSize(hs.geometry({w=sw+dx,h=sh+dy}))
--hs.window.focusedWindow():setTopLeft(hs.geometry.copy(winofs):move({-dx/2,-dy/2}))
end
sizeTimer = hs.timer.new(0.02, mouseSize)
hs.hotkey.bind('alt', 's', function ()
--winofs = hs.window.focusedWindow():topLeft()
sx = hs.mouse.getAbsolutePosition().x
sy = hs.mouse.getAbsolutePosition().y
sw = hs.window.focusedWindow():size().w
sh = hs.window.focusedWindow():size().h
sizeTimer:start()
end, function()
sizeTimer:stop()
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment