2012/12/04

自建 Ubuntu 的動態 Wallpaper

Ubuntu 真的好用,當然也有缺點。其中之一,就是想對桌面作一些調整時會比較麻煩。譬如,動態 Wallpaper 是既有的功能,但你想建立自己的版本,就要花一點心思。發行較久的 Ubuntu,可能已經有人開發 GUI 來簡化這個程序。但這套 GUI 又不見得可以適用於最新的 Ubuntu 發行版。我在 Ubuntu 12.10 就遇到這個問題。底下是我的解決方法。

首先,建立動態 wallpaper 的定義,譬如:~/wallpaper.xml:
<background>
  <starttime>
    <year>2003</year>
    <month>6</month>
    <day>14</day>
    <hour>05</hour>
    <minute>30</minute>
    <second>00</second>
  </starttime>
  <static>
    <duration>1795.0</duration>
    <file>/path/to/picture-1.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/path/to/picture-1.png</from>
    <to>/path/to/picture-2.png</to>
  </transition>
  <static>
    <duration>1795.0</duration>
    <file>/path/to/picture-2.png</file>
  </static>
  <transition>
    <duration>5.0</duration>
    <from>/path/to/picture-2.png</from>
    <to>/path/to/picture-1.png</to>
  </transition>
</background>
其中:
  • 可以是過去或未來。若是未來,就是等到那個時間才會更換 wallpaper;若是過去,設好就馬上生效。
  • 就是設定要顯示哪一個圖形?要顯示多少秒數?
  • 就是設定從一個圖形轉換到另外一個圖形要轉換多久?轉換到哪一個圖形?
  • 要成對出現,而且要設成可以頭尾連接。
Wallpaper.xml 設定檔完成之後,就要告訴系統以此作為 wallpaper:
gsettings set org.gnome.desktop.background picture-uri 'file:///path/to/wallpaper.xml'