Browse Source

Added session start/stop commands

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@90 7c53e7cc-98ea-0310-8f1f-a0b24da60408
sip 18 years ago
parent
commit
9346c5a251
5 changed files with 27 additions and 2 deletions
  1. 2 0
      ChangeLog
  2. 12 1
      app.cpp
  3. 2 0
      cfg.cpp
  4. 3 1
      const.h
  5. 8 0
      slim.conf

+ 2 - 0
ChangeLog

@@ -1,4 +1,6 @@
 1.2.4 - work in progress
+    * Added commands for session start and stop
+      (i.e. for session registering)
 
 
 1.2.3 - 2005.09.11

+ 12 - 1
app.cpp

@@ -311,9 +311,14 @@ void App::Login() {
         // Login process starts here
         SwitchUser Su(pw, &cfg, DisplayName);
         string session = LoginPanel->getSession();
-	string loginCommand = cfg.getOption("login_cmd");
+        string loginCommand = cfg.getOption("login_cmd");
         replaceVariables(loginCommand, SESSION_VAR, session);
         replaceVariables(loginCommand, THEME_VAR, themeName);
+        string sessStart = cfg.getOption("sessionstart_cmd");
+        if (sessStart != "") {
+            replaceVariables(sessStart, USER_VAR, pw->pw_name);
+            system(sessStart.c_str());
+        }
         Su.Login(loginCommand.c_str());
         exit(OK_EXIT);
     }
@@ -330,6 +335,12 @@ void App::Login() {
     }
     if (WIFEXITED(status) && WEXITSTATUS(status)) {
         LoginPanel->Message("Failed to execute login command");
+    } else {
+         string sessStop = cfg.getOption("sessionstop_cmd");
+         if (sessStop != "") {
+            replaceVariables(sessStop, USER_VAR, pw->pw_name);
+            system(sessStop.c_str());
+        }
     }
 
     // Close all clients

+ 2 - 0
cfg.cpp

@@ -28,6 +28,8 @@ Cfg::Cfg() {
     options.insert(option("halt_cmd","/sbin/shutdown -h now"));
     options.insert(option("reboot_cmd","/sbin/shutdown -r now"));
     options.insert(option("suspend_cmd",""));
+    options.insert(option("sessionstart_cmd",""));
+    options.insert(option("sessionstop_cmd",""));
     options.insert(option("console_cmd","/usr/X11R6/bin/xterm -C -fg white -bg black +sb -g %dx%d+%d+%d -fn %dx%d -T ""Console login"" -e /bin/sh -c ""/bin/cat /etc/issue; exec /bin/login"""));
     options.insert(option("screenshot_cmd","import -window root /login.app.png"));
     options.insert(option("welcome_msg","Welcome to %host"));

+ 3 - 1
const.h

@@ -48,5 +48,7 @@
 #define SESSION_VAR     "%session"
 #define THEME_VAR       "%theme"
 
-#endif
+// variables replaced in pre-session_cmd and post-session_cmd
+#define USER_VAR       "%user"
 
+#endif

+ 8 - 0
slim.conf

@@ -20,6 +20,14 @@ console_cmd         /usr/X11R6/bin/xterm -C -fg white -bg black +sb -T "Console
 # login_cmd           exec /bin/sh - ~/.xinitrc %session
 login_cmd           exec /bin/bash -login ~/.xinitrc %session
 
+# Commands executed when starting and exiting a session.
+# They can be used for registering a X11 session with
+# sessreg. You can use the %user variable
+
+# sessionstart_cmd	some command
+# sessionstop_cmd	some command
+
+
 # Available sessions (first one is the default).
 # The current chosen session name is replaced in the login_cmd
 # above, so your login command can handle different sessions.