summarylogtreecommitdiffstats
path: root/slim-session-sort.patch
blob: 8eab1d20c51896c1a6aacdcad2137f8fc6cc49c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
diff -upr slim-1.3.6-orig/cfg.cpp slim-1.3.6/cfg.cpp
--- slim-1.3.6-orig/cfg.cpp	2013-10-01 23:38:05.000000000 +0100
+++ slim-1.3.6/cfg.cpp	2021-08-31 16:50:18.415225394 +0100
@@ -14,12 +14,14 @@
 #include <iostream>
 #include <unistd.h>
 #include <stdlib.h>
+#include <algorithm>
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
 
 #include "cfg.h"
+#include "log.h"
 
 using namespace std;
 
@@ -298,6 +300,7 @@ void Cfg::fillSessionList(){
 
 		if (pDir != NULL) {
 			struct dirent *pDirent = NULL;
+			std::vector<std::tuple<string,string,string> > tmp;
 
 			while ((pDirent = readdir(pDir)) != NULL) {
 				string strFile(strSessionDir);
@@ -325,15 +328,19 @@ void Cfg::fillSessionList(){
                                      }
                              }
                              desktop_file.close();
-                             pair<string,string> session(session_name,session_exec);
-                             sessions.push_back(session);
-                             cout << session_exec << " - " << session_name << endl;
+							  std::tuple<string,string,string> session(pDirent->d_name,session_name,session_exec);
+                             tmp.push_back(session);
                         }
 
 					}
 				}
 			}
 			closedir(pDir);
+			std::sort(tmp.begin(), tmp.end());
+			for(int i=0;i<tmp.size();i++) {
+				std::pair <string,string> p (std::get<1>(tmp[i]),std::get<2>(tmp[i]));
+				sessions.push_back(p);
+			}
 		}
 	}