Eugeny / tabby

A terminal for a more modern age
https://tabby.sh
MIT License
59.7k stars 3.4k forks source link

Allow program to run after specific amount of idle time #5482

Open OlaoluwaM opened 2 years ago

OlaoluwaM commented 2 years ago

Is your feature request related to a problem? Please describe. No, my feature request is not related to any problems

Describe the solution you'd like A setting that allows for the configuration of what command to run after a specific amount of idle time (the amount of time where the terminal has not been in use) has passed. Alongside an option for setting the command to be run, like cmatrix or any cool/useful effects

Describe alternatives you've considered Using a terminal multiplexer like tmux

Additional context To be frank, I am not even sure if this is a good idea since tabby is already a bit memory-intensive ๐Ÿ˜…

OlaoluwaM commented 2 years ago

With a bit of guidance, I can work on this!!

Eugeny commented 2 years ago

Sure, you're looking for the getting started guide: https://github.com/Eugeny/tabby/blob/master/HACKING.md - and then to watch for newly added tabs and listen for their activity event

GitHub
tabby/HACKING.md at master ยท Eugeny/tabby
A terminal for a more modern age. Contribute to Eugeny/tabby development by creating an account on GitHub.
OlaoluwaM commented 2 years ago

image I am getting this issue when I try to build. Also, is it fine to use npm for this project?

OlaoluwaM commented 2 years ago

I run Linux btw, Fedora 35

Eugeny commented 2 years ago

Have you run yarn first? No, it's not fine to use npm here because specific dependencies are pinned in yarn.lock.

OlaoluwaM commented 2 years ago

Still getting the same error. I ran yarn this time

OlaoluwaM commented 2 years ago

I see in the HACKING.md there are some packages to be installed for the Debian and Ubuntu distributions. Is this the case for other Linux distros like Fedora?

OlaoluwaM commented 2 years ago

I keep getting errors when building and running tabby locally on Fedora 35. Am I missing something?

Eugeny commented 2 years ago

Does app/node_modules/rxjs exist? Yes, for Fedora, you need to install the corresponding Fedora packages, but that's not related to your current error.

OlaoluwaM commented 2 years ago

Yes!

OlaoluwaM commented 2 years ago

Oh, it worked. I didn't know we had to run yarn in both the root and app folder

OlaoluwaM commented 2 years ago

This what I got when invoking yarn start image

Eugeny commented 2 years ago

Sorry! I've just found and fixed an error in install-deps.js that prevented it from running automatically. Now you just need to run node ./scripts/build-native.js to build the native modules.

OlaoluwaM commented 2 years ago

No worries!

OlaoluwaM commented 2 years ago

Now I am getting this when I run yarn in the root directory, but the command still completes successfully image

OlaoluwaM commented 2 years ago

This is what I get when I try to run ./scripts/build-native.js image

OlaoluwaM commented 2 years ago

Lastly, plugins must be in angular correct?

Eugeny commented 2 years ago

You need to install the normal C++ toolchain (probably https://developer.fedoraproject.org/tech/languages/c/cpp_installation.html)

Plugins must be Angular modules, yes.

C++ โ€” Fedora Developer Portal
Fedora Developer Portal provides information for developers running Fedora on their workstation or virtual machines.
OlaoluwaM commented 2 years ago

This happens when I run yarn in the app dir image

OlaoluwaM commented 2 years ago

And now I get this when I run ./scripts/build-native.js image image

Eugeny commented 2 years ago

Have you installed libfontconfig-dev? It's one of the requirements listed in https://github.com/Eugeny/tabby/blob/master/HACKING.md

GitHub
tabby/HACKING.md at master ยท Eugeny/tabby
A terminal for a more modern age. Contribute to Eugeny/tabby development by creating an account on GitHub.
OlaoluwaM commented 2 years ago

It's not in the fedora repository image

Eugeny commented 2 years ago

It is, and if it weren't, that doesn't mean you can just skip it: https://fedora.pkgs.org/35/fedora-x86_64/fontconfig-devel-2.13.94-3.fc35.x86_64.rpm.html

OlaoluwaM commented 2 years ago

Shoot, my bad seems like lib is a prefix for debian based distros, thanks for letting me know

OlaoluwaM commented 2 years ago

Couldn't find the following

OlaoluwaM commented 2 years ago

I checked both the https://fedora.pkgs.org/35 link and using the dnf search command. I still get this when I run ./scripts/build-native.js image

OlaoluwaM commented 2 years ago

Am I missing something?

Eugeny commented 2 years ago

No, these aren't errors. If you're getting exitcode 0 at the end, you're good to go

OlaoluwaM commented 2 years ago

Hmm, so I got it working, but I don't seem to have tabby as a command

OlaoluwaM commented 2 years ago

image

Eugeny commented 2 years ago

tabby as a command is only available if you install it from the official .deb or .rpm - otherwise you must use the full path to the binary

Just a hint - if you're writing a plugin, you don't need the whole Tabby source tree - just install the binary release, clone the demo plugin and you're good to go.

OlaoluwaM commented 2 years ago

I did install it using the .rpm on the release page

Eugeny commented 2 years ago

True! Looks like it's missing - I'll look into it. You can use the full path(/opt/Tabby/tabby instead)

OlaoluwaM commented 2 years ago

Also, running yarn in the plugin template directory errors out with a status code of 1, because of node-sass This is part of the output. It's long. Is there a specific node version to use? image

OlaoluwaM commented 2 years ago

I found the issue. the node-sass version in the tabby-clippy repo is compatible with only node v15. https://www.npmjs.com/package/node-sass

npm
node-sass
Wrapper around libsass
OlaoluwaM commented 2 years ago

Can I update the deps of the tabby-clippy plugin to the latest?

OlaoluwaM commented 2 years ago

How do you use the AppService. Sorry, I am new to angular (a react dev)

image

Eugeny commented 2 years ago

You just add them as constructor parameters: https://angular.io/guide/architecture-services#dependency-injection-di

Angular
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
OlaoluwaM commented 2 years ago

Thank you! So I got it working to the point where we are able to log out to the console when the active tab changes. However, I am a bit stuck. What I am trying to implement is the ability for a command to be run after a tab has been idle (no command is running on the foreground) for a specific amount of time, with said time being a user-specified input. Currently, there doesn't seem to be a way to get the amount of time that has passed while the tab has been idle, but there is a way to get the current process (assuming it only returns what's running on the foreground and not the background)

OlaoluwaM commented 2 years ago

It requires a bit of polymorphism, but I am not familiar with how angular handles that or how to approach it in this plugin. Nevertheless, my thought for an implementation is to have an interval for the user-specified duration. Once the interval ends, check if the currently active tab is still idle (no foreground processes). If it is, clean up the interval and invoke whatever command the user-specified. When the tab is no longer idle, stop the command and revert things back to normal. If a user switches tabs for some reason, the plugin could either keep the command running on the previously active tab, or stop it in the previous tab and restart the idle-checking process on the new active tab. I think the latter may be better for resource utilization

Eugeny commented 2 years ago

Just use the activity$ event and a bit of RxJS:

tab.activity$.pipe(
    filter(x => x),
    debounceTime(10000)
).subscribe(() => console.log('no activity for 10s'))
OlaoluwaM commented 2 years ago
tab.activity$.pipe(
  filter(x => x),
  debounceTime(10000)
).subscribe(() => console.log('no activity for 10s'))

Or I could do this... ๐Ÿ˜…

OlaoluwaM commented 2 years ago

Just use the activity$ event and a bit of RxJS:

tab.activity$.pipe(
  filter(x => x),
  debounceTime(10000)
).subscribe(() => console.log('no activity for 10s'))

So I tried this but it doesn't work when there is a process running on the terminal like termdown. Meaning, even if termdown is running, after 10s "no activity for 10s" is logged :/

Eugeny commented 2 years ago

Well, yes, activity$ refers to output being printed. You could check tab.getCurrentProcess() whether there's still a process running.

OlaoluwaM commented 2 years ago

Hmm, looks like getCurrentProcess() keeps returning null. I checked the source and it looks like I will need to override it. How can I do that? Do I make the exported class in index.ts a child of the BaseTabComponent class? Or create a separate child class for that?

Eugeny commented 2 years ago

That's weird, does the current process show up in the tab context menu? (it also uses getCurrentProcess()). Also make sure you're actually checking for the current process when clicking the tab and not then attaching to the tab.

lppsuixn commented 1 year ago

@OlaoluwaM hi,how is it going? I need that! thx