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

How to implement a hotkey to toggle background opacity #6691

Closed
ackerr opened this issue Oct 9, 2023 · 1 comment
Closed

How to implement a hotkey to toggle background opacity #6691

ackerr opened this issue Oct 9, 2023 · 1 comment

Comments

@ackerr
Copy link

ackerr commented Oct 9, 2023

I find some options to change background opacity, but it need two different hotkey to implement toggle

map super+u           set_background_opacity 1
map super+shift+u set_background_opacity default

In wezterm, i can write a lua function implement it

wezterm.on("toggle-opacity", function(window, _)
  local overrides = window:get_config_overrides() or {}
  if not overrides.window_background_opacity then
    overrides.window_background_opacity = 0.8
    overrides.text_background_opacity = 0.8
  else
    overrides.window_background_opacity = nil
    overrides.text_background_opacity = nil
  end
  window:set_config_overrides(overrides)
end)

Although I have found a way to implement custom scripts with kitten, but I am not familiar with the APIs inside and don't know where to start.

Can you give some hints?

@kovidgoyal
Copy link
Owner

Write a kitten

https://sw.kovidgoyal.net/kitty/kittens/custom/#using-kittens-to-script-kitty-without-any-terminal-ui

something like

def handle_result(args, answer, target_window_id, boss): 
    import kitty.fast_data_types as f
    os_window_id = f.current_focused_os_window_id()
    current_opacity = f.background_opacity_of(os_window_id)
    boss.set_background_opacity("default" if current_opacity == whatever else whatever)

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

No branches or pull requests

2 participants