星期一, 11月 22, 2010

awesome 變成 reparenting WM 了

半年前嘗試將 awesome 變成 compositing WM, 搞了很久也才能正確畫出各個視窗. 最近重新 pick up 這個計畫, 結果一 git pull 打算開始做的時候才發現 awesome 變成 reparenting wm 了。

所謂的 reparenting 就是在每個 top-level client(window) 的外面加一個 frame window 當作它的 parent, 這個 frame window 則用來畫 border, title bar 等由 wm 控制的元件。原本 awesome 是直接更改 client 的 border 屬性讓  X 自己畫 border, 現在就是變成兩層, 直接設定 frame window 的 border.

這樣一改讓很多原本需要直接做在 client 上的事情現在需要改在 frame window 上.... 看來又要花點時間研究了.

星期一, 11月 15, 2010

awesome wm & naughty & rounded corner

awesome 的 naughty 接收了 dbus desktop notification 然後作成一個個 wibox 顯示在螢幕上, naughty 有預設的設定可以讓使用者在 rc.lua 裡面直接改變顏色的變數。不過最近我看到 awful.wibox 裡面有個 function: awful.wibox.rounded_corners 可以讓 wibox 有圓角,試了一下,可以讓 naughty 顯示的 notification 不再是方方正正:
這張是 radius = 10 的圓角, 比較明顯, 通常這種大小的視窗用 5~8 應該比較適合.


改過的 naughty.lua 在這裡可以下載, 在 rc.lua 裡面可以加上這個設定來控制圓角的弧度:

naughty.config.presets.normal.rounded_corners = 5
或是在使用 naughty.notify 時指定:
naughty.notify({title = "awesome is", text = "AWESOME!!", rounded_corners = 5})
不過還是要說... USE AT YOUR OWN RISK

星期六, 11月 13, 2010

Awesome WM & irssi

換用 awesome 一段時間了, naughty 真的還不錯, 整合了desktop notification (基本上就是從 DBus 把訊息 handler 接過來),今天把之前寫的 irssi pingnote script 改寫了一下, 用 naughty 來顯示。


因為用了 awesome-client, 所以 rc.lua 裡面要有 require("awful.naughty")


irssi plugin:
https://gist.github.com/675259


存成 pingnote.pl 以後, 放在 ~/.irssi/scripts 或是 ~/.irssi/scripts/autorun
以後有人 ping 你看起來會像這樣 (右上角) :


還蠻融入 awesome 本身的 theme, 看起來蠻統一還不錯 (自賣自誇..XD)

星期日, 5月 30, 2010

新版 ydict ! update: 2013/07/10


最近 yahoo 的字典改版了, 害 4$ 改寫的 ydict 不能用了, 只好重新寫 parser ...
這邊是我重寫的 ydict, 配色和版面都參考之前的 ydict, 但是 parser 整個重新寫了, 以 MIT licence 釋出:

最新的版本可到這邊下載:
https://github.com/freehaha/ydict/releases


歡迎自由抓取修改, 但是使用後果自行負責!
-------------------------------
6/23 更新:
yahoo 字典的音標位置有點變, 造成音標抓不到, 改過來了
-------------------------------
6/27 更新:
改了一下切割英/中 example 的 regexp, 稍微改善一點排版

由於新版的 yahoo 字典的例句中英沒有明顯的分隔, 目前我只能由找到的第一個非英文字來分割中英文,還是有點瑕疵不過還算堪用啦 XD

-------------------------------
2012/12/07 更新
前幾天有發現 ydict 不能用了,但沒有特別注意,今天學長說不能用了我才發現還有人在用 ydict, 決定來改一改. 這個版本除了原本的功能還加上了變化型和同義字。可能還有些 bugs, 歡迎大家回報(雖然我可能不會馬上改就是了^^|||)。
-------------------------------
2013/04/02 更新
修正部份字詞 (colour, children) 會漏抓解釋的問題。
-------------------------------
2013/07/10
想說怎麼都查不到字, 結果是 yahoo 字典又改版了! 已更新.
另外開了 github 的 repo: https://github.com/freehaha/ydict, 歡迎任何 pull request.
-------------------------------
2013/07/25
yahoo 又改回之前的版本, 請到上面 github 的連結去下載最新的版本(其實是 20130402 的 版本, 上面前兩個連結將不會繼續更新, 以後請到 github 下載. 有問題的話也可以在那邊發 issue 給我.
-------------------------------
2013/08/14
後續就不在這邊更新了, 可以到以上 github 連結看 README 跟 release. 有問題還是歡迎在這邊留言, 或是到 github 發 issue ticket.

星期六, 5月 01, 2010

perl 的 'exists' in array, hash references

今天在寫 perl 發現奇怪的 bug,Glib::Timeout 收到 unhandled exception 就停掉了,看了 error log,這我明明就處裡的好好的阿!
簡化過的問題如下:
#!/usr/bin/perl
use strict;
                                                                                                                                                              
sub retundef {
    #something wrong
    return undef;
}  

my $ret = &retundef();
if(exists $ret->{dummy}) {
    print "gasp!?\n";
}  
exit 1 unless $ret;
if(@{$ret->{list}}) {
    local $, = ", ";
    print @{$ret->{list}};

}
exit 0;
看起來很簡單的 code 卻暗藏玄機,居然 return 0; why??? 我左看右看,才想到可能是 exists 的問題。perldoc 的 exists 是這樣寫的:

Although the mostly deeply nested array or hash will not spring into existence just because its existence was tested, any intervening ones will. .... This happens anywhere the arrow operator is used...
原來在 $ret->{dummy} 以後, $ret 就自動變成 hash reference 了,雖然 $ret->{dummy} 還是不存在,但是卻改變了 $ret。
------------
不得不說,喜歡 C 不是沒有原因的... perl 寫起來方便(光是 hash table 就大勝) 但是對於一些 reference,包括 GC 的處理上的確不太透明;看來我要學得東西還很多...