Class dkb.filter

Class to bind keys only when specific window(s) are focused.

Uses hs.window.filter to filter windows and hs.hotkey.modal to set the bindings behind the scenes. This class acts the same as a dkb.modal, this is important to consider if nesting them. Use it in combination with dkb.keybindings to easily define modals and bind keys to them.

This module returns a func used to instantiate modals. See usage in the function below.

See also:

Functions

dkb.filter (filter, init_function) Function returned by this module when imported.

Tables

dkb.filter Properties of this class instance

Methods

dkb.filter:bind (func, arg) Execute a function with bindings enabled.


Functions

Methods
dkb.filter (filter, init_function)
Function returned by this module when imported. Used to create Filter instances.

Parameters:

  • filter hs.window.filter Defines on which windows to act
  • init_function func[opt] The provied function will be executed on modal creation. Keybindings inside the function will map to the modal.

See also:

Usage:

    local Filter = require("dkb.filter") --> Import class
    local wf = require("hs.window.filter")
    loal keystroke = require("hs.eventtap.keyStroke")
    
    mod3 = keybindings:bindmod("⌃", keystroke)
    
    local test_modal = Filter(wf.new{'Floorp','Firefox'}, --> Filter by window title
       function(filter)
        -- Mappings will be active only when the windows described by the filter
        -- are focused.
        -- Send down/up arrow when pressing ctrl+j/k
        mod3("j", "", "down")
        mod3("k", "", "up")
    end)

Tables

dkb.filter
Properties of this class instance

Fields:

  • modal dkb.modal object that gets activated when the fiter conditions are met
  • w_filter hs.window.filter object provided on initialization

Methods

dkb.filter:bind (func, arg)
Execute a function with bindings enabled. This means that bindigns executed within the function will be bound to the filter.

Parameters:

  • func func ` Function to be executed.
  • arg Any extra argument will be passed to the provided function.
generated by LDoc 1.5.0 Last updated 2023-10-31 00:05:48