Skip to content

A fork of the tab interface for application supporting Xembed

License

Notifications You must be signed in to change notification settings

SCOTT-HAMILTON/tabbed

Repository files navigation

Tabbed Logo

MIT License Build Status Code Quality Code Quality

Fork of Tabbed - The tab interface for application supporting Xembed

Checkout the original project tabbed and the alacritty fork needed to make this work alacritty

Tabbed-Alacritty - Demo of directory following

About

This project is a fork of tabbed. (A name needs to be found tho). It enables terminal emulators like alacritty to follow the previous working directory when opening a new tab. For now, the only patched terminal to support this protocol is alacritty, see my fork : https://github.com/SCOTT-HAMILTON/alacritty

How to test it right now

A nix shell is configured so that you can get this setup running in a few commands. This shell builds the tabbed fork and this alacritty fork.

  1. First install nix see https://nixos.org/guides/install-nix.html I higly recommand you to check out the above link but normally this command should be enough :
 $ sh <(curl -L https://nixos.org/nix/install) --daemon
  1. Navigate to this repo
 $ cd ~/path/to/where/you/cloned/my/tabbed/fork
  1. enter the nix shell :
 $ nix-shell
  1. (in the nix shell) build the alacritty fork :
 $ cargo build
  1. (still in the nix shell) run the tabbed alacritty :
 $ tabbed -cr 2 -w "--xembed-tcp-port" ./target/debug/alacritty --embed ""

Bonus for hackers
6. (still in the nix shell) run the tabbed alacritty and put debug logs in a separate file :

 $ tabbed -cr 2 -w "--xembed-tcp-port" ./target/debug/alacritty --embed "" 2>&1 | ./filter_output.pl 'debug-' debug_logs /dev/stdout 2>&1

How does it work

Flowchart Diagram

When spawning a new alacritty window, tabbed also forks a child process that will communicate with this alacritty window through ZeroMQ Rep/Req sockets (Req->tabbed, Rep->the client, cf 0MQ API). A child is referred to as a client in tabbed

Each tabbed client is identified by an XID, which is the X11 Identifier of the alacritty window it's responsible of, (cf https://metacpan.org/pod/X11::Xlib#DESCRIPTION)

Authentification Step

The tabbed client doesn't know its window's XID when spawned, it needs to ask for it. Tabbed client asking XID from alacritty window

The messages involved are : XID? and XID:138412034

Loop

Now that the client is authentified, in other words, now that it knows its associated window's XID, it can enter the following two state loops :

The communication loop

The PWD is the shell's working directory of the current focused window. It changes each time the user executes a cd /somewhere/ command.
The message involved is : PWD:/home/user

The logic loop

When entering sleep mode, the tabbed client also sends a message informing the window that it should also enter the sleep mode, same goes to the turbo mode. These modes are critical for limiting CPU usage.

Since the user can change the working directory at anytime, the client has to ask for it constantly. And so it needs to transmit the flow of answers to the tabbed parent process. This is the key system that allows it to follow the working directories. Because the tabbed parent process always knows the PWD of the currently focused window's shell, it can spawn a new one at the good location.

The messages involved are : sleep, turbo and PWD?

License

Tabbed is released under the MIT/X Consortium License This few patches are released under the MIT License

References that helped

(These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)

About

A fork of the tab interface for application supporting Xembed

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published