快捷键方法:在 Linux 中保持窗口始终位于最前面 / Always on top : wmctrl (***)

命令实现方式:

sudo apt install devilspie

sudo apt install wmctrl

如何在 Linux 中保持窗口始终位于最前面  https://cn.linux-console.net/?p=13287

要创建自定义快捷方式,您首先需要在系统上安装wmctrl。 Wmctrl 是一个 Unix/Linux 程序,可让您与 X Window 管理器交互,并允许您管理系统的窗口和用户输入。

在Linux如何使用堪比macos的窗口毛玻璃效果? https://zhuanlan.zhihu.com/p/150907578

devilspie,这是一个不提供GUI的小工具,这个工具可以在窗口创建时检测并匹配出符合规则的窗口,并执行针对该窗口的一系列动作。(具体请看官方文档

 要点:

1. 只要目标窗口处于激活状态,使用 wmctrl -b toggle,shaded -r :ACTIVE: 的快捷键,就可以将当前激活窗口,设置为 Always on top 标记。

2. 区别:

2.1. 通过鼠标方式,只能在窗口标题栏的空白处,点击“右键”,以便调出 “Always on top”菜单。

好处:

显示的效果,立即生效。

2.2. 使用

wmctrl -b toggle,shaded -r :ACTIVE: 

快捷键方式:即使快捷键已经有效了,但显示的效果,未必立即生效。(应该还需要执行窗口的刷新操作 ?)

  • 当 目标窗口在桌面上是第一个有效窗口时,立即有效。否则,未必。
  • 当目标窗口已经有效时,在它后面打开的窗口,立即生效。
  • 在目标窗口有效时,在它之前打开的窗口,无效。估计:其他窗口已经占用了 top 层,因此,需要一个窗口刷新的操作?
好处:
  • 当目标窗口没有标题菜单时,只要激活目标窗口,该快捷键的操作,就会有效。但显示效果却不能立即生效,可能需要一个刷新的操作吧?
  • 而鼠标操作,必须要求窗口要有标题栏的空白处。

区别

  • 鼠标执行 Always on top 操作,优点:显示效果立即生效。缺点:需要窗口标题栏的空白位置。
  • 使用 wmctrl 快捷键方式执行 Always on top 操作,缺点:显示效果未必立即生效。优点:不需要窗口标题栏的空白位置;只要激活目标就可以了。

=====================================

wmctrl

  https://www.freedesktop.org/wiki/Software/wmctrl/

wmctrl -r :ACTIVE: -b toggle,above

例子 1: * wmctrl -r "xine" -b toggle,fullscreen

例子 2:

Use the currently active window for the action.

     * wmctrl -b toggle,shaded -r :ACTIVE:

real-world examples

force window dimensions when launching an app

-r

wmctrl -r is used to specify the window name (long title) to act on. It is used for a number of features:

  • Move the window to the specified desktop. * Resize and move the window around the desktop. * Change the state of the window. * Set the long title of the window. * Set the short title of the window. * Set both the long and short title of the window.

~$ wmctrl --help
wmctrl 1.07
Usage: wmctrl [OPTION]...
Actions:
  -m                   Show information about the window manager and
                       about the environment.
  -l                   List windows managed by the window manager.
  -d                   List desktops. The current desktop is marked
                       with an asterisk.
  -s <DESK>            Switch to the specified desktop.
  -a <WIN>             Activate the window by switching to its desktop and
                       raising it.
  -c <WIN>             Close the window gracefully.
  -R <WIN>             Move the window to the current desktop and
                       activate it.
  -r <WIN> -t <DESK>   Move the window to the specified desktop.
  -r <WIN> -e <MVARG>  Resize and move the window around the desktop.
                       The format of the <MVARG> argument is described below.
  -r <WIN> -b <STARG>  Change the state of the window. Using this option it's
                       possible for example to make the window maximized,
                       minimized or fullscreen. The format of the <STARG>
                       argument and list of possible states is given below.
  -r <WIN> -N <STR>    Set the name (long title) of the window.
  -r <WIN> -I <STR>    Set the icon name (short title) of the window.
  -r <WIN> -T <STR>    Set both the name and the icon name of the window.
  -k (on|off)          Activate or deactivate window manager's
                       "showing the desktop" mode. Many window managers
                       do not implement this mode.
  -o <X>,<Y>           Change the viewport for the current desktop.
                       The X and Y values are separated with a comma.
                       They define the top left corner of the viewport.
                       The window manager may ignore the request.
  -n <NUM>             Change number of desktops.
                       The window manager may ignore the request.
  -g <W>,<H>           Change geometry (common size) of all desktops.
                       The window manager may ignore the request.
  -h                   Print help.

Options:
  -i                   Interpret <WIN> as a numerical window ID.
  -p                   Include PIDs in the window list. Very few
                       X applications support this feature.
  -G                   Include geometry in the window list.
  -x                   Include WM_CLASS in the window list or
                       interpret <WIN> as the WM_CLASS name.
  -u                   Override auto-detection and force UTF-8 mode.
  -F                   Modifies the behavior of the window title matching
                       algorithm. It will match only the full window title
                       instead of a substring, when this option is used.
                       Furthermore it makes the matching case sensitive.
  -v                   Be verbose. Useful for debugging.
  -w <WA>              Use a workaround. The option may appear multiple
                       times. List of available workarounds is given below.

Arguments:
  <WIN>                This argument specifies the window. By default it's
                       interpreted as a string. The string is matched
                       against the window titles and the first matching
                       window is used. The matching isn't case sensitive
                       and the string may appear in any position
                       of the title.

                       The -i option may be used to interpret the argument
                       as a numerical window ID represented as a decimal
                       number. If it starts with "0x", then
                       it will be interpreted as a hexadecimal number.

                       The -x option may be used to interpret the argument
                       as a string, which is matched against the window's
                       class name (WM_CLASS property). Th first matching
                       window is used. The matching isn't case sensitive
                       and the string may appear in any position
                       of the class name. So it's recommended to  always use
                       the -F option in conjunction with the -x option.

                       The special string ":SELECT:" (without the quotes)
                       may be used to instruct wmctrl to let you select the
                       window by clicking on it.

                       The special string ":ACTIVE:" (without the quotes)
                       may be used to instruct wmctrl to use the currently
                       active window for the action.

  <DESK>               A desktop number. Desktops are counted from zero.

  <MVARG>              Specifies a change to the position and size
                       of the window. The format of the argument is:

                       <G>,<X>,<Y>,<W>,<H>

                       <G>: Gravity specified as a number. The numbers are
                          defined in the EWMH specification. The value of
                          zero is particularly useful, it means "use the
                          default gravity of the window".
                       <X>,<Y>: Coordinates of new position of the window.
                       <W>,<H>: New width and height of the window.

                       The value of -1 may appear in place of
                       any of the <X>, <Y>, <W> and <H> properties
                       to left the property unchanged.

  <STARG>              Specifies a change to the state of the window
                       by the means of _NET_WM_STATE request.
                       This option allows two properties to be changed
                       simultaneously, specifically to allow both
                       horizontal and vertical maximization to be
                       altered together.

                       The format of the argument is:

                       (remove|add|toggle),<PROP1>[,<PROP2>]

                       The EWMH specification defines the
                       following properties:

                           modal, sticky, maximized_vert, maximized_horz,
                           shaded, skip_taskbar, skip_pager, hidden,
                           fullscreen, above, below

Workarounds:

  DESKTOP_TITLES_INVALID_UTF8      Print non-ASCII desktop titles correctly
                                   when using Window Maker.

The format of the window list:

  <window ID> <desktop ID> <client machine> <window title>

The format of the desktop list:

  <desktop ID> [-*] <geometry> <viewport> <workarea> <title>


Author, current maintainer: Tomas Styblo <tripie@cpan.org>
Released under the GNU General Public License.
Copyright (C) 2003

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值