You are not logged in.

#1 2011-03-27 15:43:17

xiaq
Member
From: somewhere in China...
Registered: 2011-03-06
Posts: 89

[Solved] Offer a choice to spawn gdm at getty?

Due to numerous bugs (most of which related to permission), I have decided that the only sensible way to log into my XFCE desktop is through gdm. Running "startxfce4" with magic prefixes like dbus-launch, ck-launch, etc. won't help, neither will startx with .xinintrc.

But sometimes I need to spawn a desktop session when I have been working under the console. I may wish to switch back and forth. So now what I have to do is: Ctrl-Alt-F2, type my password, sudo gdm, and type my password again. But hey, why can't we just spawn gdm at getty? That will save me from typing my password twice. There is also one more benefit: I have followed https://wiki.archlinux.org/index.php/Di … tab_method, and now I have two grub items. With the choice to spawn gdm at getty I can get rid of the one with X.

Last edited by xiaq (2011-03-28 07:31:24)

Offline

#2 2011-03-27 15:54:02

PIMPinator
Member
From: Queensland, Australia
Registered: 2010-03-14
Posts: 85

Re: [Solved] Offer a choice to spawn gdm at getty?

I'm not totally sure what you want to achieve. Do you want gdm to automatically start when you swap to tty2?

Offline

#3 2011-03-27 16:01:20

xiaq
Member
From: somewhere in China...
Registered: 2011-03-06
Posts: 89

Re: [Solved] Offer a choice to spawn gdm at getty?

PIMPinator wrote:

I'm not totally sure what you want to achieve. Do you want gdm to automatically start when you swap to tty2?

What I want is when getty asks me username:

login:

I may press some key (say F1) and then gdm will be started.

Offline

#4 2011-03-27 18:26:59

milomouse
Member
Registered: 2009-03-24
Posts: 940
Website

Re: [Solved] Offer a choice to spawn gdm at getty?

not sure if they'll work in your situation but you may or may not want:
1) bind F1 in console to execute GDM (check the Arch Wiki for: Extra Keyboard Keys in Console)
2) ngetty instead of agetty/similar.  ngetty allows you to execute programs per getty (tty instance) before login or after login, though i'm not certain if it will work for GDM.

some ideas, anyway, as i cannot test since i don't use gdm or similar.

Last edited by milomouse (2011-03-27 18:28:09)

Offline

#5 2011-03-28 03:31:12

xiaq
Member
From: somewhere in China...
Registered: 2011-03-06
Posts: 89

Re: [Solved] Offer a choice to spawn gdm at getty?

milomouse wrote:

not sure if they'll work in your situation but you may or may not want:
1) bind F1 in console to execute GDM (check the Arch Wiki for: Extra Keyboard Keys in Console)
2) ngetty instead of agetty/similar.  ngetty allows you to execute programs per getty (tty instance) before login or after login, though i'm not certain if it will work for GDM.

some ideas, anyway, as i cannot test since i don't use gdm or similar.

Inspired by the idea of using ngetty, I (instead) wrote small C program called mylogin.c:

#include <stdio.h>
#include <unistd.h>
#include <string.h>

int main() {
    fprintf(stderr, "This should go to stderr.\n");
    printf("Welcome to mylogin.\n"
            " - Type your username and enter to invoke vanilla login.\n"
            " - Press enter without username to launch gdm.\n"
            "login: ");
    char user[256];
    if (fgets(user, 256, stdin) == NULL) {
        // EOF
        return 0;
    }
    if (strlen(user) == 1) {
        printf("Executing gdm.\n");
        execl("/usr/sbin/gdm", "/usr/sbin/gdm", NULL);
    } else {
        user[strlen(user)-1] = '\0';
        printf("Executing login for user %s.\n", user);
        execl("/bin/login", "--", user, NULL);
    }
    printf("execl failed :(");
    return 1;
}

Compiled and installed it:

cc -omylogin mylogin.c && sudo cp mylogin /bin

(I will stick to agetty in my instruction to keep things simple) and in /etc/inittab I changed

c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux

to

c6:2345:respawn:/sbin/agetty -n -l /bin/mylogin -8 38400 tty6 linux

And when I switch to tty6, I'm offered the choice to invoke vanilla login or gdm. mylogin does the trick.

But there is still an interesting problem. If I switched to tty6 and launch gdm there, I would expect the output of gdm to be printed there. But there is no output from gdm. And I was able to confirm that both stdout and stderr go to tty6 with the above program. Is gdm redirecting the output? If so, where?

To milomouse: I will switch to ngetty, as I see it as a better replacement for agetty on all sides (I don't use serial terminal anyway). But as I said above, I sticked to agetty here to keep things simple.

Offline

#6 2011-03-28 07:30:10

xiaq
Member
From: somewhere in China...
Registered: 2011-03-06
Posts: 89

Re: [Solved] Offer a choice to spawn gdm at getty?

Update about the output redirection:
My bad, sorry. gdm is always redirecting its children's stdout and stderr to ~/.xsession-errors; even if I run sudo gdb under some console I get this behavior. I would get a lot of output only when I start XFCE by startx or startxfce4. Now my problem is fully resolved by using a customized login program.

Last edited by xiaq (2011-03-28 07:32:16)

Offline

Board footer

Powered by FluxBB