如何使用xdg-open将应用程序带到前面

时间:2018-06-08 03:54:05

标签: linux ubuntu

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

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

1 个答案:

答案 0 :(得分:0)

正如您所看到的,xdg-open只不过是处理文件类型并在首选应用程序中打开它的包装器。如果它支持“带到前面”选项,则取决于应用程序。

$ 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.