自定义 gnome 会话 .desktop Vs .xsession

自定义 gnome 会话 .desktop Vs .xsession

我对 gnome 自定义会话的初步理解来自

我的目标是i3gnome-flashbackUbuntu 18.04.4 LTS。但这些资源似乎提供了相互矛盾的指导。

我创建了/usr/share/xsessions/gnome-plus-i3.desktop包含有关我的自定义会话启动时的基本信息,GNOME Flashback(i3),在显示管理器中选择。

[Desktop Entry]
Name=GNOME Flashback (i3)
Comment=This session logs you into GNOME Flashback with i3

# Don't continue if i3 doesn't exist.
TryExec=i3

# TODO: How can I define my own .target file here?
Exec=/usr/lib/gnome-session/run-systemd-session gnome-session-flashback.target

Type=Application
DesktopNames=GNOME-Flashback;GNOME;
X-Ubuntu-Gettext-Domain=gnome-flashback

问题 1:我应该.target在这行定义我自己的文件吗

Exec=/usr/lib/gnome-session/run-systemd-session gnome-session-flashback.target

认为因为我正在创建自己的会话,所以我想要自己的.target文件。但是,这似乎不包含任何特定于窗口管理器的内容:

[Unit]
Description=User systemd services for the GNOME Flashback sessions
Requires=graphical-session-pre.target
Requires=indicators-pre.target
# start/tear down graphical-session.target along with the ubuntu session
BindsTo=graphical-session.target
# session leader -- if this dies, die along with it
BindsTo=gnome-session.service
# here we list the indicators that we want to load
Wants=indicator-application.service
Wants=indicator-bluetooth.service
Wants=indicator-datetime.service
Wants=indicator-keyboard.service
Wants=indicator-messages.service
Wants=indicator-power.service
Wants=indicator-session.service
Wants=indicator-sound.service
Wants=indicator-printers.service

问题2:如果我定义了自己的.target文件,是否需要将其添加到其中/usr/lib/systemd/user/,或者我可以提供完整路径并将其放在我的主目录中的某个位置?

问题 2.5:如何/usr/lib/gnome-session/run-systemd-session知道在哪里找到该.target文件?

问题 3:假设我已经走到这一步,为什么我需要使用.xsession?它似乎与.desktop文件几乎完全相同(运行一个名为 gnome-session)。

# Menu tools use this value to decide which applications
# are approriate for the current session.
if [ -z $XDG_CURRENT_DESKTOP ]; then
    export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME"
fi

# Run gnome-session and tell it to use our i3 session.
exec gnome-session --session=gnome-plus-i3 --disable-acceleration-check

问题 4:~/.config/i3/config如果所有 DBus 服务都列在以下列表RequiredComponents中,是否有必要从 i3 配置文件 () 启动各种 DBus 服务/usr/share/gnome-session/sessions/gnome-plus-i3.session

# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!

set $mod Mod4

# ...omitted for brevity

# Start the various DBus services.
exec --no-startup-id /usr/lib/gnome-settings-daemon/gsd-xsettings
exec --no-startup-id /usr/lib/gnome-settings-daemon/gsd-keyboard
exec --no-startup-id /usr/lib/gnome-settings-daemon/gsd-mouse
exec --no-startup-id /usr/lib/gnome-settings-daemon/gsd-media-keys
exec --no-startup-id /usr/lib/gnome-settings-daemon/gsd-sound

我的/usr/share/gnome-session/sessions/gnome-plus-i3.session文件是

[GNOME Session]
# To create a session with all the required GNOME background services, the easiest thing is to use gnome-session.
# We’ll create a session that includes i3 and the GNOME Flashback goodies.

# Name of the session. This can be localized.
Name=GNOME Flashback (i3)

# List of component identifiers (desktop files) that are required by the session.
# The required components will always run in the session.
# Note that RequiredComponents aren’t executables, they’re the names of .desktop files.

RequiredComponents=gnome-flashback-init;gnome-flashback;i3;org.gnome.SettingsDaemon.Sound;org.gnome.SettingsDaemon.MediaKeys;org.gnome.SettingsDaemon.Mouse;org.gnome.SettingsDaemon.Keyboard;org.gnome.SettingsDaemon.XSettings;org.gnome.Shell.Extensions;org.gnome.SettingsDaemon.PrintNotifications;

更新

答案#2: 桌面入门规格提供详细信息Exec 键 https://developer.gnome.org/desktop-entry-spec/#exec-variables

可执行程序既可以用其完整路径指定,也可以只用可执行程序的名称指定。如果没有提供完整路径,则在桌面环境使用的 $PATH 环境变量中查找可执行程序。

相关内容