railvast.blogg.se

Bind a hotkey hammerspoon example
Bind a hotkey hammerspoon example













bind a hotkey hammerspoon example

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.

  • This method will disable all of the hotkeys defined in the modal state, and enable the hotkey for entering the modal state (if one was defined).
  • Hs.hotkey.modal:exit() -> hs.hotkey.modal object
  • This is a pre-existing function that you should override if you need to use it the default implementation does nothing.
  • Optional callback for when a modal is entered
  • If the modal state was created with a keyboard combination, this method will be called automatically.
  • This method will enable all of the hotkeys defined in the modal state via hs.hotkey.modal:bind(),Īnd disable the hotkey that entered the modal state (if one was defined).
  • Hs.hotkey.modal:enter() -> hs.hotkey.modal object
  • The hs.hotkey.modal object for method chainingĭeletes a modal hotkey object without calling :exited().
  • repeatfn - A function that will be called when a pressed hotkey is repeating, or nil.
  • releasedfn - A function that will be called when the hotkey has been released, or nil.
  • pressedfn - A function that will be called when the hotkey has been pressed, or nil.
  • Hs.hotkey.modal:bind(mods, key, message, pressedfn, releasedfn, repeatfn) -> hs.hotkey.modal objectĬreates a hotkey that is enabled/disabled as the modal is entered/exited
  • If key is nil, no global hotkey will be registered (all other parameters will be ignored).
  • message - A string containing a message to be displayed via hs.alert() when the hotkey has been triggered, or nil for no alert.
  • key - A string containing the name of a keyboard key (as found in hs.keycodes.map ), or a raw keycode number.
  • #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.

    bind a hotkey hammerspoon example

    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.















    Bind a hotkey hammerspoon example