File slim-1.3.2-xsessions.patch of Package slim
diff -uNr old-slim-1.3.2//app.cpp slim-1.3.2/app.cpp
--- old-slim-1.3.2//app.cpp 2010-07-29 11:35:18.967314094 +0200
+++ slim-1.3.2/app.cpp 2010-07-29 11:35:43.965312586 +0200
@@ -369,6 +369,9 @@
LoginPanel->SetName(cfg->getOption("default_user") );
}
+ if (firstloop) {
+ LoginPanel->SwitchSession();
+ }
if (!AuthenticateUser(focuspass && firstloop)){
panelclosed = 0;
diff -uNr old-slim-1.3.2//cfg.cpp slim-1.3.2/cfg.cpp
--- old-slim-1.3.2//cfg.cpp 2010-07-29 11:35:18.960314700 +0200
+++ slim-1.3.2/cfg.cpp 2010-07-29 11:35:43.983313819 +0200
@@ -54,7 +54,6 @@
options.insert(option("authfile","/var/run/slim.auth"));
options.insert(option("shutdown_msg","The system is halting..."));
options.insert(option("reboot_msg","The system is rebooting..."));
- options.insert(option("sessions","wmaker,blackbox,icewm"));
options.insert(option("sessiondir",""));
options.insert(option("hidecursor","false"));
@@ -265,7 +264,6 @@
}
void Cfg::fillSessionList(){
- string strSessionList = getOption("sessions");
string strSessionDir = getOption("sessiondir");
sessions.clear();
@@ -282,27 +280,43 @@
strFile += pDirent->d_name;
struct stat oFileStat;
-
if (stat(strFile.c_str( ), &oFileStat) == 0){
- if (S_ISREG(oFileStat.st_mode) &&
- access(strFile.c_str(), R_OK | X_OK) == 0){
- sessions.push_back(string(pDirent->d_name));
+ if (S_ISREG(oFileStat.st_mode) &&
+ access(strFile.c_str(), R_OK) == 0){
+ ifstream desktop_file( strFile.c_str() );
+ if (desktop_file){
+ string line, session_name = "", session_exec = "";
+ while (getline( desktop_file, line )) {
+ if (line.substr(0, 5) == "Name=") {
+ session_name = line.substr(5);
+ if (!session_exec.empty())
+ break;
+ } else
+ if (line.substr(0, 5) == "Exec=") {
+ session_exec = line.substr(5);
+ if (!session_name.empty())
+ break;
+ }
+ }
+ desktop_file.close();
+ pair<string,string> session(session_name,session_exec);
+ sessions.push_back(session);
+ cout << session_exec << " - " << session_name << endl;
+ }
}
}
}
closedir(pDir);
}
- }
+ }
if (sessions.empty()){
- split(sessions, strSessionList, ',', false);
+ pair<string,string> session("","");
+ sessions.push_back(session);
}
}
-string Cfg::nextSession(string current) {
- if (sessions.size() < 1)
- return current;
-
+pair<string,string> Cfg::nextSession() {
currentSession = (currentSession + 1) % sessions.size();
return sessions[currentSession];
}
diff -uNr old-slim-1.3.2//cfg.h slim-1.3.2/cfg.h
--- old-slim-1.3.2//cfg.h 2010-07-29 11:35:18.966313411 +0200
+++ slim-1.3.2/cfg.h 2010-07-29 11:35:43.984313523 +0200
@@ -39,14 +39,14 @@
char c, bool useEmpty=true);
static std::string Trim(const std::string& s);
- std::string nextSession(std::string current);
+ std::pair<std::string,std::string> nextSession();
private:
void fillSessionList();
private:
std::map<std::string,std::string> options;
- std::vector<std::string> sessions;
+ std::vector<std::pair<std::string,std::string> > sessions;
int currentSession;
std::string error;
diff -uNr old-slim-1.3.2//panel.cpp slim-1.3.2/panel.cpp
--- old-slim-1.3.2//panel.cpp 2010-07-29 11:35:18.967314094 +0200
+++ slim-1.3.2/panel.cpp 2010-07-29 11:35:44.002313010 +0200
@@ -22,7 +22,8 @@
Root = root;
cfg = config;
- session = "";
+ session_name = "";
+ session_exec = "";
// Init GC
XGCValues gcv;
@@ -187,7 +188,8 @@
}
void Panel::ClearPanel() {
- session = "";
+ session_name = "";
+ session_exec = "";
Reset();
XClearWindow(Dpy, Root);
XClearWindow(Dpy, Win);
@@ -559,13 +561,15 @@
}
string Panel::getSession() {
- return session;
+ return session_exec;
}
// choose next available session type
void Panel::SwitchSession() {
- session = cfg->nextSession(session);
- if (session.size() > 0) {
+ pair<string,string> ses = cfg->nextSession();
+ session_name = ses.first;
+ session_exec = ses.second;
+ if (session_name.size() > 0) {
ShowSession();
}
}
@@ -574,7 +578,7 @@
void Panel::ShowSession() {
string msg_x, msg_y;
XClearWindow(Dpy, Root);
- string currsession = cfg->getOption("session_msg") + " " + session;
+ string currsession = cfg->getOption("session_msg") + " " + session_name;
XGlyphInfo extents;
sessionfont = XftFontOpenName(Dpy, Scr, cfg->getOption("session_font").c_str());
diff -uNr old-slim-1.3.2//panel.h slim-1.3.2/panel.h
--- old-slim-1.3.2//panel.h 2010-07-29 11:35:18.961314054 +0200
+++ slim-1.3.2/panel.h 2010-07-29 11:35:44.003314599 +0200
@@ -66,6 +66,7 @@
void SetName(const std::string& name);
const std::string& GetName(void) const;
const std::string& GetPasswd(void) const;
+ void SwitchSession();
private:
Panel();
void Cursor(int visible);
@@ -73,7 +74,6 @@
void OnExpose(void);
bool OnKeyPress(XEvent& event);
void ShowText();
- void SwitchSession();
void ShowSession();
void SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font,
@@ -150,7 +150,8 @@
std::string themedir;
// Session handling
- std::string session;
+ std::string session_name;
+ std::string session_exec;
};