You are not logged in.

#1 2013-11-24 11:49:10

Arakis
Member
From: Hamminkeln - Germany
Registered: 2013-08-11
Posts: 46
Website

One time automatic login and startx per boot

Hello,
my gloal is:
- on every boot, automatic login and start x
- only one time automatic login, and one time startx per boot
- when exiting x, normal command prompt should be visible (like manual login wihtout startx in .zprofile (via zsh))
- when exiting zsh prompt, normal, manual login should be shown.

I'm not using a graphical login manager.

I've succsessfull setup a automatic login via systemd ( https://wiki.archlinux.org/index.php/au … al_console ), and startx (via .zprofil (i'm using zsh instead of bash).
But: startx respawns everytime, when i logout from x. Maybe i could make a "trick" via "touch /tmp/exec-startx" with another systemd-service and an file exist-check in .zprofile. But the automatic-login will still enabled. And when "stopping" the custom service, tty1 will be blank with an blinking cursor.

Edit:
I've created now an AUR-Package that do all the stuff:
https://aur.archlinux.org/packages/autologin-on-boot/
If you have any suggestions to the package, please let me know.

Greetings from Germany,
Sebastian

Last edited by Arakis (2013-12-15 04:13:38)

Offline

#2 2013-11-24 14:22:25

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: One time automatic login and startx per boot

Have you tried starting X automatically?
Try using https://wiki.archlinux.org/index.php/Start_X_at_Login

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx

in your .zprofile.

Offline

#3 2013-11-24 15:37:08

sano
Member
Registered: 2012-02-11
Posts: 114

Re: One time automatic login and startx per boot

I think the OP wants something else: Start X automatically on boot, do GUI stuff, log out, do TTY stuff. With the instructions you linked he will find himself in his DE/WM again after logout.
I had the same problem, my  "workaround" is not using autostart but to manually start X every time.

Offline

#4 2013-11-24 16:04:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: One time automatic login and startx per boot

Note the difference between the wiki and karol's recommendation: remove the "exec" and you will not be logged out.

This is *half* of what the OP is looking for.  The other half is having the autologin to tty only run once.  There is a parameter in the service file for this - though I don't remember off the top of my head what it is as I haven't used in it a while.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2013-11-24 16:21:45

Arakis
Member
From: Hamminkeln - Germany
Registered: 2013-08-11
Posts: 46
Website

Re: One time automatic login and startx per boot

Hello guys,
i've found an working way. It would be interesting to know, if there is an more cleaner way.

nano /etc/systemd/system/onetimelogin.service

[Unit]
Description=Prepare one time login

[Service]
Type=oneshot
ExecStart=-/bin/touch /tmp/autologin
ExecStart=-/bin/chown sebastian:users /tmp/autologin

[Install]
WantedBy=basic.target

systemctl enable onetimelogin.service

nano /etc/systemd/system/getty@tty1.service.d/autologin.conf

[Service]
ExecStart=
ExecStart=-/bin/autologin.sh %I

nano /bin/autologin.sh

#!/bin/sh

if [ -f /tmp/autologin ]
then
        exec /sbin/agetty --autologin sebastian --noclear $1
else
        exec /sbin/agetty --noclear $1
fi

chmod +x /bin/autologin.sh

nano ~/.zprofile

if [ -f /tmp/autologin ]
then
        rm /tmp/autologin
        startx
fi

What is does: "before" getty-service will starte, an "marker" file (tmp/autologin) will be created (with the service onetimelogin.service), so the system knows now, its just booted.
When getty@tty1 will started, it's using /bin/autologin.sh instead of agetty. In autologin.sh, i start agetty with autologin, when /tmp/autologin exists, otherwise normal login.

In the .zprofile i check, too, if the /tmp/autologin exists. If so, i remove it (so autologin is disabled), and execute startx.

Short question: What makes [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx instead of only startx ?

Greetings from Germany,
Sebastian

Last edited by Arakis (2013-11-24 16:26:42)

Offline

#6 2013-11-24 16:26:43

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,646

Re: One time automatic login and startx per boot

Arakis wrote:

Short question: What makes [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx instead of only startx ?

This starts X only if it is not already started ($DISPLAY is not set), and only if you are using tty1 ($XDG_VTNR = 1). If you just use "startx" in your .zprofile, it will try to start X every time you start a new zsh shell, even if X is already running. The "only on tty1" part means that if you switch to tty2 and log in, X will not start automatically.

Last edited by 2ManyDogs (2013-11-24 16:28:38)

Offline

#7 2013-11-24 16:39:14

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: One time automatic login and startx per boot

Trilby wrote:

Note the difference between the wiki and karol's recommendation: remove the "exec" and you will not be logged out.

Maybe I should have been more explicit about this, but the wiki article I linked to does say

If you would like to remain logged in when the X session ends, remove exec.

in the 'Tips and tricks' section.

Offline

#8 2013-11-24 16:56:05

jouke
Member
Registered: 2009-10-14
Posts: 72

Re: One time automatic login and startx per boot

Warning: shameless promotion of my own software.

I think you can do exactly what you want with xlogin. My latest installation instructions detail a fully systemd integrated installation. The end result will be a very clean automatic-login configuration.

Offline

#9 2013-11-24 17:14:37

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: One time automatic login and startx per boot

2ManyDogs wrote:
Arakis wrote:

Short question: What makes [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx instead of only startx ?

This starts X only if it is not already started ($DISPLAY is not set), and only if you are using tty1 ($XDG_VTNR = 1). If you just use "startx" in your .zprofile, it will try to start X every time you start a new zsh shell, even if X is already running.

Clarification: .zprofile is only read for a login shell, not for every interactive shell (as is the case with .zshrc).


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#10 2013-11-24 17:26:43

sano
Member
Registered: 2012-02-11
Posts: 114

Re: One time automatic login and startx per boot

karol wrote:

...
Maybe I should have been more explicit about this, but the wiki article I linked to does say
...

I didn't read your post carefully enough, sorry. And neither the wiki, it seems.

Anyway, thank you for your help, it was exactly what I was looking for.

Offline

#11 2013-12-15 04:21:25

Arakis
Member
From: Hamminkeln - Germany
Registered: 2013-08-11
Posts: 46
Website

Re: One time automatic login and startx per boot

I have created now an AUR-Package that do all the stuff:
https://aur.archlinux.org/packages/autologin-on-boot/
If you have any suggestions to the package, please let me know.

It does the following:
Autologin once per boot and starts X. When you quit X and/or logoout, no relogin will be there and no auto-restart of X. If you reboot, you will be logged in again.
If you wish to start another app like "startx", simply modify the file /usr/share/autologin-on-boot/profile . Ok, /etc/autologin-on-boot.conf would be the bettr file, but i have no experience with parsing files with bash.

Short question: How to create a man-page file and how to contribute them wie makepkg or Makefile?

Greetings,
Sebastian

Offline

Board footer

Powered by FluxBB