星期二, 10月 01, 2013

[tips] [Howto] Support Nvidia Optimus on Ubuntu 12.04 LTS (precise) [No Bumblebee needed]

For laptops which use muxless Nvidia Optimus, there's a new way to support officially on Ubuntu 12.04 LTS.

 #sudo apt-get install nvidia-319-updates nvidia-prime xserver-xorg-lts-raring 

The command will upgrade
 * kernel to 3.8 ,
 * X server RandR to 1.4
 * Install Nvidia driver version 319.

After reboot, it will use nvidia driver by default.
There is no need to upgrade to 13.10 if you prefer 12.04 LTS.

星期四, 1月 17, 2013

[tips] g_clear_pointer


因為在tracking一個bug, 
所以要backport indicator-power這個package到ubuntu precise.
意外發現了glib在2.33之後支援的一個還滿好用的function: 
g_clear_pointer()

簡言之以前的寫法,要把物件刪除再把指標設為NULL:

if (priv->object_path != NULL) {
    g_free(priv->object_path);
    priv->object_path = NULL;
}
現在只要一行就可以達成了
g_clear_pointer (&priv->object_path, g_free);
當然要backport的話作法就是相反~~