Comments (3)
You cannot intercept signals sent to other processes. What is your
actual use case.
from kitty.
I am doing this to build a tui which helps manages session and easily configure the terminal:
i would like to build a script which saves the session data for a particular kitty terminal instance. we have inbuilt commands like kitty @ ls which help us do this. i built a python kitten script which looks something like this:
from typing import List
import json
import os
from kitty.boss import Boss
def main(args: List[str]) -> str:
pass
from kittens.tui.handler import result_handler
@result_handler(no_ui=True)
def handle_result(args: List[str], answer: str, target_window_id: int, boss: Boss) -> None:
w = boss.window_id_map.get(target_window_id)
if w is not None:
json_data_str = boss.call_remote_control(w, ('ls', f'--match=id:{w.id}'))
json_data = json.loads(json_data_str)
# Define the file path
home_dir = os.path.expanduser("~")
# Define the file path with the correct username
file_path = os.path.join(home_dir, '.config','kitty', 'lastsession.kitty')
# Check if the file exists
if not os.path.exists(file_path):
# If the file doesn't exist, create a new one
with open(file_path, 'w') as f:
json.dump({}, f) # Write an empty JSON object
# Write JSON data to the file
with open(file_path, 'w') as f:
json.dump(json_data, f)
boss.close_tab()
this is the simplified version but i have more ifs and else which check for different arguments incoming. i have also mapped some shortcuts in my kitty config file as follows:
map ctrl+shift+q kitten autosave.py close_tab
map ctrl+shift+w kitten autosave.py close_window
i tried the same for alt+f4 which is a common way of closing the terminal, but no dice. Then as i researched more i found that if i am 'trapping' the SIGTERM signal for the kitty instance it would cover the whole "accidentally closing terminal edge case" instead of me handling each individual closing separately.
Any help would be useful.
from kitty.
If you want to perform special actions on window close events, you use
the watcher infrastructure in kitty
https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.watcher
You absolutely cannot handle signals in your code. signals are an
asynchronous, global mechanism.
from kitty.
Related Issues (20)
- I seem to be missing a lot of symbols HOT 5
- Aspect ratio not computed when giving only one of `r` or `c` to display image
- When moving mouse over inactive Kitty windows, text is selected as if the mouse button is pressed HOT 15
- kitty: incorrectly acts like mouse button is pressed HOT 1
- Prompt not visible after resetting the terminal HOT 1
- cursor not hiding in Wayland session HOT 2
- Open new tab next to current instead of at the end of the list of open tabs. HOT 1
- focus_visible_window breaks if interrupted by mouse click
- KITTY_DATA_START dump after second ssh onto server HOT 4
- per window background color HOT 2
- kitty randomly hangs after recent system updating HOT 3
- on_focus_change erroneously invoked on every loop with sway+fcitx5 HOT 7
- "map <shoutcut> clear_terminal to_cursor active" doesn't seem to be working properly. HOT 1
- Option for alternate rendering of shade characters HOT 4
- Enter key outputs ^M instead of executing command during apt upgrade prompt HOT 1
- Kitten not matching on tab titles with spaces? HOT 1
- Clarification difference between `show_key` and `show-key` HOT 2
- Feature Request: Foreground opacity HOT 1
- panic in `kitten diff` when running under shpool and scrolling with mouse wheel HOT 5
- test_ssh_copy failure on riscv64 and ppc64el HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kitty.