Saturday, February 6, 2016

Fixing Lenovo U31-70 WiFi Problem

Abstract

Lenovo U31-70 is a lightweight laptop. Its WiFi performance has been a headache to many people. Most people report unstable signal dropping.

For those who use Windows and are experiencing unstable WiFi problem, you just need to solve the hardware problem.

I use Linux, so I had to go a different route to solve my driver problem.

The Hardware Problem

I opened up the laptop, and found that the two antenna cables were not properly attached to the card. There was a tape (not shown in the picture) trying to keep the two cables attached, but failed due to the tension from the bending; also, the screw to attach the card onto the main board is too close to one of the antenna contacts so it automatically grounds it, making that antenna useless. This is a design problem.



I first re-attached the two cables back to their contacts and re-tape them, and put some non-conductive material between the screw and the contact to prevent the grounding. It helped.

The Atheros 10K Driver Problem under Linux

I had used several Thinkpads since its IBM days, so I was quite surprised to have found that this Lenovo's Atheros 10K chip was not supported under Linux. People were reporting stable driver performance under Windows, and some efforts were made to bring the firmware from Windows driver to Linux. I waited a few months for Linux kernel to come to version 4.3 and spent a lot of time trying various hacks to get the driver working. I was never able to get stable performance.

I decided to replace the card with Intel Dual Band Wireless AC 3160, which is well supported by native Linux.

(I have no idea which antenna cable is intended for WiFi and which is for bluetooth, but this works for me; besides, tension-wise, this is the only way I could keep the contacts isolated.)

It has been working flawlessly.


Saturday, January 30, 2016

Coordinate Transformation Matrix for Touchscreen in multi-screen setup in X11

Currently I have a twin screen setup in Arch Linux, like this:

On the left, DELL 1901FP is turned 90 degree counter-clockwise in its portrait mode. On the right, DELL P2314T, a touch screen, is in its regular landscape orientation, with its bottom line aligning with the bottom of the rotated screen on the left.

Here's my xorg.conf for that. (Although one can also setup screen arrangement in KDE/Plasma/Gnome/etc., for KDM/SDDM/GDM/etc. to recognize it in the login screen, it's important to put this in xorg.conf)





X11 sees a (1024+1920) wide * 1280 high DISPLAY, with an upper-right corner being invisible.

Since the touchscreen is just a regular pointer device (through its driver), when I put my finger on the left border of the touchscreen on the right, the cursor goes all the way to the very left of the DISPLAY. Touchscreen is only useful if the cursor follows my finger. Therefore, we need to do some Input Coordinate Transformation.

Coordinate Transformation Matrix is precisely the needed configuration.

From the documentation above, our goal is to map the following coordinates on the left (X11's default behavior) to the ones on the right:



So that means we are solving the following system:


Here's the solution:

Convert it to float numbers:

Now we can put these numbers into the configuration, as the document instructed.





However, it doesn't work. The cursor stays on the lower right. After some debugging, I found the offsets 1024 and 200 were the culprit. They need to be a percentage, i.e. relative to the full width and height.

So 1024.0/(1024+1929) = .3476766, 200.0/1280 = .15625





I put it in /usr/share/sddm/scripts/Xsetup (or /usr/share/config/kdm/Xsetup if you haven't upgraded to plasma) as well as ~/.xprofile so it automatically runs every time.

Edit 2016-02-22: I ended up having 3 screens with two in the portrait orientation. SDDM correctly uses metamodes setting in xorg.conf, regardless of the screen power. However, KDE is more sensitive to that so sometimes the layout is messed up. Here's a script to quickly correct that.




Monday, October 19, 2015

Install Sibelius 8.0.1 on a non-C drive in Windows

Since Sibelius 8.0.0, Avid changed the installer, and it has a serious bug -- it assumes you have a C: drive before letting you choose the installation destination. I figured out a hack to install it. However, it doesn't work for Sibelius 8.0.1, so here's another way to approach it, before Avid's Sibelius team fixes the bug.

I don't have a C: drive, but Sibelius insists that I must do, so what we are trying to do here is to temporarily create a C: drive, and then create a link pointing crucial directories back to my system drive, K:. After Sibelius is successfully installed, we can then safely remove the temporary C: drive.

First, we need to create a Virtual Hard Drive (VHD) as our C:\ drive. I learned how to do this via this answer:
  • Start → run → diskmgmt.msc (accept all defaults... I'm not doing anything special below) 
  • From the menu bar select Action → Create VHD 
  • Choose the location and name the file (which will be the vhd) and specify the size and click OK. My file is K:\virtual_drive_c.vhd and the size is 1G, but I made it dynamic so it's actual size is around 16MB. 
  • Right click on the Disk # (underneath will be Unknown and the size and "Not Initialized"). Select "Initialize Disk" and click OK 
  • Right click on the black bar of the unallocated disk space and select "new simple volume". A wizard opens up an on the second page it lets you assign the drive letter. We want C: here. Complete the wizard and you're done!
Now that we have a C: drive, we can link the important folders. I learned how to do that from this post:
  • Start → run → cmd, then right click and choose "Run as Administrator". 
  • In the prompt, type the following:
K:\>mklink /j "C:\Program Files" "K:\Program Files"
Junction created for C:\Program Files <<===>> K:\Program Files

K:\>mklink /j "C:\Program Files (x86)" "K:\Program Files (x86)"
Junction created for C:\Program Files (x86) <<===>> K:\Program Files (x86)



After that, Sibelius installation should run normally. In the installer, I still choose to install the program to K:, to avoid future problems running Sibelius, since the bug is on the installer, not Sibelius itself.

Afterwards, you can reboot, and safely delete the vhd file.

Thursday, September 24, 2015

大易二十七年,行列二十七小時

綱要

我打大易輸入法很快,甚至比一些人用講的還快,但最近考慮換到行列輸入法。

我學大易輸入法的歷史

我小學正是Apple II電腦剛進入台灣的時候。那時候Apple II能插一張「佳佳漢卡」來顯示中文。打字方面只有倉頡與注音。我試學了幾次倉頡,最後都放棄。主要也因為那時候打中文的機會少,所以茍且用注音好多年。

注音很好學,但因為中文同音字太多,選字鍵就只那一排數字鍵,導至最後總鍵數高,輸入速度大大受限。

高一時做科展,要寫一堆文字報告。那時我字寫得難看,於是決定趁機把中打好好學。剛好大易輸入法剛出來,在雜誌上廣告,看到後就決定去他們公司問問看。下課後拎了書包就搭了公車去太易公司在中山北路(?)的辦公室。那時好像只有三位員工。其中一位先生看到高中生想學大易,很興奮。49元賣了我一本原價99的書,給我一疊字根卡,希望我回班上幫忙推廣。

大易的優點

大易說真的很了不起。讓我一個晚上就能把規則學完,看字根表打字。一星期內就完全不需要字根表了。我成功的例子也讓身邊很多人學大易用大易至今。那位先生應該覺得很欣慰。:)

用了二十七年的大易,打字速度其實蠻快的,有幾個朋友應該看過我打字追上一些人講話的速度。

我覺得大易的設計很好,字根的分類很直覺。基本上看到字就知道怎麼拆。其實,中文打多了,大部份人應該看到字就直接能跳過拆碼,直接以手指記憶打出來。

另外一個大優點是字根與字鍵的分布很平均,所以在常用字裡,需要選字的機會其實不多。

一些常見輸入法的問題

倉頡難學。字鍵數也偏多。

注音的問題上面提過,即使有些朋友熟到連選字鍵選字頁都一起背了起來,總鍵數還是太多,容易疲勞。

現在有很多智慧型輸入法,可以自動選字,或自動選詞,速度很快。但我對打字的需求比較傳統:我需要能夠完全預測什麼鍵會出什麼字。也就是說,我需要不用看瑩幕就能正確地打字。這樣能讓我做筆記時,眼睛不需要去顧打字窗。不管在做筆記或是創作,選字會讓我分心。我覺得這和演奏樂器的原理一樣,一個音彈拉吹敲下去,音高、音色、強弱都應該要能精確預期。

還有這些輸入法大多以詞為單位來做智慧選擇。字詞的頻率在不同軟體版本中會有出入,造成可預測性降低。

大易的缺點

版權的問題

大易的版權並非完全自由,許多自由軟體無法直接包含大易。網路上流通的合法版本是太易公司多年前釋出的,字數有限。後來雖然有許多熱心人士擴充,但也造成版本間有出入的問題。

平台的問題

我常用的作業系統有五個:Linux為主,手機Android,筆記型電腦是OSX,音樂的工作用Windows,以及平版的iOS。各個平台共通內建的繁體中文輸入法,只有注音與倉頡。(其他輸入法有的名稱相同,內容卻不統一)

由於上述的版權問題,軟體無法直接包含大易,所以這個過程只能手動。雖然花點力氣,也能把大易都裝上去(gcin, Lime, Open vanilla, 內建, JB/iAccess),但辛苦的是,每次系統或是作業環境升級,這個過程就得重來一次。

選字鍵的問題

大易的選字鍵和其他輸入法不同。大部份輸入法用上排數字鍵來選字,但大易把上排數字鍵和英文字母鍵都拿來當字根。這個設計,有效地讓總鍵數及選字的頻率都大大減少。但使用非標準選字鍵的缺點是,軟體必須特別設計來支援大易。隨著其他智慧型輸入法普及後,大易的使用族群變為少數,願意為大易特別設計的軟體就變少了。

可能的解決方案

最近發現令人驚艷的「瑲珩--動態拆碼暨動態組字」計畫,也許能解決版權、版本及字數的問題。

但平台的問題,卻是我目前面臨的挑戰。比方說,gcin是很優秀的程式,但在Chromium或是Qt升級間常常造成不相容(問題不一定是gcin本身)。雖然問題總會解決,但發生的頻率高到太不方便。

我考慮用iBus之類較普及的平台,看與其他軟體的相容性會不會好一點。選了軟體後,也要找大部份軟體都支援的輸入法,能直接用標準安裝,不用自己來。也許等大易版權過幾年釋出後,我就不用自己想辦法裝大易。但在那之前怎麼辦?

順道一提,這陣子我開始用手機上 Google 的中文語音輸入,準確度很高,但輸入標點符號很麻煩,而且跨平台很不方便,隱私上也有些顧慮。

行列輸入法

前陣子發現行列輸入法和自由軟體的精神相符
開放理念: 
中文輸入法必須跟發明人的生命及推廣該輸入法的公司分離,當使用者學會之後,不管發明人是否在世,各系統都要能夠繼續支援,使用者才有永遠的保障,就像倉頡和注音輸入法一樣。 
要讓使用者可以永遠使用,只有像倉頡一樣開放授權才可能,因此行列採開放授權,任何一種系統,都可以找工程師把行列寫進系統,成為系統的一部份。 
在生活與工作上,我已儘量使用自由開源軟體,所以行列輸入法發明人廖明德這段話和我很對味。官方網站公布大方公布的內容,就足夠讓我學輸入法。這點令人激賞。

行列的設計和大易一樣好學,一個晚上就能看著字根表打所有字。我相信沒多久就可以把字根表丟掉。目前初步的印象是,行列字根的分類,雖然也很有道理,但感覺上大易保留書寫直覺還是多一點。不過這個問題,應該在熟練之後就會自動消失。

結(未)論

老實說,我才剛學行列,還不知道(這篇仍是用大易打的)。也許我最後會放棄大易,完全轉用行列,也許我會發現行列的問題,再回到大易。但行列原發明人的胸襟,讓我很願意下功夫試試。

另外,我這篇也提到使用智慧型輸入法的潛在問題。也許從沒學過字根輸入的人可以試試能完全掌握打字結果的方法。

Wednesday, August 5, 2015

Sibelius 8 Installation on Non-standard Windows System Drive

UPDATE: This doesn't work for Sibelius 8.0.1. See this post instead for that.

Over the years I have many generations of audio software and plugins installed on Windows, which itself has gone through many version upgrades. I can't remember why but one upgrade called for changing the system drive from C: to K: (probably for a backup reason), and ever since then K: has been my system drive.

Between projects, I decided to give Sibelius 8 a try. However, the installation file (Install_Sibelius.exe, unpacked from Sibelius_8.0.0_Win.zip) downloaded from Avid gave me this error:


Error 1327 invalid drive C:\.


By inspecting the log, I concluded that was hard-coded in the installer (FAIL! To tell the truth, it has been a familiar feeling ever since Avid acquired Sibelius).

I really don't want to change the system drive again, since it would involve the painful process of re-configuring a million things. It's also after their support hours so I did some research, and after some trial and error, this is what worked for me:

1. run cmd.exe as Administrator.
2. Change into the directory where Install_Sibelius.exe resides
3. Run the following command


J:\Users\composer\Desktop>J:\Install_Sibelius.exe /s /v"/qn /l*v %temp%\AvidSibeliusx64.log"



4. Follow the standard procedure to activate the software

That's it.

PS: I very much look forward to Daniel Spreadbury's new score writer.

Wednesday, May 6, 2015

X11 Multi-seat running KDE and GNOME

I was archiving data on my old machine and decided to share my old multi-seat configurations (I don't need multi-seat anymore), in case somebody out there is trying to do the same thing.

It was a 7-year-old Dell PowerEdge server SC-1430 running dual Xeon (8 virtual cores), excellent for compiling, number crunching (machine learning), and video processing (Cinelerra), and on top of all that, it served as a file/media server running RAID 5 over RAID 0.

It was a power beast, in another sense, too, though -- it consumed a lot of power.

Since it was consuming power anyway, I decided to get rid of other computers and maximize its use, by setting up a multi-seat X11, so two users could use it at the same time. There were two sets of everything: two screens (on two NVIDIA cards), two keyboards, two mouses, and two USB sound cards. It worked just like two independent machines. In fact, one seat ran KDE and the other one ran GNOME. The login screen ran KDM, with two login boxes (default to the regular user login name) on respective screens and matching wallpapers. We were even able to play "networked" game against each other.

(Actually I had three sets of xorg.conf to support multi-seat, left-side dual screen, and right-side dual screen, and I used symlinks to dynamically switch to a different configuration. However, there's more info on dual screen setups out there so I skipped those here.)

For me, there were a few files to configure. These are the ones relevant to most people:
  • /etc/X11/xorg.conf
  • /etc/kde/kdm/kdmrc
  • /etc/kde/kdm/backgroundrc.seat0
  • /etc/kde/kdm/backgroundrc.seat1
  • /etc/udev/rules.d/60-dell-keyboards.rules (omit here; see my other post on udev for that)
  • /etc/udev/rules.d/90-creative-xmod.rules
For the sound cards, I just used the GUI setup in KDM and Gnome, respectively, to choose the right pulse audio sound device. I did use the udev to make the names easier to tell them apart.

I ran Arch Linux 64 on that one so the paths may be different if you use a different distro. I apologize in advance for not explaining the details here, many of which were specific to my system back then. I also wish I had time to dig out the document sources for these configs.


/etc/X11/xorg.conf


/usr/share/config/kdm/kdmrc


/usr/share/config/kdm/backgroundrc.seat0


/usr/share/config/kdm/backgroundrc.seat1


/etc/udev/rules.d/90-creative-xmod.rules

Friday, March 6, 2015

憶老方

(My high school homeroom teacher passed away, and this is my tribute and eulogy to him. There's no English translation.)

憶老方

老方是我師大附中三年的導師。年初他病逝,我們694班同學在臉書上私人社團裡,紛紛表達對他的懷念。我人在遠方,無法親自參加公祭,託同學把我對他的懷念和感謝帶上。

在那個時代,給老師取綽號算是不敬。老方知道我們在背後這麼叫他,卻一笑置之。回想起來,「老方」的暱稱,和益師益友的他其實很相稱。

老方教數學,扎實的數學底子,讓我一生受益無窮。但我特別欣賞的,是他在課堂上不做作的態度。有時候他導公式寫了滿黑板,最後發現結果不對,他會請同學幫忙一起看,然後發現之前錯了一步時,他會拍頭一笑,回過重來。這種和學生一起探索的態度,和我與國外博士班指導教授討論想法,竟有異曲同工之妙。後來在工作上,我也用一樣的態度來帶新進的人員。我帶出來的人,特別有實驗精神,敢於表達意見,也讓我的團隊贏得最有創意的名聲。

老方對同學們一視同仁,但我個人有個印象深刻的小故事。

社團是附中特色之一。學生們在社團裡學習經營,發揮創意,結交朋友。但不少社團幹部會因此而影響學業,所以如果成績太離譜,學校會發一張「紅單子」,讓學業成績太離譜的學生不得再擔任幹部。有趣的是,在社聯會(所有社團幹部的聯誼會)裡,「拿紅單子」有時候反而被視為努力經營社團的光榮象徵。

高二時我擔任社團社長,把大部分心力都用在社團經營上,成績一度跌落谷底。有一天,老方把我叫到他辦公室;我當然知道他要說什麼,但我覺得反正他不可能了解社團人的執著,準備好硬著頭皮聽訓,聽完就算了。

進到他辦公室,他看著我笑了笑,問我知不知道他為什麼叫我來。我點了點頭。沒想到他說,「那就好。沒其他事了。」

霎時間,所有我事前的心戰策略全無用武之地。他輕輕一點,讓簡單的真理乍現:你成績怎樣是你的事,你知道自己在幹什麼就好。

雖然這好像是廢話,但我之前在一個逼讀文化(不管是當面逼,還是用制度逼)下成長學習,這是第一次看到師長直接移步側站,讓我自己去面對問題、抉擇及後果。

老方那句話,是我這輩子最後一次讓別人來擔心我的學業。

傳道,授業,解惑,老方也。