Difference between revisions of "Cwm"

From ArchWiki
Jump to: navigation, search
m (add ja link)
 
(10 intermediate revisions by 3 users not shown)
Line 2: Line 2:
 
{{Lowercase title}}
 
{{Lowercase title}}
 
[[it:Cwm]]
 
[[it:Cwm]]
[http://monkey.org/~marius/pages/?page=cwm cwm] is an X11 [[window manager]] originally deriving from [[evilwm]]. However, the code base of evilwm did not accommodate the new features that were being added, so the code was re-written from scratch. cwm aims to be simple, and offers helpful features such as searching for windows.
+
[[ja:Cwm]]
 +
'''cwm''' is an X11 [[window manager]] with a focus on getting out of your way so you can be productive.
 +
It was originally derived from [[evilwm]], but the codebase has since been re-written from scratch.
  
A screen shot is available [http://monkey.org/~marius/cwm/shot-full.png here].
+
cwm is developed as part of the OpenBSD base system. A “portable” version which runs on Linux is also available.
  
 
==Installation==
 
==Installation==
The {{AUR|cwm}} package is available in the [[AUR]]. It requires {{Pkg|libx11}} and {{Pkg|libxft}}, both of which are available in the [[official repositories]].
+
The {{AUR|cwm}} package is available in the [[AUR]].
  
==Usage==
+
==Configuration==
To start cwm during boot, add the following to your {{ic|~/.xinitrc}} (see [[xinitrc]] and [[Start X at Boot]] for details).
+
cmw is configured by editing {{ic|~/.cwmrc}}. There is no default {{ic|cwmrc}} file; all defaults – including the keybinds – are defined in [https://github.com/chneukirchen/cwm/blob/linux/conf.c conf.c]. {{man|1|cwm|url=https://man.openbsd.org/cwm.1}} lists the default keybinds; {{man|5|cwmrc|url=https://man.openbsd.org/cwmrc.5}} lists all configuration directives.
  
/usr/bin/cwm
+
You can remove all default keybinds with {{ic|unbind-key all}} and {{ic|unbind-mouse all}} though.
  
==Documentation==
+
===Window groups===
There is a well-written man page on the official website ([http://monkey.org/~marius/cwm/cwm.1.a here]).
+
cwm lacks traditional ‘workspaces’; instead you can assign windows to a ''group''. This is a more flexible approach, as two or more groups can be displayed at the same time.
 +
 
 +
For example one might put a chat/irc application in group 4, and then assign a key to toggle the visibility of that group ({{ic|bind-key <k> group-toggle 4}}) to display that group ''in addition'' to whatever other windows/groups might be displayed.
 +
 
 +
You can also use {{ic|bind-key <k> group-only <n>}} to show ''only'' windows from that group, hiding everything else.
 +
 
 +
The default for new windows is to not put them in any group, meaning they will always be displayed (what many WMs call ‘sticky’ windows). However by enabling “sticky group mode” with {{ic|sticky yes}} windows will be assigned the currently selected group by default.
 +
You can also use the {{ic|autogroup}} directory to automatically group windows.
 +
 
 +
===Moving windows===
 +
There is no action to move windows to pre-defined locations; but you can get around this with {{Pkg|xdotool}}; put this {{ic|cwm-w-mv}} script in your {{ic|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
 +
 
 +
And then bind it in cwm with something like:
 +
 
 +
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
 +
 
 +
This will make Mod4 (‘Windows key’) plus hjkl or the arrow keys move the window to the side.
 +
 
 +
==See also==
 +
* [http://cvsweb.openbsd.org/cgi-bin/cvsweb/xenocara/app/cwm/ OpenBSD source]
 +
* [https://github.com/chneukirchen/cwm Portable version]
 +
* Example cwmrc: [https://blather.michaelwlucas.com/archives/873 one], [https://github.com/Carpetsmoker/dotfiles/blob/master/x11/cwmrc two].
 +
* [https://www.nostarch.com/obenbsd2e Absolute OpenBSD] contains an introduction to cwm.

Latest revision as of 15:50, 16 July 2017

cwm is an X11 window manager with a focus on getting out of your way so you can be productive. It was originally derived from evilwm, but the codebase has since been re-written from scratch.

cwm is developed as part of the OpenBSD base system. A “portable” version which runs on Linux is also available.

Installation

The cwmAUR package is available in the AUR.

Configuration

cmw is configured by editing ~/.cwmrc. There is no default cwmrc file; all defaults – including the keybinds – are defined in conf.c. cwm(1) lists the default keybinds; cwmrc(5) lists all configuration directives.

You can remove all default keybinds with unbind-key all and unbind-mouse all though.

Window groups

cwm lacks traditional ‘workspaces’; instead you can assign windows to a group. This is a more flexible approach, as two or more groups can be displayed at the same time.

For example one might put a chat/irc application in group 4, and then assign a key to toggle the visibility of that group (bind-key <k> group-toggle 4) to display that group in addition to whatever other windows/groups might be displayed.

You can also use bind-key <k> group-only <n> to show only windows from that group, hiding everything else.

The default for new windows is to not put them in any group, meaning they will always be displayed (what many WMs call ‘sticky’ windows). However by enabling “sticky group mode” with sticky yes windows will be assigned the currently selected group by default. You can also use the autogroup directory to automatically group windows.

Moving windows

There is no action to move windows to pre-defined locations; but you can get around this with xdotool; put this cwm-w-mv script in your 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

And then bind it in cwm with something like:

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

This will make Mod4 (‘Windows key’) plus hjkl or the arrow keys move the window to the side.

See also