iberianpig / fusuma-plugin-appmatcher

Fusuma plugin configure app-specific gestures
MIT License
8 stars 2 forks source link

Support in-terminal application detection #12

Open TroyMitchell911 opened 1 day ago

TroyMitchell911 commented 1 day ago

Hi. Can you add detection of foreground applications in the terminal? When I use this tool, I can only detect Gnome-shell. I think it should also list the foreground applications in the shell, which is a reasonable feature. It can get rid of long shortcut keys in vim and more app.

If I knew ruby, I would definitely submit a PR...

iberianpig commented 6 hours ago

It seems difficult because it is necessary to handle the execution of Shell commands.

Please reconsider the necessity of this feature; clarifying the specific use case might make its value clearer.

TroyMitchell911 commented 6 hours ago

In vim or tmux, we can use the touchpad to switch windows

TroyMitchell911 commented 6 hours ago

Sorry, Idk if it's diffcult. but how fg works? I think it's similar to the principle of fg.

iberianpig commented 4 hours ago

I don't know. However the behavior of fg and bg is dependent on the shell implementation.

Would it be possible to create a script that retrieves the foreground process using any commands?

TroyMitchell911 commented 4 hours ago

I don't know. However the behavior of fg and bg is dependent on the shell implementation.

Would it be possible to create a script that retrieves the foreground process using any commands?

of course. I run a vim in a zsh terminal. it's search child process here:

❯ ps --ppid 76432
    PID TTY          TIME CMD
 184521 pts/0    00:00:01 vim

and it's search a vim process and it's parent process:

#!/bin/sh

VIM_PID=$(pgrep vim)

# parent pid
PPID=$(ps -o ppid= -p $VIM_PID)

ps -p $VIM_PID
ps -p $PPID
TroyMitchell911 commented 4 hours ago

If you can get what application is selected, I think you can get it's pid?(sorry I don't know ruby so I didn't check source code)

TroyMitchell911 commented 4 hours ago

You can through system call to get these information. e.g. procfs getppid sysctl