slim: improve chvt patch
authorGrazvydas Ignotas <notasas@gmail.com>
Sun, 19 Oct 2014 15:23:25 +0000 (18:23 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Sun, 19 Oct 2014 15:23:25 +0000 (18:23 +0300)
recipes/slim/slim/chvt_on_exit.patch
recipes/slim/slim_1.3.1.bb

index 1b7a35a..b32b5d0 100644 (file)
@@ -1,6 +1,6 @@
 diff -urp slim-1.3.1_/app.cpp slim-1.3.1/app.cpp
 --- slim-1.3.1_/app.cpp        2014-10-19 03:03:12.620870228 +0300
-+++ slim-1.3.1/app.cpp 2014-10-19 04:42:05.373090987 +0300
++++ slim-1.3.1/app.cpp 2014-10-19 17:52:30.237854286 +0300
 @@ -956,7 +956,7 @@ int IgnoreXIO(Display *d) {
  }
  
@@ -10,20 +10,35 @@ diff -urp slim-1.3.1_/app.cpp slim-1.3.1/app.cpp
      // Stop alars clock and ignore signals
      alarm(0);
      signal(SIGQUIT, SIG_IGN);
-@@ -1013,6 +1013,12 @@ void App::StopServer() {
+@@ -1013,6 +1013,28 @@ void App::StopServer() {
      cerr << endl;
  }
  
++#include <utmp.h>
++
 +void App::StopServer() {
++    int runlevel = 0;
++    struct utmp *ut;
++
 +    StopServerWork();
++
 +    // yet another pandora hack: switch to tty1, where user can log in
-+    system("/usr/bin/chvt 1");
++    // but only if we're not shutting down / rebooting
++    setutent();
++    while ((ut = getutent()) != NULL) {
++        if (ut->ut_type == RUN_LVL) {
++            runlevel = ut->ut_pid % 256;
++            break;
++        }
++    }
++    endutent();
++    if (1 <= runlevel && runlevel <= 5)
++        system("/usr/bin/chvt 1");
 +}
 +
  
  void App::blankScreen()
  {
-Only in slim-1.3.1_: .app.cpp.swp
 diff -urp slim-1.3.1_/app.h slim-1.3.1/app.h
 --- slim-1.3.1_/app.h  2014-10-19 03:03:12.624870228 +0300
 +++ slim-1.3.1/app.h   2014-10-19 04:41:54.873090597 +0300
index d7e2a0c..3e95d21 100644 (file)
@@ -2,7 +2,7 @@ DESCRIPTION="Simple Login Manager"
 HOMEPAGE="http://slim.berlios.de"
 LICENSE = "GPL"
 
-PR = "r8"
+PR = "r9"
 
 inherit update-rc.d