Lubuntu 19.10和20.04:如何平铺窗口?lxqt-rc.xml文件中缺少窗口平铺部分。

Lubuntu 19.10和20.04(LTS)使用Openbox作为窗口管理器。

对于Lubuntu 18.04和19.04,允许用户编辑各种Openbox设置的文件lubuntu-rc.xmllxqt-rc.xml分别有一个名为“窗口平铺的快捷键”的部分,其中包含以下键盘快捷键:

  • HalfLeftScreen
  • HalfRightScreen
  • HalfUpperScreen以及
  • HalfLowerScreen

在Lubuntu 19.10和20.04(LTS)的~/.config/openbox/lxqt-rc.xml中缺少该部分。

我按照发布说明中的说明进行了删除

  • ~/.config/lxqt/globalkeyshortcuts.conf
  • ~/.config/lxqt/lxqt-runner.conf以及
  • ~/.config/openbox/lxqt-rc.xml

然后退出并重新登录。然而,lxqt-rc.xml仍然没有窗口平铺部分。

我了解到在LXQt中,Super键(也称为Meta键)与一些冲突有关。(所有的窗口平铺键盘快捷键最初都使用了Super键。)

Lubuntu 19.10和20.04的用户可以采取什么措施来恢复“窗口平铺”键盘快捷键呢?

4个回答

编辑日期20220907:从LXQt 0.17.0(2021年4月)开始,“为了窗口管理器的不可知性,移除了Openbox配置”,而~/.config/openbox/lxqt-rc.xml不再被识别,而~/.config/openbox/rc.xml则被识别。

编辑日期20200526:感谢this question,我意识到另一个解决方案是将显示/隐藏LXQt菜单的快捷键更改为Meta+Space之类的组合。换句话说,如果将Meta+Space设置为显示/隐藏LXQt菜单,则“纯粹”的Super可用于在~/.config/openbox/lxqt-rc.xml中使用。无需使用下面详细介绍的C+W组合。您的18.04 lubuntu-rc.xml现在可以在Lubuntu 20.04(和19.10)中使用。


这个答案适用于 Lubuntu 19.10 和 Lubuntu 20.04。
为了清晰起见,在 Lubuntu 会话中使用的文件应该是 `~/.config/openbox/lxqt-rc.xml`,而在纯 Openbox 会话中应该命名为 `~/.config/openbox/rc.xml`。
如何分割窗口?中,Lubuntu团队的一位成员建议在lxqt-rc.xml中包含一些代码来恢复窗口分割,并解决了我在问题中提到的冲突:

... 在19.04+版本中,您将遇到与lxqt-globalkeys使用该键打开菜单的冲突,因此要么禁用它,重新配置它,要么在这里使用其他按键。

请查看Lubuntu 20.04手册中的键盘快捷键部分,其中列出了默认键盘快捷键的列表,但也提到了以下内容:

全局键将优先于openbox绑定。如果一个键在全局键中使用,它将无法在Openbox键盘快捷键中工作。例如,如果W(indows)键在全局键中打开LXQT应用程序菜单(相当于Windows开始菜单),那么Openbox命令如窗口调整(W +箭头键)将无法正常工作。在使用和编辑键盘快捷键时,请记住这一点。


如果有人想要使用Lubuntu 19.04中使用的相同平铺快捷方式,这里提供了一种稍微修改过的形式。我已经包括了使用Control键与Super键以及相关箭头键,而不仅仅是Super键和相关箭头键。
以下列出的键盘快捷键的一个重要点是用户必须首先按住Ctrl键,然后按住Super键,然后按下相关的箭头键,然后释放所有的键。如果用户首先按下Super键,然后再按下Ctrl键,快捷键将无法工作。
    <!--
        Lubuntu specific.
        Keybindings for window tiling
    -->
    <!--
        # HalfLeftScreen
    -->
  <keybind key="C-W-Left">
    <action name="UnmaximizeFull"/>
    <action name="MoveResizeTo">
      <x>0</x>
      <y>0</y>
      <height>100%</height>
      <width>50%</width>
    </action>
  </keybind>
    <!--
        # HalfRightScreen
    -->
  <keybind key="C-W-Right">
    <action name="UnmaximizeFull"/>
    <action name="MoveResizeTo">
      <x>-0</x>
      <y>0</y>
      <height>100%</height>
      <width>50%</width>
    </action>
  </keybind>
    <!--
        # HalfUpperScreen
    -->
  <keybind key="C-W-Up">
    <action name="UnmaximizeFull"/>
    <action name="MoveResizeTo">
      <x>0</x>
      <y>0</y>
      <width>100%</width>
      <height>50%</height>
    </action>
  </keybind>
    <!--
        # HalfLowerScreen
    -->
  <keybind key="C-W-Down">
    <action name="UnmaximizeFull"/>
    <action name="MoveResizeTo">
      <x>0</x>
      <y>-0</y>
      <width>100%</width>
      <height>50%</height>
    </action>
  </keybind>

编辑完成后,打开终端并运行openbox --reconfigure以使按键绑定生效。或者,注销并重新登录。
我没有包括用于最大化或最小化窗口的键盘快捷键,因为这些操作和许多其他操作可以通过按下Alt+Spacebar来轻松访问。请注意,Openbox更喜欢使用iconify而不是minimize

DK Bose的回答很棒。
一般来说,只需要两个步骤:
1. 在全局操作管理器(GAM)中禁用“Super_L”。 2. 在Openbox的lxqt-rc.xml配置文件中添加条目。
禁用“Super_L”:
搜索“快捷键”。
找到“Super_L”条目并禁用它 enter image description here 配置Openbox键盘绑定:
Openbox文档中可以找到很好的键盘绑定条目,他们称之为“窗口对齐”。
<keybind key="W-Left">
    <action name="UnmaximizeFull"/>
    <action name="MaximizeVert"/>
    <action name="MoveResizeTo">
        <width>50%</width>
    </action>
    <action name="MoveToEdge"><direction>west</direction></action>
</keybind>
<keybind key="W-Right">
    <action name="UnmaximizeFull"/>
    <action name="MaximizeVert"/>
    <action name="MoveResizeTo">
        <width>50%</width>
    </action>
    <action name="MoveToEdge"><direction>east</direction></action>
</keybind>

然后通过运行openbox --reconfigure重新配置Openbox。

上面的解决方案不错。:-)
与此同时,我写了一个脚本来完成相同的任务。你可以将它挂钩到lxqt快捷键上 - meta+left等等。
#!/bin/bash 
# -x

offset_lubuntu_panel=50
width=$(wmctrl -d |head -n1 | cut -f5 -d' '|cut -dx -f1) # size of your monitor, say 1600x900
height=$(( $(wmctrl -d |head -n1 | cut -f5 -d' '|cut -dx -f2) - offset_lubuntu_panel))
width_half=$((width/2))
height_half=$((height/2))

case $1 in
    left)
        wmctrl -r :ACTIVE:  -b remove,maximized_vert,maximized_horz # un-maximizing an active window:
        sleep .1
        wmctrl -r :ACTIVE: -e 0,0,0,$width_half,$height # left half
        ;;
    right) 
        wmctrl -r :ACTIVE:  -b remove,maximized_vert,maximized_horz # un-maximizing an active window:
        sleep .1
        wmctrl -r :ACTIVE: -e 0,$width_half,0,$width_half,$height # right half
        ;;
    up)
        wmctrl -r :ACTIVE:  -b remove,maximized_vert,maximized_horz # un-maximizing an active window:
        sleep .1
        wmctrl -r :ACTIVE: -e 0,0,0,$width,$height_half # upper half
        ;;
    down)
        wmctrl -r :ACTIVE:  -b remove,maximized_vert,maximized_horz # un-maximizing an active window:
        sleep .1
        wmctrl -r :ACTIVE: -e 0,0,$height_half,$width,$height_half # lower half
        ;;
    max)
        wmctrl -r :ACTIVE:  -b add,maximized_vert,maximized_horz # maximizing the current  window
        ;;
    *)
        echo -e "\t$(basename $0) [left|right|up|down|max]"
            echo -e "\t\twmctrl -r :ACTIVE: -e 0,0,0,$width,$heightpulka  # gravity,x,y,w,h"
            echo -e "\tRun: lxqt-config-globalkeyshortcuts to add shortcuts to your system"
            echo -e "\tor edit manually this file: ~/.config/lxqt/globalkeyshortcuts.conf"
        echo
        ;;
esac

1谢谢,这可能是迄今为止最便携的实现!我已将其添加到我用于初始化新机器的代码库中 :) - RafDouglas C. Tommasi
1哦,天啊。对于我这个谦逊的业余爱好者来说,这真是一份巨大的荣誉。:-) 谢谢你! - xerostomus

你的回答帮助我能够在Lubuntu 22.04和LXQt 0.17.0中使用窗口平铺。我还在DK Bose的代码中添加了四个角落的屏幕、一个最大化屏幕和一个中间屏幕。
<!--
    Lubuntu specific.
    Keybindings for window tiling
-->
<!--
    # HalfLeftScreen
-->
<keybind key="C-W-Left">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>0</x>
    <y>0</y>
    <height>100%</height>
    <width>50%</width>
  </action>
</keybind>
<!--
    # HalfRightScreen
-->
<keybind key="C-W-Right">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>-0</x>
    <y>0</y>
    <height>100%</height>
    <width>50%</width>
  </action>
</keybind>
<!--
    # HalfUpperScreen
-->
<keybind key="C-W-Up">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>0</x>
    <y>0</y>
    <width>100%</width>
    <height>50%</height>
  </action>
</keybind>
<!--
    # HalfLowerScreen
-->
<keybind key="C-W-Down">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>0</x>
    <y>-0</y>
    <width>100%</width>
    <height>50%</height>
  </action>
</keybind>
<!--
    # UpperLeftScreen
-->
<keybind key="C-W-A-Prior">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>0</x>
    <y>0</y>
    <height>50%</height>
    <width>50%</width>
  </action>
</keybind>
<!--
    # UpperRightScreen
-->
<keybind key="C-W-A-Next">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>-0</x>
    <y>0</y>
    <height>50%</height>
    <width>50%</width>
  </action>
</keybind>
<!--
    # LowerLeftScreen
-->
<keybind key="C-W-A-Left">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>0</x>
    <y>-0</y>
    <width>50%</width>
    <height>50%</height>
  </action>
</keybind>
<!--
    # LowerRightScreen
-->
<keybind key="C-W-A-Right">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>-0</x>
    <y>-0</y>
    <width>50%</width>
    <height>50%</height>
  </action>
</keybind>
<!--
    # MaxScreen
-->
<keybind key="C-W-A-Up">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>0</x>
    <y>0</y>
    <width>100%</width>
    <height>100%</height>
  </action>
</keybind>
<!--
    # MidScreen
-->
<keybind key="C-W-A-Down">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <x>25%</x>
    <y>25%</y>
    <width>50%</width>
    <height>50%</height>
  </action>
</keybind>

这不是一个回答,而是一个感谢评论。 - David
请不要将“谢谢”作为答案。一旦您拥有足够的声望,您将能够投票支持有帮助的问题和答案。- 来自审核 - David
好的,谢谢你,对不起。我是新来的,我试着将它作为评论移到DK Bose的代码中。 - BenJaMin
哦,我的评论声望太低了。我应该删除整个回答吗?对我来说,这些角落的屏幕很有帮助,但我不知道是否太简单可以发表。 - BenJaMin