我剛剛將桌面從 Ubuntu 21.04 升級到 21.10。一切正常!當時我很開心。
但之後,我運行了一個錯誤的程序,該程序會將圖形登入畫面的背景更改為另一張圖片。
很可能是我運行的腳本:我在 21.04 期間下載了以下程式並安裝並執行它。
github.com/thiggy01/gdm-background
gdm-background/gdm-background-helper /
#!/usr/bin/env python3
import distro
import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
import shutil
from subprocess import call
class GDMBackground(dbus.service.Object):
if distro.id() == 'ubuntu':
default_theme = '/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource'
elif distro.id() == 'pop':
default_theme = '/usr/share/gnome-shell/theme/Pop/gnome-shell-theme.gresource'
backup_theme = default_theme + '~'
def __init__(self, conn=None, object_path=None, bus_name=None):
dbus.service.Object.__init__(self, conn, object_path, bus_name)
@dbus.service.method('xyz.thiggy01.GDMBackground', in_signature='s', out_signature='b',
sender_keyword='sender', connection_keyword='conn')
def SetImage(self, task, sender=None, conn=None):
action_id = 'xyz.thiggy01.GDMBackground.SetImage'
if self._check_polkit_privilege(sender, conn, action_id):
if task == 'backup':
shutil.copy(self.default_theme, self.backup_theme)
elif task == 'set':
shutil.move("/tmp/gdm3/theme/gnome-shell-theme.gresource", self.default_theme)
return True
else:
return False
@dbus.service.method('xyz.thiggy01.GDMBackground', in_signature='s', out_signature='b',
sender_keyword='sender', connection_keyword='conn')
def RestoreBackup(self, task, sender=None, conn=None):
action_id = 'xyz.thiggy01.GDMBackground.RestoreBackup'
if self._check_polkit_privilege(sender, conn, action_id):
if task == 'restore':
shutil.move(self.backup_theme, self.default_theme)
return True
else:
return False
@dbus.service.method('xyz.thiggy01.GDMBackground', in_signature='s', out_signature='',
sender_keyword='sender', connection_keyword='conn')
def RestartGDM(self, action_id, sender=None, conn=None):
if self._check_polkit_privilege(sender, conn, action_id):
call(['/usr/sbin/service', 'gdm', 'restart'])
def _check_polkit_privilege(self, sender, conn, action_id):
if sender is None and conn is None:
return
self.proxy_dbus = dbus.Interface(conn.get_object('org.freedesktop.DBus',
'/org/freedesktop/DBus/Bus', False), 'org.freedesktop.DBus')
sender_pid = self.proxy_dbus.GetConnectionUnixProcessID(sender)
self.proxy_polkit = dbus.Interface(dbus.SystemBus().get_object(
'org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority', False),
'org.freedesktop.PolicyKit1.Authority')
try:
(is_auth, is_challenge, details) = self.proxy_polkit.CheckAuthorization(
('unix-process', {'pid': dbus.UInt32(sender_pid, variant_level=1),
'start-time': dbus.UInt64(0, variant_level=1)}),
action_id, {'':''}, dbus.UInt32(1), 'cancel')
if is_auth:
return True
else:
return False
except dbus.DBusException as error:
self.proxy_polkit.CancelCheckAuthorization('cancel')
raise
if __name__ == '__main__':
DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
name = dbus.service.BusName('xyz.thiggy01.GDMBackground', bus)
gdm_background_helper = GDMBackground(name, '/xyz/thiggy01/GDMBackground')
GLib.MainLoop().run()
之後 Ubuntu 21.10 無法再載入圖形登入畫面。
螢幕上出現錯誤:監視悲傷的臉,並顯示訊息“哦不!出了問題。”出現問題且系統無法恢復。請聯絡系統管理員。
我嘗試透過使用復原模式運行 Ubuntu 21.10 來解決該問題。然後轉到根目錄並使用命令:
sudo apt install ubuntu-gnome-desktop
systemctl status gdm
systemctl start gdm
它根本不起作用。
我懷疑我運行的程式/腳本與 GNOME 40 與 Ubuntu 21.04 的設定發生衝突。請幫我找回原先的 GUI 登入畫面設定。
我嘗試使用 CTRL-SHIFT-F3 登入 Ubuntu 21.04。然後我輸入:
systemctl status gdm3
gdm.service is active (running)
Starting GNOME Display Manager.....
但有一個錯誤訊息:
Gdm: GdmDisplay: Session never registered, failing
Gdm: Child process -2037 was already dead.
答案1
我有同樣的問題。首先,您需要進入恢復根控制台。在啟動過程中按下左移或轉義鍵就可以了。https://wiki.ubuntu.com/RecoveryMode
什麼可能就足夠了
我安裝了 lightdm,但我不確定是否需要安裝 lightdm 並切換回 gdm3。這可能有效:
sudo apt reinstall gdm3 gnome-shell yaru-theme-gnome-shell
sudo service gdm3 restart
我做了什麼
首先,我運行恢復選項以恢復原始文件。沒有效果。我使用了具有 --restore 標誌的不同腳本,而不是您發布的 Python 程式碼。看起來他們兩個都這樣做:
mv /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource~ \
/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource
然後我安裝了lightdm。
# Should install then show UI to switch from gdm3 to lightdm
sudo apt install lightdm
重新啟動後就可以了,但是當我重新登入 Gnome 後,UI 就出現了問題。例如:按 Super 鍵會彈出應用程式搜尋框,但圖示繪製重疊且閃爍,就像幀緩衝區問題一樣。 lightdm 在左下角也顯示了 Ubuntu 版本 21.04。我認為 lightdm + gnome 在 21.10 中還沒有得到正確支援。
最後,我重新安裝了 gdm3、gnome-shell 和 yaru 主題,並從 lightdm 切換回 gdm。
sudo apt reinstall gdm3 gnome-shell yaru-theme-gnome-shell
# Switch back to gdm3
sudo dpkg-reconfigure gdm3
重新啟動,一切再次正常,仍然是 gdm3 的相同預設背景圖像。需要駭客來更改背景圖像,這實在是太無聊了,但我們做到了。