You are not logged in.

#1 2021-04-08 11:17:39

zacariaz
Member
Registered: 2012-01-18
Posts: 499
Website

Execute on different tty, or similar behavior

I've been Googling all day, and the closest I can come to an answer, is that what I want to do, is simply not possible. Well, that won't do, thus I ask the experts.

In short, I have create a script which does everything I need to do, which is stop any xserver business (to fully be able to utilize the GPU), do some stuff and once completed, start the normal stuff again.

If I change to, say tty2, and execute said script, everything runs as clockwork, and I don't even need to bother changing back to tty7 once completed.
So what I'm thinking I need, is to automate the change to tty2 (including login if necessary), and run the script in question. Of course changing to another tty is easy, provided it's already logged in, (alternatively there's openvt, but that's iffy), but getting it to execute the script, that is beyond me.
I wish to be able to do this with a press of a button, in my Desktop environment of choice.

I though it would be simple, but I cannot for the life of me figure it out, thus I hope someone here will be able to help.


Best regards.

Offline

#2 2021-04-08 12:02:37

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,254

Re: Execute on different tty, or similar behavior

To change to a different consoleTTY you could simulate a key combo with xdotool:

xdotool key Control+Alt+F5

Using commands like 'chvt 5' will only work in console...

Last edited by qinohe (2021-04-08 12:08:41)

Offline

#3 2021-04-08 15:07:47

zacariaz
Member
Registered: 2012-01-18
Posts: 499
Website

Re: Execute on different tty, or similar behavior

qinohe wrote:

To change to a different consoleTTY you could simulate a key combo with xdotool:

xdotool key Control+Alt+F5

Using commands like 'chvt 5' will only work in console...

Presumably that will only work as far as changing to another console, which I can also do, without any issues, but I'll look into it.

Thanks.

Last edited by zacariaz (2021-04-08 15:10:05)

Offline

#4 2021-04-11 13:23:30

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,254

Re: Execute on different tty, or similar behavior

zacariaz wrote:

Presumably that will only work as far as changing to another console

Ah, right :-) You may want to look at 'setsid' run a command in a new session (see) 'man setsid'
You can experiment a little with both commands!
Something like:

#!/bin/sh
  xdotool key Control+Alt+F5
  setsid sh -c '/home/mark/bin/test <> /dev/tty5 >&0'
#  setsid sh -c '/home/mark/bin/test <> /dev/tty5 >&0 2>&1'
exit 0

I don't know how effective this would be for you, but it does work, somehow...

edit: Example, I tried to use a shell script which I use as my display manager, this failed with message:

(WW) xf86OpenConsole: VT_ACTIVATE failed: Operation not permitted
(EE) xf86OpenConsole: Switching VT failed

So, you need workarounds for that kind of stuff, simple commands work, though I have reservations using this kind of tricks!

Last edited by qinohe (2021-04-11 14:08:50)

Offline

Board footer

Powered by FluxBB