scottcs / dot_hammerspoon Goto Github PK
View Code? Open in Web Editor NEWMy Hammerspoon config
License: MIT License
My Hammerspoon config
License: MIT License
It would be nice to be able to have different cheatsheets based on the currently open URL in a web browser. I'm not sure how to grab the URL from each browser, yet, though. I haven't looked into it.
It's too specific to my own personal setup right now. I like being able to have different cheatsheets for different tmux panes, sheets based on current running commands in the shell, and especially sheets based on current open filetype in nvim. This is all currently working, but requires too much specific setup and code. I'd like to refactor this to be more generic and extensible.
I have run into an odd issue with your browser module that just started happening out of the blue (possibly after the last hammerspoon update, I'm not sure).
I run both Safari and Chrome, have two monitors and multiple spaces on OS X 10.11.6. When I have the browser module enabled for both Safari and Chrome and click on a link, I end up on an empty space that has no browser windows running on it. When I return to the original space I was in, I find the link opened in the correct browser as expected.
I'm assuming this is some interaction between your module and https://github.com/asmagill/hs._asm.undocumented.spaces, but I have no idea what it could be from a quick look at the code. Any ideas?
2019-08-20 15:00:24: hazel: Moved /Users/cocobear/Downloads/687474703a2f2f692e696d6775722e636f6d2f6662756b436e782e6a7067.jpeg to /Users/cocobear/Dump
2019-08-20 15:00:24: hazel: Moved /Users/cocobear/Downloads/zprof-0.1.tar.gz to /Users/cocobear/Dump
2019-08-20 15:00:24: hazel: Moved /Users/cocobear/Downloads/门锁 (1).png to /Users/cocobear/Dump
result:
.rw-r--r--@ 160M cocobear 02-28 10:04 /Users/cocobear/Dump
all file had gone, except the last one.
:-(
Do you have any interest in code to auto-populate new cheatsheets from the application menus? I adapted the code below from https://github.com/dharmapoudel/hammerspoon-config. I'm using tables in my cheatsheets since I like the way they look, and since the format is hard-coded into getAllMenuItems you would have to edit the code to change it. I've been trying to come up with a way to make the format configurable, but haven't come up with any ideas I like.
I added the below code to cheatsheets.lua and added a call to
ufile.append(file, getAllMenuItems(hs.application.frontmostApplication():getMenuItems()))
after the ufile.create() in editCheatSheet(). (if you prefer I can send you a pull request with my changes if you want to include them)
-- Walk application menus to auto-populate new cheatsheet
-- Original code from https://github.com/dharmapoudel/hammerspoon-config
-- Map modifiers to MenuBarItem modifier indicies
local commandEnum = {
[0] = '⌘',
[1] = '⇧ ⌘',
[2] = '⌥ ⌘',
[3] = '⌥ ⇧ ⌘',
[4] = '⌃ ⌘',
[5] = '⇧ ⌃ ⌘',
[6] = '⌃ ⌥ ⌘',
[7] = '',
[8] = '⌦',
[9] = '',
[10] = '⌥',
[11] = '⌥ ⇧',
[12] = '⌃',
[13] = '⌃ ⇧',
[14] = '⌃ ⌥',
}
local function getAllMenuItems(app)
local menu = ''
for pos,val in pairs(app) do
if(type(val)=='table') then
-- do not include help menu for now until I find best way to remove menubar items with no shortcuts in them
if(val['AXRole'] =='AXMenuBarItem' and type(val['AXChildren']) == 'table') and val['AXTitle'] ~='Help' then
menu = menu..val['AXTitle']..'\n'..string.rep('=',string.len(val['AXTitle']))..'\n\n'
menu = menu..'| | |\n'
menu = menu..'| ---: | ------------------------------------------------------- |\n'
menu = menu.. getAllMenuItems(val['AXChildren'][1])
menu = menu..'\n'
elseif(val['AXRole'] =='AXMenuItem' and not val['AXChildren']) then
if( val['AXMenuItemCmdModifiers'] ~='0' and val['AXMenuItemCmdChar'] ~='') then
menu = menu..'| '..commandEnum[val['AXMenuItemCmdModifiers']]..' '..val['AXMenuItemCmdChar']..' | '..val['AXTitle']..' |\n'
end
elseif(val['AXRole'] =='AXMenuItem' and type(val['AXChildren']) == 'table') then
menu = menu..getAllMenuItems(val['AXChildren'][1])
end
end
end
return menu
end
Great work, you've given me some good ideas for my hammerspoon config! (and made me rewrite a bunch of my code :-) )
Any chance you can share some cheatsheet examples? It's just markdown so not that hard to create my own, but seeing what you are already doing could help to give me some direction.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.