顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

2013年2月19日 星期二

改變日文版Firefox內建的Google搜尋語系

0 個回應

前幾天把KDE4.10的界面語系改成日文(奇怪的是,~/圖片 等資料夾名稱沒有變,我記得GNOME會),基本上幾乎沒有什麼障礙,惟Firefox的搜尋框都被日文版的設定給覆蓋掉了,變成只能用日本語Google搜尋,而且完全不理會cookie,下次搜尋還是一樣強制變回日本Google。

經過實驗,修改~/.mozilla/firefox/*.default/searchplugins/google.xml是無效的,把firefox-locale-ja套件(Mint)裡的那個.xpi檔解開也沒有東西能改。

最後發現解法是編輯

/usr/lib/firefox/distribution/searchplugins/locale/ja/google-jp.xml

然後把裡面的相關的"ja"字樣全改成"zh_TW";"google.co.jp"則全改成"google.com.tw"。

(用kate編輯該檔案似乎會有問題,換行什麼的我也不是很了解,嘗試前請先備份原始檔案,或者用vim/emacs試試)

要改成其他語系大概也是如法炮製,或者可以嘗試Mycroft Project,直接安裝各種語系的搜尋引擎(但裡面沒有能用的正體中文版Google)。


2012年11月6日 星期二

在tmux裡使用Emacs會遇到的一些問題

0 個回應

GUI版的Emacs好看是好看,但啟動時間再怎麼樣也是比純文字界面遲緩。而且KDE的工具列還得多一個Emacs佔空間。於是最後狠下心把Solarized Theme給扔了(這主題需要GUI版的Emacs才能用),裝上Tmux。但發現還有一些問題要處理:

1. 修改~/.zshrc或~/.bashrc,加上:

alias emacs='emacs -nw'
        如此一來直接在終端機輸入emacs會開啟CLI(文字界面)版本的Emacs
2. 再加上:
alias ta='if tmux attach-session -t 0;then;else tmux;fi'
        會這樣做是因為我發現如果只是平常使用,通常應該不會在Tmux裡開到一個以上的session(至少我從沒有這種需要...),而且每次detach掉還要打一長串tmux attach-session -t [number]掛回來很麻煩,乾脆弄成一開終端機只要打ta就能開tmux,而且當已經有session存在的話直接attach進去。

3. 編輯~/.tmux.conf,不存在請自行建立。
unbind C-b
set -g prefix M-C-b
bind-key k confirm-before -p "kill-window #W? (y/n)" kill-window

因為Tmux預設的prefix (C-b)會跟Emacs相衝,最後找來找去發現大概只有M-C-b (Ctrl-Alt-B)這個binding沒有相衝問題,而且在其他主機上用Tmux也不會太難以習慣。

然後kill-window我改成prefix + k,比較符合Emacs在kill buffer時的使用習慣。

4. 編輯.emacs,加入
;;解決tmux下無法切換buffer以及一些key-binding的問題
(global-set-key (kbd "C-x M-[ d") 'previous-buffer)
(global-set-key (kbd "C-x M-[ c") 'next-buffer)
(global-set-key (kbd "M-[ c") 'forward-word)
(global-set-key (kbd "M-[ d") 'backward-word)
如此key-binding問題會少一點(苦笑)

5.下載xclip-mode,丟到~/.emacs.d/lisps/裡後,~/.emacs加上:
;; xclip-mode
(load "~/.emacs.d/lisps/xclip-1.0.el")
(define-minor-mode xclip-mode
  "Minor mode to use the `xclip' program to copy&paste."
  :global t
  (if xclip-mode
      (turn-on-xclip)
    (turn-off-xclip)))
(xclip-mode t)
可以解決X11與Emacs剪貼簿共用的問題。

6. 換到文字界面的Emacs後,其餘還發現有部份Org-mode裡原本可以使用的key-binding突然變得不能用了(例如Shift+[Arrow],尤其Super鍵是在X11裡定義的,除非經過麻煩設定,不然tty或Terminal裡是無法辨識這個鍵的),這問題請參考Org-mode的官方說明文件:http://orgmode.org/manual/TTY-keys.html ,通常Org-mode裡會出問題的key-binding這裡都有其他按法。

————————————————————————————

裝上Tmux,並換到CLI版的Emacs,優點在於:
  1. Emacs啟動速度變快了
  2. 桌面上的視窗變少了,一個Terminal emulator就可以解決一堆事情。
缺點?嗯...
  1. 滑鼠快被我荒廢了wwwwwww

2012年9月4日 星期二

Installing Lubuntu on iBook G3

0 個回應


Out of nothing, trying to install Lubuntu 12.04 on iBook G3.

It amazed me that this 1999's iBook G3 still could boot and run well with MacOS9 after staying nearly 4-years untouched. On contrast, the motherboard of my old desktop (about bought on 2007) broken 2 month ago after staying half a year unused.

Lubuntu officially provides the iso of liveCD for PowerPC and Intel-based Macs. At first, I download lubuntu-12.04-desktop-powerpc.iso and burn the image with k3b in the lowest speed (10x). However, iBook G3 can't read it at all...

After seeking for some solution, it seems that many old cd-rom can't read the CDs burn with some fancy(?) modern CD burning program like k3b, so I try again with Nero and choose "DAO" (of course, also in the lowest speed), now iBook sometimes can read it.(err...the chance to work is about 15%...)

It took about half an hour or more to boot and enter LXDE. nevertheless, iBook freezed after double-click on install program... Well...So, download lubuntu-12.04-alternate-powerpc.iso (text-based installer, just like the one on Debian, suitable for low-memory system) and try again.

Installing cost about 3 hours, boot loader is Yaboot that I've never heard of. But shit, the whole desktop environment runs extremely slow though LXDE team claimed that LXDE can run on Pentium II 266 MHz/192 MB in a moderate~fast speed...
cat /proc/cpuinfo
processor : 0
cpu : 740/750
temperature : 47-49 C (uncalibrated)
clock : 366.666663MHz
revision : 131.0 (pvr 0008 8300)
bogomips : 33.28
total bogomips : 33.28
timebase : 16644884
platform : PowerMac
model : PowerBook2,1
machine : PowerBook2,1
motherboard : PowerBook2,1 MacRISC2 MacRISC Power Macintosh
detected as : 64 (iBook (first generation))
pmac flags : 0000000d
L2 cache : 512K unified
pmac-generation : NewWorld
Memory : 192 MB
As a lightweight web browser, Midori is still too fat for this iBook, then I found this:
http://www.compmiscellanea.com/en/lightweight-web-browsers-for-linux.htm

I think NetSurf may be a good choice.However, after some test, NetSurf is still too slow and Dillo cannot support Chinese...Hmmmmm...


Of course, I've try pcmanx-gtk2, but also runs extremely slowly. Fortunately, Pidgin works well and smoothly.

Now I learned that MacOS9.2.2 may be the most lightweight GUI OS I've ever used...(though nowadays it has no usability at all...)

Opening a new LX Terminal takes 6~8 sec...And this is after killing a lot of resources-drained progress like "update-apt-xapi" "update-manager" in tty because ubuntu's redundant and nonsense update-manager always pop up automatically, drained all the resources and freeze the whole system.

In conclusion, do not trying install Lubuntu on the first generation iBook G3...

2012年9月3日 星期一

Quickly Customize GRUB2 Background Image

0 個回應

  1. (Optional) Reboot, press "c" when GRUB2 menu appear, and input 'vbeinfo' to check available resolutions for GRUB2. 'exit' to quit.
  2. Resize picture to fit size, you can use ImageMagick to do this in one line without GIMP:
  3. convert -resize 1366x768^ -gravity Center -extent 1366x768 the_image_you_like.jpg background.jpg
  4. cp background.jpg /boot/grub/
  5. sudo update-grub
  6. If output like this, it successful: 
Generating grub.cfg ...
Found background image: background.jpg
Found linux image: /boot/vmlinuz-3.2.0-23-generic
Found initrd image: /boot/initrd.img-3.2.0-23-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
Found Windows Recovery Environment (loader) on /dev/sda2
done
        Note for convert:
            The "^" is a geometry option flag, which will resize image base on the smaller fitting dimension.
            The parameter -extent will crop the region out of 1366x768.
            This command is also very useful when setting wallpaper in LXDE due to its poor capability in cropping image.

        I also found some guide on Google to customize GRUB2 background image but they need to edit /etc/grub.d/05_debian_theme or 06_mint_theme. However, after some test, it seems not essential because Mint13 have no GRUB2 background by default. (Tested on Mint13).

        Update:
        If your distro has GRUB2 background image by default, check /boot/grub and /usr/share/images/desktop-base.
        update-grub will scan these directories one by one, and the early one will be applied.

        2012年8月12日 星期日

        普通人(非程式設計師)的.emacs設定檔

        8 個回應

        Emacs最麻煩的地方大概就是在使用前得先搞定設定檔(~/.emacs、~/.emacs.d等)....沒有設定檔,Emacs可能會比notepad還難用。

        這篇能讓你得到一個很基礎的.emacs設定檔,快速進入狀況並能開始用Emacs跟org-mode寫點東西,省得浪費不該浪費的時間,慢慢摸索出一堆不值得花時間重新發現的東西。

        網路上能找到的Emacs設定檔都是程式設計師寫的,裡面一堆我這輩子大概絕對用不到的設定,加上很多設定複雜到無從下手改起(.emacs設定檔越多,啟動會越慢,所以能省則省),而且我不太能接受每天用的設定檔卻連自己都無法理解。於是只好自己慢慢生出一個一般使用者會用到的Emacs設定檔,而不是程式設計師所打造,所以我沒有設定縮排、語法高亮、編譯一類的東西,不過我想以一個不會寫程式(tm)的凡人來說,這個設定檔應該已經很實用了,自己也靠了這個Emacs設定檔撐過了一學期。

        Org-mode應該是使用或者改用Emacs的一個很大的拉力吧,沒有Org-mode,Emacs使用者搞不好會少一半(當初在抉擇要學Emacs跟Vim時,就是Org-mode把我拉向Emacs這邊)。Org-mode是Emacs的一個主模式,想一窺Org-mode的強大,看看這段最基礎的Org-mode教學影片:

        (其實Org文件只是普通文字檔,用Vim也能開(但就不會有標題折疊一類的功能),把檔名命名成.org結尾,下次開啟Emacs就會自動啟用Org-mode)

        有了Org-mode的加持,於是現在寫日記可以弄成這樣:
        比寫在blog或日記本上都還要方便,尤其方便日後回顧、整理。


        或者拿一個Org-mode文件來代替之前Gnome上的桌面便條紙(KDE上找不到替代品,不過現在這樣就夠方便了):

        學Emacs有什麼好處?嗯......,以一個不會寫程式的普通學生來說,個人覺得還蠻值得。寫日記、寫報告、整理思緒、GTD幾乎都用Org-mode完成(想要在手機上閱讀/整理Org文件還有MobileOrg能用,但我沒試過。),也裝了Twittering-mode上Twitter。

        現在每次開機必定常駐工具列的兩個程式就是Firefox跟Emacs,然後Firefox裝了Firemacs好讓Firefox的key binding跟Emacs相同。

        為何不學更普及、幾乎到哪台主機上都必定會有、而且不需麻煩配置就能使用的Vi/Vim?嗯...我的原因是:
        1. 對平常幾乎都只處理中文文件、很少寫程式或者處理英文文件的使用者來說,Vi的操作設計(Normal/Insert Mode....etc)沒有優勢,試著每按一次esc就要先切換一次輸入法就知道那有多彆扭了,當然這對本來就已經很熟悉Vi的使用者來說並不是問題。
        2. 當然,就是Org-Mode。


        那麼,開始吧:
        1.我的Emacs設定檔在哪裡?
        直接在~/下新增一個空白檔案,取名叫.emacs,可以直接把下面這行貼進終端機裡:
        cd ; touch .emacs
        然後~/.emacs就是設定檔了。往後啟動Emacs時會自動讀取.emacs。

        2.最基礎的常用快速鍵與操作請看stevenchan製作的簡易速查表:
        以下是個人用了一整個學期後邊用邊調出來的.emacs,自己用得還蠻舒適。





        照樣,不喜歡的可以手動更改。感謝網路上所有熱心Emacser的分享。

        注意,此設定檔僅在ubuntu10.04+GNU Emacs23與Mint 12 KDE+GNU Emacs 23測試過,不保證其他版本能夠正確執行,如有錯誤(如Emacs24的Color-theme設定與Emacs23有些許不同)請自行調整。

        .emacs中有些絕對路徑(如/home/kuanyui/)請自行更改 ,因為有時相對路徑不知為何在.emacs中會失效。

        這個設定檔中,除了solarized-theme配色外,.emacs.d/lisps已經預先加裝了
        • Org-mode
        • Markdown-mode
        • popup-kill-ring
        • undo-tree
        • auto-complete(AC)
        • twittering-mode(上Twitter用,需自行安裝GnuPG)
        • evil-mode(模擬Vim操作用,預設不使用,有需要的請自行從.emacs中找到該行取消註釋)
        至於怎麼使用看一下.emacs裡的註釋大概沒什麼問題。

        tar.bz2包中已經把所有el編譯成elc,內含較新版的Org-mode跟Markdown-mode,如覺得心裡不夠踏實可自行將lisps資料夾中的所有.elc檔刪掉再用 M-x byte-compile-file自行編譯(有些資料夾裡面有Makefile就直接make),或是自行Google找到該el再手動安裝,都很容易取得。
        Emacs 24的話Color-Theme似乎有內建不用另外裝,請自行Google因為我也不清楚。

        不過Emacs用到現在還有幾點不滿,目前也還不知該如何解決,首先是內建那個ansi-term非常容易當機,而且對許多CLI程式支援度頗差,如man。再來是我的flyspell-mode(拼字檢查)一直搞不定,最後還被我搞掛,字典完全不能用。其他內建的拼字檢查我也一直搞不懂該怎麼使用orz。