

Local newtab = hs.osascript.applescript(command_to_open) Local command_to_open = 'tell app "safari" to set the url of (make new tab in window 1) to "https:/sci-hub.tw/'. Local bo, obj, desc = hs.osascript.applescript('tell app "safari" to get the url of current tab of window 1') get url of current active safari window SCI-HUB with CMD + ALT + CTRL + h on safari tab So I automated the task with a function and a keybinding programmed in lua for those of you using (the wonderful!) hammerspoon. In contrast to other browsers, there's no legal (is that the word?) Safari extension to open current publication without having to load sci-hub site and pasting the url. Optional callback for when a modal is exitedTypical scenario: using Safari to search for a reference, end up at a journal's site to which I have no access.
#BIND A HOTKEY HAMMERSPOON EXAMPLE MODS#
mods - A table or a string containing (as elements, or as substrings with any separator) the keyboard modifiers required, which should be zero or more of the following:.Hs.(mods, key, message) -> hs.hotkey.modal objectĬreates a new modal state, optionally with a global keyboard combination to trigger it Methods - API calls which can only be made on an object returned by a constructorĪPI Documentation Constructors new Signature.

Constructors - API calls which return an object, typically one that offers API methods.alert 'Exited mode' end k : bind ( '', 'escape', function () k : exit () end ) k : bind ( '', 'J', 'Pressed J', function () print 'let the record show that J was pressed' end ) ``` API Overview alert 'Entered mode' end function k : exited () hs. new ( 'cmd-shift', 'd' ) function k : entered () hs.
