Ubuntu更改登錄壁紙

個人覺得Ubuntu22.04的登錄界面太單調了,鎖屏界面也不太喜歡。現在Gnome Settings裏面只能改桌面壁紙,記得之前的版本鎖屏界面也是可以改壁紙的。於是一頓搜索,發現登錄界面還是可以改的,鎖屏界面還沒有方便的更改方式,有人知道的話可以郵箱聯繫我,郵箱地址在github的個人信息裏面。

下面是更改登錄界面的過程,所謂登錄界面在Linux裏是Display Manager,Gnome的叫GNOME Display Manager (GDM) ,還有其它dm,比如LightDM,當你的系統安裝多個dm的時候,你只能選其中的一個,而且這東西會影響其它的軟件功能,以前我就遇到切換到LightDM,鎖屏快捷鍵失效,無奈得切換回GDM3。

題外話不多說,開始操作

1. 下載工具腳本

wget -qO - https://github.com/PRATAP-KUMAR/ubuntu-gdm-set-background/archive/main.tar.gz | tar zx --strip-components=1 ubuntu-gdm-set-background-main/ubuntu-gdm-set-background

2. 查看文件類型,幫助信息

看得懂腳本的可以用編輯器打開看看,腳本依賴libglib2.0-dev-bin這個包,該包提供一個叫gresource的工具能操作.gresource結尾的文件,而.gresource文件就是GTK-3的主題CSS文件預編譯後的二進制格式數據文件,該腳本就是通過這樣的方式更改相關樣式的。

  • image參數:更改登錄界面壁紙
  • color參數:更改登錄界面顏色(一個純色,沒有圖片)
  • gradient horizontal參數:更改登錄界面爲水平漸變顏色(從左到右,逐漸從一個顏色過渡到另外一個顏色)
  • gradient vertical參數:更改登錄界面爲垂直漸變顏色(不解釋)

測試了下,我還是喜歡圖片,內容豐富些。

➜  ~ ls -al ubuntu-gdm-set-background
-rwxrwxr-x 1 mephisto mephisto 10752 Feb  3 12:41 ubuntu-gdm-set-background
➜  ~ file ubuntu-gdm-set-background
ubuntu-gdm-set-background: Bourne-Again shell script, Unicode text, UTF-8 text executable
➜  ~ ./ubuntu-gdm-set-background --help

ubuntu-gdm-set-background script (for changing Ubuntu 20.04, 21.04, 21.10 & 22.04 GDM Background) HELP

there are four options
1. background with image
2. background with color
3. background with gradient horizontal ( requires two valid hex color inputs)
4. background with gradient vertical ( requires two valid hex color inputs)

Tip: be ready with valid hex color code in place of below example like #aAbBcC or #dDeEfF. Change them to your preffered hex color codes.
you may choose colors from https://www.color-hex.com/

Example Commands:

1. sudo ./ubuntu-gdm-set-background --image /home/user/backgrounds/image.jpg
2. sudo ./ubuntu-gdm-set-background --color \#aAbBcC
3. sudo ./ubuntu-gdm-set-background --gradient horizontal \#aAbBcC \#dDeEfF
4. sudo ./ubuntu-gdm-set-background --gradient vertical \#aAbBcC \#dDeEfF
5. sudo ./ubuntu-gdm-set-background --reset
6. ./ubuntu-gdm-set-background --help

RESCUE_MODE, Example Commands:

1. $ sudo ./ubuntu-gdm-set-background --image /home/user/backgrounds/image.jpg rescue
2. $ sudo ./ubuntu-gdm-set-background --color \#aAbBcC rescue
3. $ sudo ./ubuntu-gdm-set-background --gradient horizontal \#aAbBcC \#dDeEfF rescue
4. $ sudo ./ubuntu-gdm-set-background --gradient vertical \#aAbBcC \#dDeEfF rescue

Why RESCUE_MODE?
It is when you try to change the background with some other scripts and then interacted with this script,
there will be some conflicts. In case you ran other scripts to change the background and then tried this script,
found conflicts? then add 'rescue' to the end of the command as mentiond above.

Please note that for 'RESCUE_MODE' active internet connection is necessary

3. 更改登錄界面背景圖,俗稱壁紙

後面圖片路徑,輸入要使用的圖片的全路徑,別偷懶,重新登錄即可生效

➜  ~ sudo ./ubuntu-gdm-set-background --image ~/Pictures/th.jpeg

😕 Seems 'background change is successful'
Changes will be effective after a Reboot (CTRL+ALT+F1 may show the changes immediately)
If something went wrong, log on to tty and run the below command
$ sudo update-alternatives --quiet --set gdm-theme.gresource /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource

4. 想復原

sudo ./ubuntu-gdm-set-background --reset

這樣登錄界面是改好了,操作不當還是有登錄界面被改掛的風險,萬一出現這種狀況,只能遠程連接找到對應的文件復原了。這麼看來,還是希望官方在Gnome settings裏面提供相關配置選項。

另外,bing搜索的主頁每天都有一個圖片,可以用來當壁紙,還可以。

最後修改於: Monday, August 28, 2023

相關文章:

翻譯: