xsession: add option xsession.initBeforeSystemd

This commit add an option called xsession.initBeforeSystemd to setup
xsession related options such as merging xresources and doing other
x11 related setup before hm-graphical-session.target is started.

For example, before this commit, if we set dpi using xresources, it
won't work for user graphical systemd services since xresources is
merged after hm-graphical-session.target is started.
This commit is contained in:
wrvsrx 2023-06-01 22:53:12 +08:00
parent 98282a481d
commit f2b5f8c61d
No known key found for this signature in database
4 changed files with 13 additions and 2 deletions

View file

@ -139,7 +139,7 @@ in {
}
(mkIf cfg.x11.enable {
xsession.initExtra = ''
xsession.initBeforeSystemd = ''
${pkgs.xorg.xsetroot}/bin/xsetroot -xcf ${cursorPath} ${
toString cfg.size
}

View file

@ -99,6 +99,6 @@ in {
'';
};
xsession.initExtra = xrdbMerge;
xsession.initBeforeSystemd = xrdbMerge;
};
}

View file

@ -70,6 +70,13 @@ in {
description = "Extra shell commands to run before session start.";
};
initBeforeSystemd = mkOption {
type = types.lines;
default = "";
description =
"Shell commands to run before starting hm-graphical-session.target. For example, configuring x11 cursor and dpi.";
};
initExtra = mkOption {
type = types.lines;
default = "";
@ -200,6 +207,8 @@ in {
fi
unset HM_XPROFILE_SOURCED
${cfg.initBeforeSystemd}
systemctl --user start hm-graphical-session.target
${cfg.initExtra}

View file

@ -3,6 +3,8 @@ if [ -z "$HM_XPROFILE_SOURCED" ]; then
fi
unset HM_XPROFILE_SOURCED
systemctl --user start hm-graphical-session.target
init extra commands