跳转至内容

cwm

来自 ArchWiki

cwm 是一个 X11 窗口管理器,其核心理念是尽可能减少干扰,以便用户高效工作。它最初衍生自 evilwm,但其代码库随后经过了重新编写。

cwm 作为 OpenBSD 基础系统的一部分进行开发。同时也提供了一个可在 Linux 上运行的“可移植”版本。

安装

安装 cwmAUR 软件包。

配置

cwm 通过编辑 ~/.cwmrc 来进行配置。系统没有默认的 cwmrc 文件;所有默认设置(包括快捷键)都在 conf.c 中定义。cwm(1) 列出了默认快捷键;cwmrc(5) 列出了所有配置指令。

不过,您可以使用 unbind-key allunbind-mouse all 来移除所有默认快捷键。

窗口组

cwm 缺乏传统的“工作区”;相反,您可以将窗口分配到一个 组 (group)。这是一种更灵活的方法,因为两个或多个组可以同时显示,这与许多平铺窗口管理器的工作区功能类似或完全相同。

例如,您可以将聊天/IRC 应用程序放入第 4 组,然后指定一个按键来切换该组的可见性 (bind-key <k> group-toggle 4),从而在显示其他窗口/组的 同时 显示该组。

您也可以使用 bind-key <k> group-only <n> 显示该组的窗口,并隐藏其他所有内容。

新窗口的默认设置是不将其放入任何组,这意味着它们将始终显示(许多窗口管理器称之为“粘滞/sticky”窗口)。但是,通过使用 sticky yes 启用“粘滞组模式”,窗口默认将被分配到当前选中的组。您还可以使用 autogroup 目录来自动对窗口进行分组。

移动窗口

cwm 没有将窗口移动到预定义位置的操作;但您可以使用 xdotool 来实现;将此 cwm-w-mv 脚本放入您的 PATH

#!/bin/sh
# Move a window to the side of a screen.

case "$1" in
	"left") xdotool getactivewindow windowmove 0 y ;;
	"top")  xdotool getactivewindow windowmove x 0 ;;

	"right")
		screen_width=$(xwininfo -root | grep Width | cut -d: -f2 | tr -d ' ')
		win_width=$(xdotool getactivewindow  getwindowgeometry --shell | grep WIDTH | cut -d= -f2)
		xdotool getactivewindow windowmove $(( $screen_width - $win_width )) y
		;;
	"bottom")
		screen_height=$(xwininfo -root | grep Height | cut -d: -f2 | tr -d ' ')
		win_height=$(xdotool getactivewindow  getwindowgeometry --shell | grep HEIGHT | cut -d= -f2)
		xdotool getactivewindow windowmove x $(( $screen_height - $win_height ))
		;;
	*)
		echo "Unsupported: \"$1\""
		exit 1
esac

然后在 cwm 中使用类似以下内容进行绑定

bind-key 4-h      cwm-w-mv left   # Move window to side of the screen.
bind-key 4-j      cwm-w-mv bottom
bind-key 4-k      cwm-w-mv top
bind-key 4-l      cwm-w-mv right
bind-key 4-Left   cwm-w-mv left
bind-key 4-Down   cwm-w-mv bottom
bind-key 4-Up     cwm-w-mv top
bind-key 4-Right  cwm-w-mv right

这将使 Mod4(“Windows 键”)加上 hjkl 或方向键将窗口向侧边移动。

参见

© . This site is unofficial and not affiliated with Arch Linux.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.