[THE 1st TIME] Our own login manager

Forum rules
Share your brain ;)
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

[THE 1st TIME] Our own login manager

Unread post by machinebacon » Mon Feb 24, 2014 3:47 pm

Too many WMs installed and tired of editing the .xinitrc every time you want to switch? Users of recent (2014) BBQ releases can imply this neat method to have a login manager after boot.

1) The /usr/local/bin/bbqlogin file, it looks like this (sample!)

Code: Select all

#!/usr/bin/env bash

# A simple dialog to start sessions via starter scripts

# put the release name here
RELEASE_NAME=Roasted

# create temporary file
INPUT=/tmp/menu.sh.$$

# main function: the menu
function mainmenu(){
	dialog --backtitle "LinuxBBQ $RELEASE_NAME" --nocancel --title "Select your session" --menu " " 0 0 0 \
	c "Change color scheme" \
	o "Openbox session" \
	3 "i3 session" \
	x "Emacs session" \
	v "VIM session" \
	m "tmux session" \
	h "bash prompt" \
	b "BBQ Terminal Menu" \
	s "Set up network" \
	l "Radio" \
	f "Start Framebuffer session"  \
	y "Edit startup" \
	e "Edit this menu" \
	9 "Reboot" \
	0 "Poweroff"  2>"${INPUT}"
menuitem=$(<"${INPUT}")

# if X is pressed Y will be executed
case $menuitem in
        o) exec xinit /usr/local/bin/openbox-start;;
	3) exec xinit /usr/local/bin/i3-start;;
	c) fbcolors;;
	h) bash ;;
	x) emacs ;;
	v) vim;;
	e) nano /usr/local/bin/bbqlogin ;;
	y) nano /usr/bin/start-wm ;;
	s) sudo ceni;;
	l) bbqradio;;
	m) tmux;;
	b) bbq;;
	f) fb;;
	0) sudo /sbin/poweroff;;
	9) sudo /sbin/reboot;;
	esac
}

# remove temporary file
[ -f $INPUT ] && rm $INPUT

mainmenu
save and exit, and make it accessible and executable:

Code: Select all

sudo chmod a+x /usr/local/bin/bbqlogin
You can additionally make it writable for all:

Code: Select all

sudo chmod 777 /usr/local/bin/bbqlogin
2) The /usr/local/bin/openbox-start file looks like this:

Code: Select all

#!/bin/bash
/usr/bin/start-wm /usr/bin/openbox-session
save, exit, and chmod a+x over it. Now make a variant for /usr/local/bin/i3-start

Code: Select all

#!/bin/bash
/usr/bin/start-wm /usr/bin/i3
Create as many <wm>-start scripts as you have window managers installed. Don't forget to make the <wm>-start scripts executable!

TIP: Use the "whereis" command to find the exact path to your window manager ;)

3) We need a replacement for .xinitrc, called /usr/bin/start-wm - it might look like this, edit to your needs!

Code: Select all

#!/bin/bash
# This is a sample .xinitrc file (to be executed with xinit or startx)

# source the Xresources for the terminal
xrdb -merge ~/.Xresources &

# Ctrl-Alt-Backspace kills the X session
setxkbmap -option terminate:ctrl_alt_bksp

# sets your keyboard to 'us' keymap
setxkbmap us &

# read Xmodmap file - please edit it first
#xmodmap ~/.Xmodmap &

# call /usr/include/ulimit.h
ulimit -c unlimited &

# helpful to have keycombos set - see also ~/.xbindkeysrc
xbindkeys -f ~/.xbindkeysrc &

# set a solid background
xsetroot -solid "#1a1a1a" &

# make the cursor point in the 'right' direction
xsetroot -cursor_name left_ptr &

# set a wallpaper
hsetroot -tile /usr/share/wallpapers/1.png &

# this makes dual heads work better
#vgascript &

# got time?
#sleep 2s && osd_clock -f  -*-terminus-*-*-*-*-12-*-*-*-*-*-*- -c brown -s 0 -r -t -o -8 &

# candy
#compton -bcCGf -i 0.8 -e 0.8 --no-fading-openclose &

# nice tty-clock
#sleep 3s && x-terminal-emulator -geometry 37x9-50+50 -e tty-clock & 

# authoring terminal ready -> change 'tmux' to your preferred writing tool
# we give it enough sleep so that Xresources can be sourced, the wallpaper painted
# and compton fully activated before opening the terminals windows.
#sleep 4s && x-terminal-emulator -geometry 100x42+50+50 -e tmux &
#sleep 4s && x-terminal-emulator -geometry 37x30-50+206 -e hnb &
#sleep 4s && x-terminal-emulator -geometry 37x8-50-10 -e bbqalarm &
#sleep 4s && x-terminal-emulator -geometry 100x8+50-10 &

# execute session:
# if you have consolekit and dbus running:
#exec ck-launch-session dbus-launch --exit-with-session $1

# else something like:
exec $1
Please really edit it! save it, and make it executable:

Code: Select all

sudo a+x /usr/bin/start-wm

Code: Select all

sudo chmod 777 /usr/bin/start-wm
NOW TEST IF THE SCRIPTS WORK! Exit your X session, fall back to a normal login shell, and run "bbqlogin". Test all entries. If something fails, stop here and check for typos or ask us. Do not continue with step 4) if things don't work 100% perfect.

4) Optional: bbqlogin as login/display manager. Edit the .bash_profile file to look like this

Code: Select all

if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

. "$HOME/.bashrc"

[[ -z $DISPLAY && $TERM = "linux" ]] && exec bbqlogin
Save and exit as normal user, not as root!

Now log out ("exit") and you will be greeted with this neat little dialog ;)
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: [THE 1st TIME] Our own login manager

Unread post by GekkoP » Mon Feb 24, 2014 3:53 pm

Using it on Chicken Wings. A really great add to the spins imho.

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by catfood » Mon Oct 10, 2016 10:12 pm

Perfect! Thanks Bacon!
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by wuxmedia » Tue Oct 11, 2016 8:47 am

^
thanks Bacon
save time now and get this line saved as a macro or something. :)
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by catfood » Thu Oct 13, 2016 2:41 am

I prefer the hand typed thanks to the cut & paste. Allows variable inputs && outputs as required per session ;)

Ive seem a few code >:D< 's here

I~~I
I ID
I__I. Here is a beer stein of gratitude.
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by wuxmedia » Thu Oct 13, 2016 6:48 am

oh thank you another ASCII lover:)
yeah sure hand typed is good, it's just you'll end up saying that phrase a lot :)
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by catfood » Sun Oct 23, 2016 8:13 pm

Dumb quesiton, but am I supposed to have a /usr/local/bin/openbox-start file already or is that always manually created? Trying to backup a stock version of every file elsewhere before I change anything.

Running Break. Wasn't sure if it would have an openbox-start by default or some other auto-start I need to hashout during this process...?
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by machinebacon » Mon Oct 24, 2016 5:59 am

^ not a dumb question. Every window manager you want needs its own start file, for example

Code: Select all

#!/bin/bash
/usr/bin/start-wm /usr/bin/openbox-session
or for spectrwm

Code: Select all

#!/bin/bash
/usr/bin/start-wm /usr/bin/spectrwm
So you definitely need the following files:
/usr/local/bin/bbqlogin as main login manager
/usr/local/bin/openbox-start (in your case) for starting openbox using our login manager, as stated a few lines above in this post
/usr/bin/start-wm that replaces the autostart sequence of ~/.xinitrc if bbqlogin is used
/usr/bin/openbox-session generally for starting openbox-session, this one is existing

Every additional window manager you want to start with bbqlogin needs /usr/local/bin/WINDOWMANAGER-start and of course the window manager itself (use "whereis WINDOWMANAGER" to find its exact path)
..gnutella..

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by catfood » Sun Oct 30, 2016 9:17 pm

Also, am I moving default .xinitrc somewhere else and leaving start-wm in it's place?

Or do you change a line in another startup script to refer to start-wm now instead of .xinitrc?

or does the system just automatically take start-wm as priority?
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by machinebacon » Mon Oct 31, 2016 4:39 am

No, just keep everything where it is.

Usually, you would use "startx" to start X (duh) which reads ~/.xinitrc by default, and this file runs "exec WINDOW_MANAGER" eventually.
In our case, "bbqlogin" starts the selected WINDOW_MANAGER-start which 1) is a replacement for xinitrc and 2) starts start-wm.

The system will take ~/.xinitrc as priority if you use "startx" to start X
The system will take start-wm as priority if you use "bbqlogin" or "WINDOW_MANAGER-start"
..gnutella..

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by catfood » Wed Nov 16, 2016 2:53 am

I made typo's in bbqlogin.
Thanks bacon for finding them.

Code: Select all

#Updated bbqlogin nano reposted shortly
#This post trimmed down to save space
Last edited by catfood on Wed Nov 16, 2016 11:39 pm, edited 1 time in total.
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by machinebacon » Wed Nov 16, 2016 5:08 am

Seriously, just check your script carefully. There's a pattern, and in one line the pattern does not occur. Hint: it's in the second part of the script. Extra hint: it has to do with the missing semicolons in jwm's entry.

it throws an error for the "bash" line because ... the problem occurs in the line before and breaks the "bash" line.

(By the way, your windowmanager-start scripts in the menu are put all over the place (/usr/bin/ and /usr/local/bin), no idea if you want it that way or if you are not aware that /usr/bin/ and /usr/local/bin/ are completely different places. just a heads up to prevent another headache)
..gnutella..

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by wuxmedia » Wed Nov 16, 2016 8:34 am

I had to look up '#!/usr/bin/env bash' line, turns out it just runs 'bash' in one's current env...
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by catfood » Wed Nov 16, 2016 10:31 pm

Ok, trying to test bbqlogin, I realize I can't seem to kill x-sessions...

ctrl-alt-bksp is in my .xinitrc as killx, but doesn't work.
sudo killall x, stop, stop service, etc don't seem to work either. Most say
"x: no processes found"
All google searches seem to report these same "solutions" which don't seem to work here.

Ctrl-alt-F2, switch to new console, tried testing bbqlogin anyways, but as expected, yes, X is still running.

I commented out all my exec WM files in .xinitrc, hoping it would just load into tmux, but it just gets stuck in a blinky loop til I pull the battery. Had to go back in as root and uncomment 1 to get my user to run at all.
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by machinebacon » Thu Nov 17, 2016 3:17 am

0) yes, there are WMs that don't allow Ctrl-Alt-Backspc
1) it's X, not x.
2) "pkill -9 X" should work
3) window managers usually have a 'quit' function, see manpage.
4) if not, you can always try "pkill -9 <window-manager-name>"
5) or you run sxhkd and assign it a "pkill -9 X" for a certain keybinding.
6) tmux in TTY1 is problematic [1], and as login shell it requires an extra step [2] that I would not recommend[3]. Please simply skip the tmux experiment for now and revisit later. Stay with "bash".

[1] https://www.raspberrypi.org/forums/view ... 91&t=23129
[2] either chsh
[3] or login via inittab
..gnutella..

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by catfood » Fri Nov 18, 2016 3:17 am

Yea, I had tried logout, quit from terminal. Both of those say "use exit"
Type exit and it just closes that terminal only.
I tried all of those things yesterday on 2wm and openbox (assuming maybe 2wm's shortcuts overrided Ctrl+Alt+Bksp but they might still work in openbox? nope)

pkill -9 X, pkill -9 X, or 2wm's Quit shortcut (Alt+Shift+Q) today, or openbox exit yesterday("exit"):
Close all currently open windows, then immediately reload background. (If I try terminal open shortcut it also immediately works as if nothing was ever really stopped)
Tried the following with and without touching anything after kill WM

Ctrl+Alt+F1 or F2 to switch console after any kill method, then try bbqlogin:
Choose any WM option from menu:

Code: Select all

(EE)
Fatal server error:
(EE) Server is already active for display 0
        If This server is no longer running, remove /tmp/ .X0-lock
        and start again. 
(EE)
(EE)
Please consult the The X.Org Foundation support
         at http://wiki.x.org
for help.
(EE)
break@grill:~$ XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 7 requests (7 known processed) with 0 events remaining.
Was searching on http://wiki.x.org yesterday, but found nothing I hadn't already been told to try.
1 or 2 of the kill processes I tried yesterday gave these same results when I ran bbqlogin. Most of them did nothing. A couple did the same as the new ones today.

Just confusing. Like X-session is on auto-reanimate or something, lol.

Tmux did work from the menu ironically, but only like one out of 5 times, so was thinking of ditching anyways. Failed times gave random results. A pseudo glitchtxt bar on the bottom or:

Code: Select all

(1) sessions should be nested with care, unset $TMUX to force
(2) /home/break/ .tmux.conf:20: unkown option: status-utf8
(3) other random weirdness
Menu edit's, FBColor, Reboot, and Poweroff all worked from the bbqlogin menu too. Just haven't been able to test any of the WM's yet due to the above (EE) error no matter what I try.
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: [THE 1st TIME] Our own login manager

Unread post by franksinistra » Fri Nov 18, 2016 4:18 am

just try

Code: Select all

pkill X 

or

Code: Select all

pkill -15 X
and you should be out in the TTY again. so you can bbqlogin again or whatever.

tmux config needs to be updated, read the manual. That option (status-utf8) for example is deprecated.
rice no more.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by machinebacon » Fri Nov 18, 2016 9:29 am

Sure, if you switch tty's and run startx (or any login to X), it will bail out because, as the error message says, an X server is already running.

Same applies to tmux. The server is running, you try to nest a new session inside a running session. It does only work if tmux is not a login shell.

I'm sure there's an ampersand missing or too much somewhere.

please send your /usr/local/bin/bbqlogin, your /local/usr/bin/openbox-start, your /usr/bin/start-wm and your ~/.bash_profile to pastebin or transfer.sh. or put them here.
..gnutella..

User avatar
catfood
Bad Advice Dog
Posts: 146
Joined: Tue Oct 04, 2016 1:25 am
Location: F google
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by catfood » Fri Nov 18, 2016 11:50 pm

Yea, I tried switching TTY after Kill all X methods since none of them kicked me back into TTY on their own. They all just seem to close all active windows but not much else...

All the above files mentioned and 2wm-start as well via transfer.sh:
https://transfer.sh/%28/xQ1ar/.bash-pro ... %29.tar.gz
Thank You!
(I remember when debian "non-gui" installer scared me. #never-forget)

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: [THE 1st TIME] Our own login manager

Unread post by machinebacon » Sat Nov 19, 2016 7:49 am

^ seems you have no .bash_profile (or didn't pack it), is there a ~/.profile instead?
the other files look OK...
..gnutella..

Post Reply