WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Exit to terminal from script  (Read 3506 times)

Offline TopNotch

  • Newbie
  • *
  • Posts: 12
Exit to terminal from script
« on: March 13, 2019, 03: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.
The more complex the mind, the greater the need for the simplicity of play.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Exit to terminal from script
« Reply #1 on: March 13, 2019, 04: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.

Offline TopNotch

  • Newbie
  • *
  • Posts: 12
Re: Exit to terminal from script
« Reply #2 on: March 13, 2019, 05: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.
The more complex the mind, the greater the need for the simplicity of play.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Exit to terminal from script
« Reply #3 on: March 13, 2019, 10:26:57 PM »
Hi TopNotch
Please post your  .xsession  file.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Exit to terminal from script
« Reply #4 on: March 14, 2019, 04:48:57 AM »
There are also image viewers for the framebuffer.
The only barriers that can stop you are the ones you create yourself.

Offline TopNotch

  • Newbie
  • *
  • Posts: 12
Re: Exit to terminal from script
« Reply #5 on: March 14, 2019, 10: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
The more complex the mind, the greater the need for the simplicity of play.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Exit to terminal from script
« Reply #6 on: March 14, 2019, 10: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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Exit to terminal from script
« Reply #7 on: March 14, 2019, 11: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.

Offline TopNotch

  • Newbie
  • *
  • Posts: 12
Re: Exit to terminal from script
« Reply #8 on: March 14, 2019, 01:27:18 PM »
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?
The more complex the mind, the greater the need for the simplicity of play.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Exit to terminal from script
« Reply #9 on: March 14, 2019, 01:35:39 PM »
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/

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11619
Re: Exit to terminal from script
« Reply #10 on: March 14, 2019, 01:44:04 PM »
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

Offline TopNotch

  • Newbie
  • *
  • Posts: 12
Re: Exit to terminal from script
« Reply #11 on: March 14, 2019, 04: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.
The more complex the mind, the greater the need for the simplicity of play.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Exit to terminal from script
« Reply #12 on: March 15, 2019, 03:53:29 AM »
fbv posted to CorePure64 repo