Advertisement
Guest User

uxlaunch fallback tty patch

a guest
Oct 21st, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.65 KB | None | 0 0
  1. --- a/options.c
  2. +++ b/options.c
  3. @@ -25,6 +25,7 @@
  4.  
  5.  /* builtin defaults */
  6.  int tty = 1;
  7. +int fallback = 1;
  8.  char session[256] = "/usr/bin/mutter --sm-disable";
  9.  char username[256] = "meego";
  10.  char dpinum[256] = "120";
  11. @@ -36,6 +37,7 @@ int x_session_only = 0;
  12.  static struct option opts[] = {
  13.     { "user",     1, NULL, 'u' },
  14.     { "tty",      1, NULL, 't' },
  15. +   { "fallback", 1, NULL, 'f' },
  16.     { "session",  1, NULL, 's' },
  17.     { "xsession", 0, NULL, 'x' },
  18.     { "help",     0, NULL, 'h' },
  19. @@ -49,6 +51,7 @@ void usage(const char *name)
  20.     printf("Usage: %s [OPTION...] [-- [session cmd] [session args]]\n", name);
  21.     printf("  -u, --user      Start session as specific username\n");
  22.     printf("  -t, --tty       Start session on alternative tty number\n");
  23. +   printf("  -f, --fallback  Revert to alternative tty number on session end\n");
  24.     printf("  -s, --session   Start a non-default session\n");
  25.     printf("  -x, --xsession  Start X apps inside an existing X session\n");
  26.     printf("  -v, --verbose   Display lots of output to the console\n");
  27. @@ -129,6 +132,8 @@ void get_options(int argc, char **argv)
  28.                 strncpy(username, val, 256);
  29.             if (!strcmp(key, "tty"))
  30.                 tty = atoi(val);
  31. +           if (!strcmp(key, "fallback"))
  32. +               fallback = atoi(val);
  33.             if (!strcmp(key, "session"))
  34.                 strncpy(session, val, 256);
  35.             if (!strcmp(key, "dpi"))
  36. @@ -153,6 +158,9 @@ void get_options(int argc, char **argv)
  37.         case 't':
  38.             tty = atoi(optarg);
  39.             break;
  40. +       case 'f':
  41. +           fallback = atoi(optarg);
  42. +           break;
  43.         case 's':
  44.             strncpy(session, optarg, 256);
  45.             break;
  46. @@ -188,7 +196,7 @@ void get_options(int argc, char **argv)
  47.     open_log(!x_session_only ? LOGFILE : NULL);
  48.  
  49.     lprintf("uxlaunch v%s started%s.", VERSION, x_session_only ? " for x session only" : "" );
  50. -   lprintf("user \"%s\", tty #%d, session \"%s\"", username, tty, session);
  51. +   lprintf("user \"%s\", tty #%d, fallback #%d, session \"%s\"", username, tty, fallback, session);
  52.  
  53.     pass = getpwnam(username);
  54.     if (!pass) {
  55. diff -rupN a/uxlaunch.c b/uxlaunch.c
  56. --- a/uxlaunch.c
  57. +++ b/uxlaunch.c
  58. @@ -98,7 +98,7 @@ int main(int argc, char **argv)
  59.  
  60.     setup_efs();
  61.  
  62. -   set_tty();
  63. +   set_tty(tty);
  64.  
  65.     start_oom_task();
  66.  
  67. diff -rupN a/uxlaunch.h b/uxlaunch.h
  68. --- a/uxlaunch.h
  69. +++ b/uxlaunch.h
  70. @@ -18,6 +18,7 @@ extern Xauth x_auth;
  71.  extern char user_xauth_path[];
  72.  
  73.  extern int tty;
  74. +extern int fallback;
  75.  extern char session[];
  76.  extern char username[];
  77.  extern char dpinum[];
  78. @@ -35,7 +36,7 @@ extern void setup_pam_session(void);
  79.  extern void close_pam_session(void);
  80.  extern void switch_to_user(void);
  81.  extern void setup_user_environment(void);
  82. -extern void set_tty(void);
  83. +extern void set_tty(int);
  84.  extern void setup_xauth(void);
  85.  extern void start_X_server(void);
  86.  extern void wait_for_X_signal(void);
  87. diff -rupN a/xserver.c b/xserver.c
  88. --- a/xserver.c
  89. +++ b/xserver.c
  90. @@ -56,7 +56,7 @@ static volatile int exiting = 0;
  91.   * TIOCLINUX will tell us which console is currently showing
  92.   * for this purpose.
  93.   */
  94. -void set_tty(void)
  95. +void set_tty(int newtty)
  96.  {
  97.     int fd;
  98.     struct vt_stat v;
  99. @@ -76,13 +76,13 @@ void set_tty(void)
  100.         return;
  101.     }
  102.  
  103. -   if (v.v_active != tty) {
  104. -       if (ioctl(fd, VT_ACTIVATE, tty))
  105. +   if (v.v_active != newtty) {
  106. +       if (ioctl(fd, VT_ACTIVATE, newtty))
  107.             lprintf("VT_ACTIVATE failed");
  108.     }
  109.     close(fd);
  110.  
  111. -   snprintf(displaydev, PATH_MAX, "/dev/tty%d", tty);
  112. +   snprintf(displaydev, PATH_MAX, "/dev/tty%d", newtty);
  113.  
  114.     lprintf("Using %s as display device", displaydev);
  115.  }
  116. @@ -409,6 +409,8 @@ void wait_for_X_exit(void)
  117.  
  118.  void set_text_mode(void)
  119.  {
  120. +   set_tty(fallback);
  121. +
  122.     int fd;
  123.  
  124.     lprintf("Setting console mode to KD_TEXT");
  125.  
  126.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement