Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WezTerm support #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add WezTerm support #99

wants to merge 2 commits into from

Conversation

cpick
Copy link

@cpick cpick commented Sep 26, 2023

Depends on installing jq, activating WezTerm's shell integration (for the __wezterm_set_user_var() shell function), and placing following snippet in WezTerm's .wezterm.lua:

local wezterm = require 'wezterm'
local config = {}

wezterm.on('user-var-changed', function(window, pane, name, value)
  if name ~= "NOTIFICATION" then
    return
  end

  local notification = wezterm.json_parse(value)

  if notification.check_focus
    and window:is_focused()
    and window:active_pane():pane_id() == pane:pane_id()
  then
    return
  end

  if not notification.timeout_milliseconds then
    notification.timeout_milliseconds = nil
  end

  window:toast_notification(notification.title, notification.message,
    nil, notification.timeout_milliseconds)
end)

return config

Chris Pick added 2 commits September 26, 2023 11:19
Depends on installing [`jq`](https://github.com/jqlang/jq),
activating WezTerm's
[shell integration](https://wezfurlong.org/wezterm/shell-integration.html?h=integration#user-vars)
(for the `__wezterm_set_user_var()` shell function), and placing
following snippet in WezTerm's
[.wezterm.lua](https://wezfurlong.org/wezterm/config/files.html#quick-start):
```lua
local wezterm = require 'wezterm'
local config = {}

wezterm.on('user-var-changed', function(window, pane, name, value)
  if name ~= "NOTIFICATION" then
    return
  end

  local notification = wezterm.json_parse(value)

  if notification.check_focus
    and window:is_focused()
    and window:active_pane():pane_id() == pane:pane_id()
  then
    return
  end

  if not notification.timeout_milliseconds then
    notification.timeout_milliseconds = nil
  end

  window:toast_notification(notification.title, notification.message,
    nil, notification.timeout_milliseconds)
end)

return config
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant