gpt4 book ai didi

linux - 如何使用 xdg-open 将应用程序置于最前面

转载 作者:太空宇宙 更新时间:2023-11-04 12:05:54 26 4
gpt4 key购买 nike

在 Linux 上,xdg-open 可以启动一个应用程序,但在大多数情况下,所需的行为是仅在应用程序尚未运行时启动它,如果它已经在运行则将其置于最前面。

xdg-open 可以做到这一点吗?是否有其他一些标准方法来提供此功能?

最佳答案

如您所见,xdg-open 只不过是处理文件类型并在首选应用程序中打开它的包装器。是否支持"bring to front" 选项取决于应用程序。

$ file /usr/bin/xdg-open
/usr/bin/xdg-open: POSIX shell script, ASCII text executable

为了将应用程序窗口置于最前面,您可以使用其他工具,如 wmctrlxdotoolqdbus

详细信息:

NAME
wmctrl - interact with a EWMH/NetWM compatible X Window Manager.

SYNOPSIS
wmctrl [ options | actions ]...

DESCRIPTION
wmctrl is a command that can be used to interact with an X Window man‐
ager that is compatible with the EWMH/NetWM specification. wmctrl can
query the window manager for information, and it can request that cer‐
tain window management actions be taken.
[...]
-a <WIN>
Switch to the desktop containing the window <WIN>, raise the
window, and give it focus.



NAME
xdotool - command-line X11 automation tool

SYNOPSIS
xdotool cmd args...

Notation: Some documentation uses [window] to denote an optional window
argument. This case means that the argument, if not present, will
default to "%1". See "WINDOW STACK" for what "%1" means.

DESCRIPTION
xdotool lets you programatically (or manually) simulate keyboard input
and mouse activity, move and resize windows, etc. It does this using
X11's XTEST extension and other Xlib functions.

There is some support for Extended Window Manager Hints (aka EWMH or
NetWM). See the "EXTENDED WINDOW MANAGER HINTS" section for more
information.

关于linux - 如何使用 xdg-open 将应用程序置于最前面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50753118/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com