slim: Sort sessions

This ensures that xfce and most others DMs are preferred over
xterm. Previously slim used directory order, which is undefined.

Of course, it's just lucky that xfce < xterm lexicographically, but
that also applies to the other display managers, AFAIK. We should have
a way to specify a DM order, but that can be accomodated by generating
desktop entries like "<NN>-session.desktop".

Fixes #4300. Parenthetical to #12516.
This commit is contained in:
Eelco Dolstra 2016-01-30 10:37:39 +01:00
parent 1a5d3e9c17
commit eeb9231009
2 changed files with 45 additions and 1 deletions

View File

@ -18,13 +18,17 @@ stdenv.mkDerivation rec {
# slim's broken PAM session handling (see
# http://developer.berlios.de/bugs/?func=detailbug&bug_id=19102&group_id=2663).
./run-once.patch
# Ensure that sessions appear in sort order, rather than in
# directory order.
./sort-sessions.patch
];
preConfigure = "substituteInPlace CMakeLists.txt --replace /lib $out/lib";
cmakeFlags = [ "-DUSE_PAM=1" ];
NIX_CFLAGS_COMPILE = "-I${freetype}/include/freetype";
NIX_CFLAGS_COMPILE = "-I${freetype}/include/freetype -std=c++11";
enableParallelBuilding = true;

View File

@ -0,0 +1,40 @@
diff -ru -x '*~' slim-1.3.6-orig/cfg.cpp slim-1.3.6/cfg.cpp
--- slim-1.3.6-orig/cfg.cpp 2013-10-02 00:38:05.000000000 +0200
+++ slim-1.3.6/cfg.cpp 2016-01-30 10:35:51.108766802 +0100
@@ -14,6 +14,7 @@
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
+#include <algorithm>
#include <sys/types.h>
#include <sys/stat.h>
@@ -293,6 +294,8 @@
sessions.clear();
+ typedef pair<string,string> session_t;
+
if( !strSessionDir.empty() ) {
DIR *pDir = opendir(strSessionDir.c_str());
@@ -325,7 +328,7 @@
}
}
desktop_file.close();
- pair<string,string> session(session_name,session_exec);
+ session_t session(session_name,session_exec);
sessions.push_back(session);
cout << session_exec << " - " << session_name << endl;
}
@@ -341,6 +344,10 @@
pair<string,string> session("","");
sessions.push_back(session);
}
+
+ std::sort(sessions.begin(), sessions.end(), [](session_t& a, session_t& b) -> bool{
+ return a.first < b.first;
+ });
}
pair<string,string> Cfg::nextSession() {