Gnome 3中換Wallpaper之小Script

Wan Leung Wong
May 2, 2020 · 3 min read

本人在GNU/Linux中使用的Desktop Environment是為Gnome 3, 而由朝對晚對住個黑色的TERMINAL或VSCODE, 有D悶. 於是不少開發者, 將TERMINAL同VSCODE的背景, 都整成半透明, 等我們可以見到後面的WALLPAPER. 以前本人的GNOME 2 Environment, 有開發著寫了一個可定期換WALLPAPER的程式, 不過上了GONME 3後不再WORK同無再MAINTAIN, 而且本人之後一直都係用黑色的背景, 所以都無再理有無定期換WALLPAPER.

不過最近試新版UBUNTU 20.04, 發現UBUNTU官方加了不少唔錯的WALLPAPER(當然要另外安裝), 本人於是心血來朝睇下有無定期換WALLPAPER的程式.

找到一個叫Wallch的程式, 可以用apt直接安裝. 不過個程式有部份有問題, 而且太耐無MAINTAIN, LIVE EARTH之類的功能死亡. 於是就想睇下有無方法, 可以用command去改Gnome 3的wallpaper.

之後發現, 原來可用以下command 去改Gnome 3的wallpaper.

gsettings set org.gnome.desktop.background picture-uri “file://$PIC”

於是我就寫在個script, 可以在cron行定期去更換wallpaper.

程式好簡單:

由於cron入面無gnome session的env param, 所以要先在前面找回gnome session, 之後才可以行gsettings 轉wallpaper.

而在轉WALLPAPER前, 先在指的FOLDER找出所有的圖片FILE, 然後用shuf亂數抽一張圖做WALLPAPER.

本人就將個SCRIPT放CRON行, SET做每3個字轉一張WALLPAPER.

而個DIR, DEFAULT就係UBUNTU系統安裝的WALLPAPER; 又或者可以SET去自己的相簿.

Hong Kong Linux User Group

香港LINUX用家協會

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store