如何更换 Ubuntu 系统的 GDM 登录界面背景

How To Change GDM Login Screen Background In Ubuntu

如何更换 Ubuntu 系统的 GDM 登录界面背景

Whenever you log in or lock and unlock your Ubuntu 18.04 LTS desktop, you will be greeted with a plain purple-colored screen. It is the default GDM (GNOME Display Manager) background since Ubuntu version 17.04. Some of you may feel boring to look at this plain background and want to make the Login screen something cool and eye-candy! If so, you’re on the right track. This brief guide describes how to change GDM Login screen background in Ubuntu 18.04 LTS desktop.

Ubuntu 18.04 LTS 桌面系统在登录、锁屏和解锁状态下,我们会看到一个纯紫色的背景。它是 GDM(GNOME 显示管理器 GNOME Display Manager)从 ubuntu 17.04 版本开始使用的默认背景。有一些人可能会不喜欢这个纯色的背景,想换一个酷一点、更吸引眼睛的!如果是这样,你找对地方了。这篇短文将会告诉你如何更换 Ubuntu 18.04 LTS 的 GDM 登录界面的背景。

Change GDM Login Screen Background In Ubuntu

更换 Ubuntu 的 GDM 登录界面背景

Here is how the default GDM login screen background image looks like in Ubuntu 18.04 LTS desktop.

这是 Ubuntu 18.04 LTS 桌面系统默认的登录界面。

20190309200905861_46144125.png

Whether you like it or not, you will stumbled upon this screen every time you log in or lock and unlock the system. No worries! You can change this background with any beautiful image of your choice.
Changing desktop wallpaper and user’s profile picture is not a big deal in Ubuntu. We can do it with a few mouse clicks in no time. However, changing Login/Lock screen background need a little bit editing of a file called ubuntu.css located under /usr/share/gnome-shell/theme directory.
Before modifying this file, take a backup of this file. So, we can restore it if something went wrong.

不管你喜欢与否,你总是会不经意在登录、解屏/锁屏的时面对它。别担心!你可以随便更换一个你喜欢的图片作为背景。

在 Ubuntu 上更换桌面壁纸和用户的资料图像不难。我们可以点击鼠标就搞定了。但更换解屏/锁屏的背景则需要修改文件 ubuntu.css,它位于 /usr/share/gnome-shell/theme

修改这个文件之前,最好备份一下它。这样我们可以避免出现问题时可以恢复它。

sudo cp /usr/share/gnome-shell/theme/ubuntu.css /usr/share/gnome-shell/theme/ubuntu.css.bak

Now, edit ubuntu.css file:

现在,开始编辑文件 ubuntu.css。

sudo nano /usr/share/gnome-shell/theme/ubuntu.css
  • 注:这里可以选择自己喜欢的文本编辑工具,比如 vim、gedit 等,本文作者使用的是 nano。

Find the following lines under the directive named “lockDialogGroup” in the file:

在文件中找到关键字<font color=red> lockDialogGroup</font>,如下行:

#lockDialogGroup {
   background: #2c001e url(resource:///org/gnome/shell/theme/noise-texture.png);
   background-repeat: repeat; 
}
20190309201734178_211015612.png

As you can see, the default image for the GDM login screen is noise-texture.png.
Now, change the background image by adding your image path. You can use either .jpg or .png file. Both format images worked fine for me. After editing the file, the contents of file will look like below:

可以看到,GDM 默认登录的背景图片是 noise-texture.png

现在修改为你自己的图片路径。也可以选择 **.jpg **或 .png 格式的文件,两种格式的图片文件都是支持的。修改完成后的文件内容如下:

#lockDialogGroup {
   background: #2c001e url(file:///home/sk/image.png);
   background-repeat: no-repeat; 
   background-size: cover;
   background-position: center;
}

Please pay little attention to the modified version of this directive in the ubuntu.css file. I have marked the changes in bold.

请注意 ubuntu.css 文件里这个关键字的修改,我把修改点加粗了。

As you might have noticed, I have changed the line “…url(resource:///org/gnome/shell/theme/noise-texture.png);” with “…url(file:///home/sk/image.png);”. I.e You should change “…url(resource…” to “…url(file..”.

你可能注意到,我把原来的 ... url(resource:///org/gnome/shell/theme/noise-texture.png); 修改为 ... url(file:///home/sk/image.png);。也就是说,你可以把 ... url(resource ... 修改为 .. url(file ...

Also, I have changed the value of “background-repeat:” parameter from “repeat” to “no-repeat” and added two more lines. You can simply copy/paste the above lines and change image path with your own in your ubuntu.css file.

同时,你可以把参数 background-repeat: 的值 repeat 修改为 no-repeat,并增加另外两行。你可以直接复制上面几行的修改到你的 ubuntu.css 文件,对应的修改为你的图片路径。

Once you are done, save and close the file. And, reboot your system.

修改完成后,保存和关闭此文件。然后系统重启生效。

Here is my GDM login screen with updated backgrounds:

下面是 GDM 登录界面的最新背景图片:

20190309202405565_1748831120.png
20190309202502188_338757135.png

Cool, yeah? As you can see, changing GDM login screen is not that difficult either. All you have to do is to change the path of the image in ubuntu.css file and restart your system. It is simple as that. Have fun!

是不是很酷,你都看到了,更换 GDM 登录的默认背景很简单。你只需要修改 ubuntu.css 文件中图片的路径然后重启系统。是不是很简单也很有意思.

You can also edit gdm3.css file located under /usr/share/gnome-shell/theme directory and modify it as shown above to get the same result. Again, don’t forget to take the backup of the file before making any changes.

你也可以修改 /usr/share/gnome-shell/theme 目录下的文件 gdm3.css ,具体修改内容和修改结果和上面一样。同时记得修改前备份要修改的文件。

And, that’s all now. More good stuffs to come. Stay tuned!

就这些了。如果有好的东东再分享了,请大家关注!

Cheers!

后会有期。

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,457评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,837评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,696评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,183评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,057评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,105评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,520评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,211评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,482评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,574评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,353评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,213评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,576评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,897评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,174评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,489评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,683评论 2 335

推荐阅读更多精彩内容