git.iko.soy/typeable/nixpkgs
on master help sign in
display-managers: Fix the xsession parameters

The xsession script was called with inconsistent (depending on the display managers) and wrong parameters. The main reason for this where the spaces the parameter syntax. In order to fix this the old syntax: $1 = '<desktop-manager> + <window-manager>' Will be replaced with a new syntax: $1 = "<desktop-manager>+<window-manager>" This assumes that neither "<desktop-manager>" nor "<window-manager>" contain the "+" character but this shouldn't be a problem. This patch also fixes the quoting by using double quotes (") instead of single quotes (') [0]. Last but not least this'll add some comments for the better understanding of the script. [0]: https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s06.html

commit1273f414a784af87363ac440af2ce948b6a656b1 authorMichael Weiss <dev.primeos@gmail.com> dateSun 23 Apr 2017, 05:00 (10 years ago) parent5c25c33
3 files changed+38−10
nixos/modules/services/x11/display-managers/default.nix+36−8 nixos/modules/services/x11/display-managers/lightdm.nix+1−1 nixos/modules/services/x11/display-managers/sddm.nix+1−1
nixos/modules/services/x11/display-managers/default.nix+36−8
@@ -32,8 +32,32 @@ let
3232 ''
3333 #! ${pkgs.bash}/bin/bash
3434
35− # Handle being called by SDDM.
36− if test "''${1:0:1}" = / ; then eval exec "$1" "$2" ; fi
35+ # Expected parameters:
36+ # $1 = <desktop-manager>+<window-manager>
37+
38+ # Actual parameters (FIXME):
39+ # SDDM is calling this script like the following:
40+ # $1 = /nix/store/xxx-xsession (= $0)
41+ # $2 = <desktop-manager>+<window-manager>
42+ # SLiM is using the following parameter:
43+ # $1 = /nix/store/xxx-xsession <desktop-manager>+<window-manager>
44+ # LightDM keeps the double quotes:
45+ # $1 = /nix/store/xxx-xsession "<desktop-manager>+<window-manager>"
46+ # The fake/auto display manager doesn't use any parameters and GDM is
47+ # broken.
48+ # If you want to "debug" this script don't print the parameters to stdout
49+ # or stderr because this script will be executed multiple times and the
50+ # output won't be visible in the log when the script is executed for the
51+ # first time (e.g. append them to a file instead)!
52+
53+ # All of the above cases are handled by the following hack (FIXME).
54+ # Since this line is *very important* for *all display managers* it is
55+ # very important to test changes to the following line with all display
56+ # managers:
57+ if [ "''${1:0:1}" = "/" ]; then eval exec "$1" "$2" ; fi
58+
59+ # Now it should be safe to assume that the script was called with the
60+ # expected parameters.
3761
3862 ${optionalString cfg.displayManager.logToJournal ''
3963 if [ -z "$_DID_SYSTEMD_CAT" ]; then
@@ -107,11 +131,12 @@ let
107131 fi
108132 fi
109133
110− # The session type is "<desktop-manager> + <window-manager>", so
111− # extract those.
112− windowManager="''${sessionType##* + }"
134+ # The session type is "<desktop-manager>+<window-manager>", so
135+ # extract those (see:
136+ # http://wiki.bash-hackers.org/syntax/pe#substring_removal).
137+ windowManager="''${sessionType##*+}"
113138 : ''${windowManager:=${cfg.windowManager.default}}
114− desktopManager="''${sessionType% + *}"
139+ desktopManager="''${sessionType%%+*}"
115140 : ''${desktopManager:=${cfg.desktopManager.default}}
116141
117142 # Start the window manager.
@@ -142,6 +167,9 @@ let
142167 exit 0
143168 '';
144169
170+ # Desktop Entry Specification:
171+ # - https://standards.freedesktop.org/desktop-entry-spec/latest/
172+ # - https://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
145173 mkDesktops = names: pkgs.runCommand "desktops"
146174 { # trivial derivation
147175 preferLocalBuild = true;
@@ -155,7 +183,7 @@ let
155183 Version=1.0
156184 Type=XSession
157185 TryExec=${cfg.displayManager.session.script}
158− Exec=${cfg.displayManager.session.script} '${n}'
186+ Exec=${cfg.displayManager.session.script} "${n}"
159187 X-GDM-BypassXsession=true
160188 Name=${n}
161189 Comment=
@@ -238,7 +266,7 @@ in
238266 wm = filter (s: s.manage == "window") list;
239267 dm = filter (s: s.manage == "desktop") list;
240268 names = flip concatMap dm
241− (d: map (w: d.name + optionalString (w.name != "none") (" + " + w.name))
269+ (d: map (w: d.name + optionalString (w.name != "none") ("+" + w.name))
242270 (filter (w: d.name != "none" || w.name != "none") wm));
243271 desktops = mkDesktops names;
244272 script = xsession wm dm;
nixos/modules/services/x11/display-managers/lightdm.nix+1−1
@@ -61,7 +61,7 @@ let
6161 let
6262 dm = xcfg.desktopManager.default;
6363 wm = xcfg.windowManager.default;
64− in dm + optionalString (wm != "none") (" + " + wm);
64+ in dm + optionalString (wm != "none") ("+" + wm);
6565in
6666{
6767 # Note: the order in which lightdm greeter modules are imported
nixos/modules/services/x11/display-managers/sddm.nix+1−1
@@ -69,7 +69,7 @@ let
6969 let
7070 dm = xcfg.desktopManager.default;
7171 wm = xcfg.windowManager.default;
72− in dm + optionalString (wm != "none") (" + " + wm);
72+ in dm + optionalString (wm != "none") ("+" + wm);
7373
7474in
7575{