跳轉到內容

X11/視窗管理器/ctwm 指南

來自華夏公益教科書,開放的書籍,開放的世界

型別: 堆疊 語言: C 許可證: GPL

克勞德的選項卡式視窗管理器

[編輯 | 編輯原始碼]
CTWM 3.7 screenshot captured on Debian 7 GNU/Linux
CTWM 3.7 螢幕截圖,在 Debian 7 GNU/Linux 上捕獲

CTWMTWM 的一個分支,允許使用 多個桌面,它是一個可定製的、輕量級且最小的 重新父級化視窗管理器,在各種較舊和較新的 UNIX(及其衍生系統)作業系統上使用。目前它不符合 ICCCMEWMH 標準,但具有一些 GNOME 支援(有一個名為 ETWM 的分支,聲稱正在開發中,符合 ICCCM 2.0 和 NetWM/EWMH 標準)。

開發歷史

[編輯 | 編輯原始碼]

CTWM 的起源可以追溯到 1987 年,當時 Tom LeStrange 編寫了 Tom 的視窗管理器。1989 年,TWM 被 X Consortium 採用,成為 X11 的標準視窗管理器,並更名為 Tab Window Manager。克勞德·勒科曼德爾 <Claude.Lecommandeur@Epfl.Ch> 受 HP 的 MWM 基視窗管理器(提供可配置的工作區)的啟發,將 多個工作區 新增到 TWM 中,並在 1992 年將其釋出為 CTWM。2003 年,當克勞德停止開發時,該專案由理查德·萊維特 <levitte@lp.se> 繼續。2014 年之後,馬修·富勒 <fullermd@over-yonder.net> 接管了該專案。截至本文撰寫之時(2017 年年中),他是當前維護者。

CTWM 視窗管理器的特點包括

  • 堆疊視窗
  • 支援 多個桌面
  • C 編寫
  • 自動升起或點選獲取焦點模式
  • 支援 M4 用於使用者定義的宏
  • 支援 XToolkit 客戶端(使用 XLib 和 XResources)
  • 視窗裝飾(包括 邊框 和帶有可配置 標題按鈕標題欄
  • "形狀" 視窗
  • 透過 標題按鈕、指標(滑鼠)按鈕或鍵盤支援彈出選單
  • 支援圖示管理
  • 支援主題和自定義顏色
  • 支援桌面桌布
  • 支援 XPM、JPEG 和 IMCONV'd 影像
  • 支援 GNOME
  • 支援聲音
  • 開源 並在許多平臺上免費提供

使用 CTWM

[編輯 | 編輯原始碼]

CTWM 是一個傳統的 X 視窗管理器,與現代 X "桌面"、Microsoft Windows 或 Mac OS/X 不同。沒有圖形化的 "設定" 管理器。啟動 CTWM 和自定義您的環境是透過使用者會話管理器或透過編輯您的 X 配置檔案來完成的,例如 ~/.xinitrc~/.xprofile 等,使用普通的文字編輯器。以下操作是正常編譯的預設值,您的系統管理員可能已將預設值配置得不同,或者編譯了沒有某些功能的 CTWM,YMMV。

設定您的 X 視窗環境

[編輯 | 編輯原始碼]

您的 ~/.xinitrc 檔案是一個由 xinit 及其前端 startx 讀取的 shell 指令碼。xinit 程式啟動 X Window System 伺服器,並在未使用顯示管理器的系統上作為第一個客戶端程式執行。它用於在啟動 X 時啟動守護程式(後臺執行的應用程式)、設定環境以及執行視窗管理器和其他程式。您的系統管理員可能已在您的主目錄中放置了一個 .xinitrc 檔案,其中包含一些預設的啟動應用程式和預設的視窗管理器或桌面環境。在文字編輯器中開啟它(嘗試 nano .xinitrc)並向下滾動到檔案末尾。您應該將預設視窗管理器(通常是 twm)更改為 ctwm,並在儲存檔案之前進行任何其他更改。

視窗操作

[編輯 | 編輯原始碼]

在 CTWM 的預設配置中(可能位於 /usr/lib/X11/[c]twm/system.ctwmrc 中),標題欄 有兩個按鈕

  • 右側 "調整大小" 按鈕(巢狀的正方形):使用者將滑鼠指標拖動到要移動的邊緣,然後在視窗達到所需大小後釋放。
  • 左側 "最小化" 按鈕(點):將視窗最小化。單擊圖示以恢復它。

左鍵單擊 標題欄 或突出顯示的區域,會將視窗提升到視窗堆疊的頂部;按住按鈕並將輪廓拖動到螢幕上的新位置,然後釋放按鈕,會將視窗移動到那裡。

左鍵單擊桌面會彈出一個預設操作選單(XToolkit 應用程式)。

  • "Xterm" 一個 "終端",您可以使用它來啟動程式或訪問遠端計算機。
  • "Calculator" 一個計算器
  • "Xman" 一個用於瀏覽可用的程式文件的手冊瀏覽器。
  • "Xmag" 一個螢幕放大鏡。
  • "Restart" 重新啟動 CTWM,重新載入 .ctwmrc 檔案。(在編輯您的 ~/.ctwmrc 檔案後使用)
  • "Exit" 退出 CTWM(並關閉 X 視窗)。

在桌面上右鍵單擊會彈出一個視窗操作選單。選擇操作,然後左鍵單擊要操作的視窗。

  • "Occupy" 允許您選擇窗口占據哪些工作區。
  • "Occupy All" 將視窗複製到所有 "WorkSpaces"。
  • "Iconify" 將視窗圖示化/取消圖示化。
  • "Refresh" 如果螢幕上有 "artifacts" 則重新整理螢幕。
  • "Vanish" 如果窗口占據了其他工作區,則將其從當前工作區中刪除。
  • "Info" 獲取視窗的 X-Windows 資訊。
  • "Resize" 點選並拖動滑鼠指標到要移動的視窗邊緣,然後在視窗達到所需大小後釋放滑鼠。
  • "Move" 勾勒並移動螢幕上的視窗。
  • "Adopt Window" (請參閱 "man" 頁面)
  • "Animate" 重新開始動畫(如果有)。
  • "Don't animate" 停止動畫(如果有)。
  • "Send Delete" 關閉視窗。
  • "Kill Window" 關閉視窗的最後手段(用於行為異常的程式)。
  • "Pin menu" 使選單停留在螢幕上。

沒有停靠欄、托盤或選單欄,但如果您啟動一個獨立的合成管理器(例如 Compton),則可以新增這些。

工作區操作

[編輯 | 編輯原始碼]

管理圖示

[編輯 | 編輯原始碼]

配置 CTWM

[編輯 | 編輯原始碼]

CTWM 的配置是透過使用普通的文字編輯器編輯 ~/.ctwmrc 檔案來完成的。如果您有一個 /twmrc 檔案,它會使用該檔案。檢視 Dan Lilliehorn 的廣為人知的 "Complete & Commented .ctwmrc"ctwm.org 上(注意:自大約 3.6 版之後就沒有更新)。視窗管理器的 "Feel" (來自 "Look-and-Feel") 主要有兩種型別:"Focus-follows-mouse" (有時稱為 "Auto-Raise");或者 "Click-to-focus"。CTWM 可以同時實現兩種方式。配置檔案主要包含三個部分:變數;繫結;和選單。在討論視窗裝飾之後,我們最後會看看選單部分。

自動提升

[編輯 | 編輯原始碼]

這是一個典型的自動提升變數部分,您的情況可能有所不同。

### GENERAL CTWM CONFIG 

## Don't grab server when popupping up menus and moving opaque windows
NoGrabServer

## Respect program-requested positions: "on", "off" or "non-zero"
UsePPosition "non-zero"

## Don't use the default titlebuttons and bindings
#NoDefaults

## Place windows in a pseudo-random location: "on", "off", "all", "unmapped"
RandomPlacement "on"

## Remember if window was iconified when restarting window manager
RestartPreviousState

## Raise window when one click on it
#RaiseOnClick

## Use Button 1 to raise a window
#RaiseOnClickButton 1

## Automticcally raise window when cursor enters the window
AutoRaise

## if Autoraise, wait N ms before raising it
RaiseDelay 250

## Transient windows get focus automatically when created
AutoFocusToTransients

## Transient window on top if n% smaller than parent window
TransientOnTop 50

## Don't send key events from the titlebar 
## and icon managers to the application
#NoTitleFocus

# Use sloppy Focus
#SloppyFocus

# Don't use pointer-driven keyboard focus, but click to focus
#ClickToFocus

# Don't wait for the cursor to cross an edge to resize the window
AutoRelativeResize

# Don't move windows Off the screen
#DontMoveOff

# Moving the small window in the WorkspaceManager will move the actual window
ReallyMoveInWorkspaceManager

# Keep menus up if the cursor has not yet been entered by the pointer
StayUpMenus

### WINDOWS RING 

WindowRing {
##        "AppsClassName"
}

## f.wrapring warps only to windows visible in the current space
WarpRingOnScreen

## Don't raise windows when pointer is wraped to them
NoRaiseOnWarp

## Deiconify any iconified windows it encounters.
WarpUnmapped

這是一個典型的自動提升繫結部分,您的情況可能有所不同。

## Key bindings

# Ignore caps lock (lock) and num lock (m2) modifiers
IgnoreModifier { lock m2 }

# Raise/lower windows with C-S-Up/Down
"Up"    =  c s	  : window : f.raise
"Down"  =  c s 	  : window : f.lower

# You can use your favorite keys to go directly 
# the preferred apps
#"F5"  =  : all : f.warpto "emacs"
#"F6"  =  : all : f.warpto "Mozilla-bin"
#"F7"  =  : all : f.warpto "bitchx" 

# Use the windowring using M-Tab/C-Tab 
# (you must define apps that go in the windowring, see WindowRing above)
"Tab" = m : window : f.warpring "next"
"Tab" = c : window : f.warpring "prev"

## Workspaces and screens

# Win+Up   : change workspace
"Up" = m4    : all : f.prevworkspace
# Win+Down : change workspace
"Down" = m4    : all : f.nextworkspace

# Win+Right/Left: change screen
"Left"  = m4 : all : f.warptoscreen "back"
"Right" = m4 : all : f.warptoscreen "next"


## Windows placement

# Iconify window with Ctrl+Esc, Deiconify with Win+Esc
"Escape"        = c     : window        : f.iconify
"Escape"        = m4    : iconmgr       : f.deiconify
"Return"        =       : iconmgr       : f.deiconify

# Ctl+Win+Right/Left: push window
"Left"  = c m4    : window : f.pack "left"
"Right" = c m4    : window : f.pack "right"
"Up"    = c m4    : window : f.pack "top"
"Down"  = c m4    : window : f.pack "bottom"

# Win+Tab: forward in iconmgr
"Tab" = m4    : all : f.forwiconmgr
# Win+a: backward in inconmgr
"a" = m4    : all : f.backiconmgr

# Pointer bindings

## In Windows, icons and iconmanager
## Raise/lower window with Button1 and Button3, iconify with Button2
Button1 =    m : window|icon  : f.lower
Button2 =    m : window|icon  : f.iconify
Button3 =    m : window|icon  : f.raise

## Move window with Button1 in title, Raise/lower it with Button 2
Button1 =    : title       : f.move
Button2 =    : title|frame : f.raiselower

## Move window with C-Button2
Button2 =    c : window : f.move

## Resise window with C-Button3 and with Button1 on frame
Button3 =    c : window : f.resize
Button1 =      : frame  : f.resize

## Move or de-iconify icons with button 1
Button1 = : icon : f.function "move-or-iconify"

# Squeeze window with mouse wheel
Button4 =      : title          : f.squeeze
Button5 =      : title          : f.squeeze

# raise window with a click on the icon manager
Button1 =       : iconmgr       : f.iconify

## Bind menus to pointer

# Mouse Buttons on the root window open main menus
Button1 =    : root : f.menu "defops"
Button2 =    : root : f.menu "TwmWindows"
Button3 =    : root : f.menu "TwmIcons"

# Cltr+Mouse Buttons on the root window open secondary menus
Button1 =  c : root : f.menu "TwmWorkspaces"
Button2 =  c : root : f.menu "TwmAllWindows"
Button3 =  c : root : f.menu "windowops"

# Open windowops menu also on windows titlebars and iconmanager
Button3 =    : title|iconmgr : f.menu "windowops"

點選聚焦

[編輯 | 編輯原始碼]

這是一個典型的點選聚焦變數部分,您的情況可能有所不同。

### GENERAL CTWM CONFIG 

## Don't grab server when popupping up menus and moving opaque windows
NoGrabServer

## Respect program-requested positions: "on", "off" or "non-zero"
UsePPosition "non-zero"

## Number of outline to be displayed when (de-)iconnifying a window
Zoom 0

## Don't use the default titlebuttons and bindings
#NoDefaults

## Place windows in a pseudo-random location: "on", "off", "all", "unmapped"
RandomPlacement "on"

## Remember if window was iconified when restarting window manager
RestartPreviousState

## Raise window when one click on it
RaiseOnClick

## Use Button 1 to raise a window
RaiseOnClickButton 1

## Automticcally raise window when cursor enters the window
#AutoRaise 

## if Autoraise, wait N ms before raising it
#RaiseDelay 250

## Transient windows get focus automatically when created
AutoFocusToTransients

## Don't send key events from the titlebar 
## and icon managers to the application
#NoTitleFocus

# Use sloppy Focus
#SloppyFocus

# Don't use pointer-driven keyboard focus, but click to focus
ClickToFocus


### WINDOWS RING 

WindowRing {
##        "AppsClassName"
}

## f.wrapring warps only to windows visible in the current space
WarpRingOnScreen

## Don't raise windows when pointer is wraped to them
NoRaiseOnWarp

## Deiconify any iconified windows it encounters.
WarpUnmapped

這是一個典型的點選聚焦繫結部分,您的情況可能有所不同。

## Key bindings

# Ignore caps lock (lock) and num lock (m2) modifiers
IgnoreModifier { lock m2 }

# Change workspace with C-Up/Down
"Up"  	=  c 	: all : f.prevworkspace
"Down" 	=  c 	: all : f.nextworkspace

# Raise/lower windows with C-S-Up/Down
"Up"    =  c s	  : window : f.raise
"Down"  =  c s 	  : window : f.lower

# You can use your favorite keys to go directly 
# the preferred apps
#"F5"  =  : all : f.warpto "emacs"
#"F6"  =  : all : f.warpto "Mozilla-bin"
#"F7"  =  : all : f.warpto "bitchx" 

# Walk the windowring using M-Tab/C-Tab 
# (you must define apps that go in the windowring, see WindowRing above)
"Tab" = m : window : f.warpring "next"
"Tab" = c : window : f.warpring "prev"


## Workspaces and screens

# Win+Up   : change workspace
"Up" = m4    : all : f.prevworkspace
# Win+Down : change workspace
"Down" = m4    : all : f.nextworkspace

# Win+Right/Left: change screen
"Left"  = m4 : all : f.warptoscreen "back"
"Right" = m4 : all : f.warptoscreen "next"


## Windows placement

# Iconify window with Ctrl+Esc, Deiconify with Win+Esc
"Escape"        = c     : window        : f.iconify
"Escape"        = m4    : iconmgr       : f.deiconify

# Ctl+Win+Right/Left: push window
"Left"  = c m4    : window : f.pack "left"
"Right" = c m4    : window : f.pack "right"
"Up"    = c m4    : window : f.pack "top"
"Down"  = c m4    : window : f.pack "bottom"

# Win+Tab: forward in iconmgr
"Tab" = m4    : all : f.forwiconmgr
# Ctrl+a: backward in inconmgr
"a" = m4    : all : f.backiconmgr


# Pointer bindings

## In Windows, icons and iconmanager

## Raise/lower window with Button1 and Button3, iconify with Button2
Button1 =    m : window|icon  : f.lower
Button2 =    m : window|icon  : f.iconify
Button3 =    m : window|icon  : f.raise

## Move window with Button1 in title, Raise/lower it with Button 2
Button1 =    : title|frame : f.move
Button2 =    : title|frame : f.raiselower

## Move window with C-Button2
Button2 =    c : window : f.move

## Resise window with C-Button3
Button3 =    c : window : f.resize

## Move or de-iconify icons with button 1
Button1 = : icon : f.function "move-or-iconify"

## Activate window from the incon manager with button1
Button1 =    : iconmgr : f.function "activate-me"

# Squeeze window with mouse wheel
Button4 =      : title          : f.squeeze
Button5 =      : title          : f.squeeze


## Bind menus to keys

# Mouse Buttons on the root window open main menus
Button1 =    : root : f.menu "defops"
Button2 =    : root : f.menu "TwmWindows"
Button3 =    : root : f.menu "TwmIcons"

# Cltr+Mouse Buttons on the root window open secondary menus
Button1 =  c : root : f.menu "TwmWindows"
Button2 =  c : root : f.menu "TwmWorkspaces"
Button3 =  c : root : f.menu "windowops"

# Open Window menu also on windows titlebars and iconmanager
Button3 =    : title|iconmgr : f.menu "windowops"

視窗裝飾

[編輯 | 編輯原始碼]

使用者介面樣式有很多選擇:OPEN LOOK,使用標題欄上的一個按鈕,就像早期 SUNview 所使用的那樣;ICE,這是一種傳統的 UNIX 外觀,使用兩個按鈕,就像 TWM 所使用的那樣;Motif 三按鈕樣式,就像 MWM 所使用的那樣,並在 *Motif Style Guide* 中進行了描述;以及現代 X 視窗管理器和 X 桌面環境(如 GnomeKDE)的所謂 "Clean" 四按鈕樣式。

OPEN LOOK
[編輯 | 編輯原始碼]
Open Windows using olwm.
使用 olwm 開啟視窗。

Open Look 在左側使用一個標題按鈕,用於將視窗圖示化。在標題欄上點選按鈕 1(通常是滑鼠左鍵)會將視窗提升到視窗堆疊的頂部;按鈕 2(中間按鈕)會移動視窗;按鈕 3(通常是右鍵)會彈出一個選單(通常是針對視窗執行的操作)。

ICE default "Look" (TWM)
ICE 預設 "Look" (TWM)

在預設的 ICE 配置中,標題欄上有兩個按鈕

  • 右側 "Resize" 按鈕 (f.resize):使用者將滑鼠指標拖動到要移動的邊緣,然後在視窗達到所需大小後釋放滑鼠。
  • 左側 "Iconify" 按鈕 (f.iconify):將視窗圖示化。

標題欄 上的 左鍵單擊 會將視窗提升到視窗堆疊的頂部; 中鍵單擊 會移動視窗; 右鍵單擊 會將視窗傳送到視窗堆疊的底部。

Motif default "Look" (MWM)
Motif 預設 "Look" (MWM)

Motif 使用三個按鈕

  • 最右側 "Maximize" 按鈕 (f.fullzoom):將視窗調整到顯示器的全尺寸。
  • 右側內側 "Minimize" 按鈕 (f.iconify):將視窗圖示化。
  • 左側 "Menu" 按鈕 (f.menu "name_of_menu"):通常是針對視窗執行的操作的選單。

此外,在 標題欄 或突出顯示的區域 (f.move) 上 左鍵單擊,拖動到螢幕上的新位置,然後釋放會將視窗移動到該位置。

Gnome Desktop
Gnome 桌面環境的 "CLEAN" 樣式。
  • 最右側 "Close" 按鈕 (f.delete 或 f.destroy 或 f.deletedestroy):關閉視窗。
  • 右側中間 "Maximize/Restore" 按鈕 (f.fullzoom):將視窗調整到顯示器的全尺寸。
  • 右側內側 "Minimize" 按鈕 (f.iconify):將視窗圖示化。
  • 左側 "Menu" 按鈕 (f.menu "name_of_menu"):通常是針對視窗執行的操作的選單。

此外,在 標題欄 或突出顯示的區域 (f.move) 上 左鍵單擊,拖動到螢幕上的新位置,然後釋放會將視窗移動到該位置。

華夏公益教科書