screen + dvtm tiling window的脫機版

dvtm真是的個好用的東西,補足了screen在layout上的不足,以往使用screen都需要開很多個shell之後在很多個shell中快速的切換,有的時候抄個東西就要換個畫面,實在非常的麻煩,然而dvtm補足這個部份,它可以將一個shell切成數個,並以tiling的方式layout出來,因此可以在同一個畫面上邊寫程式、debug、看執行結果

1. 安裝方式
# cd /usr/ports/sysutils/dvtm
# make install clean (若要修改keybind的話先make patch之後去改config.h檔)

2. 實際使用圖


3. Keyboard Command (原始程式)
Mod : 預設為 ^g, 更改於 config.h 或 -m 的方式
Mod-c : 新增一個 window.
Mod-x : 關閉目前 window.
Mod-l : 增加 5% 主視窗的寬度.
Mod-h : 減加 5% 主視窗的寬度.
Mod-j : 移到下一個視窗.
Mod-k : 移到上一個視窗.
Mod-[1..n] : 移到第 n 個視窗
Mod-. : Toggle minimization of current window.
Mod-u : Focus next non minimized window.
Mod-i : Focus prev non minimized window.
Mod-m : Maximize current window (change to fullscreen layout).
Mod-PageUp : Scroll up.
Mod-PageDown : Scroll down.
Mod-Space : Toggle between defined layouts (affects all windows).
Mod-Enter : Zooms/cycles current window to/from master area.
Mod-t : Change to vertical stack tiling layout.
Mod-b : Change to bottom stack tiling layout.
Mod-g : Change to grid layout.
Mod-s : Shows/hides the status bar.
Mod-r : Redraw whole screen.
Mod-G : Escape the next typed key.
Mod-X : Lock screen.
Mod-M : Toggle dvtm mouse grabbing. Mod-q Quit dvtm.

Mouse commands
Copy and Paste : 按 SHIFT 加左鍵反白要 Copy 的文字,SHIFT 加中鍵為貼上
Button1 click : Select window.
Button1 double click : Select window and toggle maximization.
Button2 click : Zooms/cycles current window to/from master area.
Button3 click : Toggle minimization of current window.

4. Keyboard Command (自訂改過config.h)

Mod = ^q
Mod-c = 新增一個視窗
Mod-x = 關閉一個視窗
Mod-j = 減少5%視窗寬度
Mod-l = 增加5%視窗寬度
Mod-1~n = 移動到第n個視窗
Mod-. = 視窗最小化
Mod-k or n = 移動到下個視窗
Mod-i or p = 移動到前個視窗
Mod-t = 變成tiling layout
Mod-b = 變成bottom layout
Mod-g = 變成grid layout
Mod-m = 變成max layout
Mod-r = 所有視窗重繪
Mod-X = 鎖定整個dvtm 先輸入密碼後按enter鎖定。重打一次回復
Mod-M = 啟動/關閉滑鼠
Mod-space = 切換layout
Mod-pageup = PageUP
Mod-pagedown= PageDown

Mouse commands

Copy and Pasts : 按SHIFT加左鍵反白要Copy的文字,SHIFT加中鍵為貼上
Button1 click : Select window.
Button1 double click : Select window and toggle maximization.
Button2 click : Zooms/cycles current window to/from master area.
Button3 click : Toggle minimization of current window.

send-pr (Problem Report)

使用freebsd快一年了,今天在使用thunar這個file manager的時候發現了一個問題,當建立目錄的時候用所建出來的權限一直都是777,明明我的umask是設為022怎麼建出來是有問題的,因此追了一下程式加上問google,才發現這是一個bug,但是在freebsd ports tree裡面還沒有加入,因此也是第一次機會可以送出屬於自己的PR。

1. 複製一個原始port,還沒有加入patch的
# cd /usr/ports/x11-fm/
# cp -rfv thunar thunar.orig

2. 開始修改加入patch
# cd /usr/ports/x11-fm/thunar
# make patch (先讓此ports先patch網上存在的修正檔)
# cd work/Thunar-1.0.1/thunar-vfs/
# cp thunar-vfs-io-jobs.c thunar-vfs-io-jobs.c.orig

3. 修改thunar-vfs-io-jobs.c
把檔案修改完之後存檔

4. 輸出與原始檔案比對之後相異處的patch檔
# cd /usr/ports/x11-fm/thunar/work/Thunar-1.0.1 (主程式src的根目錄)
# diff -u thunar-vfs/thunar-vfs-io-jobs.c.orig thunar-vfs/thunar-vfs-io-jobs.c > patch-thunar-vfs-io-jobs.c
# mv patch-thunar-vfs-io-jobs.c ../../files/ (移到ports修正檔目錄中)
此看我們可以看到在/usr/ports/x11-fm/thunar/files/裡面存在patch-thunar-vfs-io-jobs.c
--- thunar-vfs/thunar-vfs-io-jobs.c.orig 2009-04-04 17:03:02.000000000 +0800
+++ thunar-vfs/thunar-vfs-io-jobs.c 2010-04-21 21:51:09.000000000 +0800
@@ -433,7 +433,7 @@

again:
/* try to create the file at the given path */
- fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, DEFFILEMODE);
+ fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (G_UNLIKELY (fd < 0))
{
/* check if the file already exists */
@@ -708,7 +708,7 @@
_thunar_vfs_job_process_path (job, lp);

/* try to create the target directory */
- if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777 & ~umask(0), THUNAR_VFS_IO_OPS_NONE, error))
+ if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777, THUNAR_VFS_IO_OPS_NONE, error))
return FALSE;
}

以上是我們做完patch之後的內容

5. 驗證patch是否正確修正
# make clean (將整個port工作目錄清掉)
# make patch (重做一次patch看是否有套用自己有修改的部份)

6. 比對原始未修正的port與目前已修正的port
# cd /usr/ports/x11-fm/thunar (不是thunar.orig喔thunar.orig是原始未修改目錄)
# make clean (清掉驗證時的工作目錄,目前整個目錄除了多了一個patch-thunar-io-jobs.c整個目錄應該和原本的一樣了)
# port diff -d .orig > /tmp/thunar.patch
.orig是剛剛複製目錄時候所加的結尾,目的就是要讓port這個工具幫我們比對整個新的thunar目錄與原始的thunar.orig目錄有何差異,並輸出差異內容,我們把差異內容放在/tmp下面,最後這個在/tmp下的thunar.patch就是我們要send-pr的附加檔,內容為
===> Generating patch
===> Viewing diff with more
diff -ruN --exclude=CVS /usr/ports/x11-fm/thunar.orig/files/patch-thunar-vfs-io-jobs.c /usr/ports/x11-fm/thunar/files/patch-thunar-vfs-io-jobs.c
--- /usr/ports/x11-fm/thunar.orig/files/patch-thunar-vfs-io-jobs.c 1970-01-01 08:00:00.000000000 +0800
+++ /usr/ports/x11-fm/thunar/files/patch-thunar-vfs-io-jobs.c 2010-04-21 22:01:36.000000000 +0800
@@ -0,0 +1,20 @@
+--- thunar-vfs/thunar-vfs-io-jobs.c.orig 2009-04-04 17:03:02.000000000 +0800
++++ thunar-vfs/thunar-vfs-io-jobs.c 2010-04-21 21:51:09.000000000 +0800
+@@ -433,7 +433,7 @@
+
+ again:
+ /* try to create the file at the given path */
+- fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, DEFFILEMODE);
++ fd = g_open (absolute_path, O_CREAT | O_EXCL | O_WRONLY, 0666);
+ if (G_UNLIKELY (fd < 0))
+ {
+ /* check if the file already exists */
+@@ -708,7 +708,7 @@
+ _thunar_vfs_job_process_path (job, lp);
+
+ /* try to create the target directory */
+- if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777 & ~umask(0), THUNAR_VFS_IO_OPS_NONE, error))
++ if (!_thunar_vfs_io_ops_mkdir (lp->data, 0777, THUNAR_VFS_IO_OPS_NONE, error))
+ return FALSE;
+ }
+
===> Done

※ports這個工具是在/usr/ports/ports-mgmt/porttools/沒有的話自行安裝

7. send-pr
# setenv EDITOR vim (設定pr的編輯器為vim)
# send-pr -a /tmp/thunar.patch (-a為附加檔案)
接下來就是要填入pr裡面許多的欄位了,這裡列出需要修改的部份
From: Clockwork Box 
Reply-To: Clockwork Box
Originator: Clockwork Box
Synopsis: [PATCH] x11-fm/thunar: fix umask handling
Serverity: non-critical
Priority: low
Category: ports
Class: update
Description:
Fix umask handling, when create directory.

填完離開存檔,它就會問你要不要send送出,選擇送出就完成了

8. 等待郵送過去之後就會收到一封由FreeBSD-gnats-submit@freebsd.org所寄過來的信
Thank you very much for your problem report.
It has the internal identification `ports/145916'.
The individual assigned to look at your
report is: freebsd-ports-bugs.

You can access the state of your problem report at any time
via this link:

http://www.freebsd.org/cgi/query-pr.cgi?pr=145916

>Category: ports
>Responsible: freebsd-ports-bugs
>Synopsis: [PATCH] x11-fm/thunar: fix umask handling
>Arrival-Date: Wed Apr 21 12:50:04 UTC 2010

透過這封信就可以追蹤到目前送出的patch有沒有被accept