gvim pid在$!与wmctrl列表不同 [英] gvim pid in $! different to wmctrl list

查看:93
本文介绍了gvim pid在$!与wmctrl列表不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启动多个gvim窗口的脚本。我想以某种方式定位它们。 wmctrl 可以做到这一点,但是由于存在多个实例,因此窗口名称不明确。我认为:使用pids。

I have a script which launches multiple gvim windows. I want to position them in a certain way. wmctrl can do this, but because there are multiple instances, the window names are ambiguous. I figure: use pids.

gvim /tmp/xxx &

X=$!

wmctrl -lp | grep $X
echo $X
wmctrl -lp | grep GVIM
echo sleeping
sleep 3
wmctrl -lp | grep GVIM

输出为:

5211
sleeping
0x03400062  0 5218   localhost xxx (/tmp) - GVIM

似乎gvim以pid 5211开始,但为实际窗口启动了一个新进程。此外,该过程还不存在。

It seems gvim starts out with pid 5211 but launches a new process for the actual window. Also, that process doesn't exist yet.

如何明确获取刚启动的gvim实例的wmctrl窗口句柄?还是应该使用其他东西?

How can I unambiguously get the wmctrl window handle of the gvim instance I just started? Or should I use something else?

-echo-wid 选项看起来不错,但我使用的是KDE。

The --echo-wid option looks nice but I am using KDE.

推荐答案

我只是遇到了相同的问题,并通过运行来解决了该问题

I just ran into the same problem, and solved it by running

gvim -f &
pid=$!

n.m。

gvim的手册页:


-f          Foreground.   For  the  GUI  version, Vim will not fork and detach from the
            shell it was started in.  On the Amiga, Vim is not restarted to open a  new
            window.   This option should be used when Vim is executed by a program that
            will wait for the edit session to finish (e.g. mail).   On  the  Amiga  the
            ":sh" and ":!" commands will not work.


这说明了它为什么起作用。

which explains why it works.

我不知道您是否尝试过此方法,或者答案是否更重要,但我不愿回答一个好问题:)

I don't know if you tried this, or if the answer even matters anymore, but I hate leaving a good question unanswered :)

贷记至nm指出 -f 开关

这篇关于gvim pid在$!与wmctrl列表不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆