Tiny Core Linux

Tiny Core Base => TCB Talk => Topic started by: TopNotch on March 13, 2019, 12:22:38 PM

Title: Exit to terminal from script
Post by: TopNotch on March 13, 2019, 12:22:38 PM
I need a way to exit to terminal from a script. In other words, to what Ctrl-Alt-Backspace does, but from a a script.
I want to open a terminal window, run a script that does a few things, and ends with exiting from GUI to terminal.
Title: Re: Exit to terminal from script
Post by: Rich on March 13, 2019, 01:21:32 PM
Hi TopNotch
If you are trying to exit X to end up at the console, then this should get you there:
Code: [Select]
sudo kill $( cat /tmp/.X${DISPLAY:1:1}-lock ) &That is how  exittc  exits to a console prompt.
Title: Re: Exit to terminal from script
Post by: TopNotch on March 13, 2019, 02:57:11 PM
Rich, that works by itself, but here's what I'm trying to do.
Starting from terminal mode, I want to startx, run feh to display a graphic image, and when the user presses Esc to exit form feh, it should go back to terminal mode. I added a line to .xsession to run feh and display the image, and I tried your line after that line. When I press Esc, it goes to a cross-hatch background, not to terminal mode.
Title: Re: Exit to terminal from script
Post by: Rich on March 13, 2019, 07:26:57 PM
Hi TopNotch
Please post your  .xsession  file.
Title: Re: Exit to terminal from script
Post by: curaga on March 14, 2019, 01:48:57 AM
There are also image viewers for the framebuffer.
Title: Re: Exit to terminal from script
Post by: TopNotch on March 14, 2019, 07:33:25 AM
curoga, is tere a program in the repository that is an image viewer for the framebuffer? If so, what is it?

Rich, here is my .xsession file:
Code: [Select]
/usr/local/bin/Xfbdev -mouse /dev/input/mice,5 -nolisten tcp -I >/dev/null 2>&1 &
export XPID=$!
waitforX || ! echo failed in waitforX || exit
"$DESKTOP" 2>/tmp/wm_errors &
export WM_PID=$!
feh ship.jpg
sudo kill $( cat /tmp/.X${DISPLAY:1:1}-lock } &
[ -x $HOME/.setbackground ] && $HOME/.setbackground
[ -x $HOME/.mouse_config ] && $HOME/.mouse_config &
[ $(which "$ICONS".sh) ] && ${ICONS}.sh &
[ -d "$HOME/.X.d" ] && find "$HOME/.X.d" -type f -print | while read F; do . "$F"; done
Title: Re: Exit to terminal from script
Post by: Rich on March 14, 2019, 07:43:04 AM
Hi TopNotch
I think your problem is because you inserted those commands in the middle of the file. Either move them to the end like this:
Code: [Select]
/usr/local/bin/Xfbdev -mouse /dev/input/mice,5 -nolisten tcp -I >/dev/null 2>&1 &
export XPID=$!
waitforX || ! echo failed in waitforX || exit
"$DESKTOP" 2>/tmp/wm_errors &
export WM_PID=$!
[ -x $HOME/.setbackground ] && $HOME/.setbackground
[ -x $HOME/.mouse_config ] && $HOME/.mouse_config &
[ $(which "$ICONS".sh) ] && ${ICONS}.sh &
[ -d "$HOME/.X.d" ] && find "$HOME/.X.d" -type f -print | while read F; do . "$F"; done
feh ship.jpg
sudo kill $( cat /tmp/.X${DISPLAY:1:1}-lock } &
or add an exit statement like this:
Code: [Select]
/usr/local/bin/Xfbdev -mouse /dev/input/mice,5 -nolisten tcp -I >/dev/null 2>&1 &
export XPID=$!
waitforX || ! echo failed in waitforX || exit
"$DESKTOP" 2>/tmp/wm_errors &
export WM_PID=$!
feh ship.jpg
sudo kill $( cat /tmp/.X${DISPLAY:1:1}-lock } &
exit
[ -x $HOME/.setbackground ] && $HOME/.setbackground
[ -x $HOME/.mouse_config ] && $HOME/.mouse_config &
[ $(which "$ICONS".sh) ] && ${ICONS}.sh &
[ -d "$HOME/.X.d" ] && find "$HOME/.X.d" -type f -print | while read F; do . "$F"; done
Title: Re: Exit to terminal from script
Post by: Rich on March 14, 2019, 08:13:46 AM
Hi TopNotch
curoga, is tere a program in the repository that is an image viewer for the framebuffer? If so, what is it?
If my previous answer doesn't solve your problem and you want try a framebuffer based image viewer there's  fbv.
Title: Re: Exit to terminal from script
Post by: TopNotch on March 14, 2019, 10:27:18 AM
Forgot to mention that I'm trying to do this on Tiny Core 64. fbv is not in the repository for 64-bit Tiny Core, so I'm trying to compile it. It needs libungif. I see libgif in the repository, but not libungif. Any ideas?
Title: Re: Exit to terminal from script
Post by: Rich on March 14, 2019, 10:35:39 AM
Hi TopNotch
I take it my previous suggestions did not help? Try using the source package and build script (ashes) from here:
http://tinycorelinux.net/4.x/x86/tcz/src/fbv/
Title: Re: Exit to terminal from script
Post by: Rich on March 14, 2019, 10:44:04 AM
Hi TopNotch
Hi TopNotch
 ... Try using the source package and build script (ashes) from here:
http://tinycorelinux.net/4.x/x86/tcz/src/fbv/
You'll want to modify these flags for x86_64:
Code: [Select]
export CFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export LDFLAGS="-Wl,-O1"
as per the Wiki:
http://wiki.tinycorelinux.net/wiki:creating_extensions#installing
Title: Re: Exit to terminal from script
Post by: TopNotch on March 14, 2019, 01:44:08 PM
Rich,
It turns out that the source you gave was too old to build under my version of TC (9.0). I found a later source which builds fine.
https://github.com/godspeed1989/fbv
Thanks for the help.
Title: Re: Exit to terminal from script
Post by: Juanito on March 15, 2019, 12:53:29 AM
fbv posted to CorePure64 repo