Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Zacherl

Terminal Server AND Screen?

Question

Hello there,

 

I just started looking into OC (did some things with CC before) and saw a YouTube video where a guy was using the Remote Terminal and a screen at the same time (the contents were mirrored). Did this behaviour change? If so, is there any other way to output data to a screen and beeing able to use the shell on a Remote Terminal at the same time?

 

Best regards

Zacherl

Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

It is possible but mirroring in the precise sense is a bit tricky. If you just want to run a program on a screen and still have a shell in the remote terminal that's not that difficult. What are you trying to achieve? Do you really need mirroring? Or do you just want to be able to run more than one program at a time?

Link to post
Share on other sites
  • 0
8 hours ago, Molinko said:

If you just want to run a program on a screen and still have a shell in the remote terminal that's not that difficult. What are you trying to achieve? Do you really need mirroring? Or do you just want to be able to run more than one program at a time?

Nice, thats exactly what I want. My computer runs a program that shows status info on a screen and I want to be able to remotely use the shell on a terminal without interrupting the screen output.

Is there by chance any tool (launcher) that automatically redirects the output of programs in a generic way? For ComputerCraft there was the "screen <lua_script> <side>" command to archieve this. I saw the OpenOS "isloated" process/environment architecture, so shouldn't it be possible to override the main gpu/screen just for a single process?

 

8 hours ago, Molinko said:

It is possible but mirroring in the precise sense is a bit tricky.

Yeah, I already played around with that quite a bit, after I found this thread:

The results were ... mhh ... unpredictable :D Registering the VGPU as primary destroys the terminal output on all screens. Same result for calling "vgpu.setBackground()" or some other random function.

Link to post
Share on other sites
  • 1
  • Solution

Okay, so i worked something up for you. These two scripts should get you started. If you need something better you'll have to build it yourself :p

Add these files to /home/,  /home/bin/,  or  /usr/bin/. Whichever you prefer.

tmsp.lua  "term swap"

local component = require "component"
local term = require "term"

local args, opts = require("shell").parse(...)
local USAGE = [[
Usage: $cmd [q, m, f, --gpu, --screen] [screen_address]
$cmd -mf --screen=27f    include motd, flush screen
$cmd -qf 27f --gpu=38a   quite mode, flush
]]

if not term.isAvailable() then
  os.exit()
end

if not opts.screen and not args[1] then
  local cmd = require("process").info().command
  io.stderr:write(USAGE:gsub("%$cmd", cmd).."\n")
  os.exit()
end

local screen, err = component.get(opts.screen or args[1], 'screen')
if not screen then
  io.stderr:write(("failed to get screen component")..'\n')
  os.exit()
end

local gpu
if opts.gpu then
  gpu, err = component.get(opts.gpu, "gpu")
  if not gpu then
    io.stderr:write(("failed to get gpu component")..'\n')
    os.exit()
  end
else
  gpu = component.gpu.address
end

if screen ~= term.screen() then
  if not opts.q then
    print "rebinding term screen.."
    os.sleep(1)
  end

  if opts.f then term.clear() end

  component.invoke(gpu, "bind", screen)
  term.setCursor(1, 1)
  term.bind(component.proxy(gpu))

  if opts.f then term.clear() end

  if opts.m then
    dofile("/etc/motd")
  end
else
  if not opts.q then
    print "screen is already bound to term"
  end
end

alterm.lua "alternate term"

local component = require "component"
local process = require "process"
local thread = require "thread"
local event = require "event"
local term = require "term"

local args, opts = require("shell").parse(...)
local USAGE = [[
Usage: %s [-qf] --screen=5b3 --gpu=64f `program ...`
  -q: quiet mode
  -f: flush the target screen before and after program execution
]]

if not opts.screen or not opts.gpu or not args[1] then
  local cmd = process.info().command
  io.stderr:write(USAGE:format(cmd).."\n")
  os.exit()
end

local gpu = assert(component.get(opts.gpu, 'gpu'))
local screen = assert(component.get(opts.screen, 'screen'))
assert(component.invoke(gpu, "bind", screen, opts.f))

local proc = thread.create(function()
  local window = term.internal.open(0, 0, component.invoke(gpu, "getViewport"))
  term.bind(component.proxy(gpu), window)
  process.info().data.window = window
  if opts.f then term.clear() end
  os.execute(args[1])
  if not opts.q then
    print('exiting from background..')
    os.sleep(1)
  end
  if opts.f then term.clear() end
end)

proc:detach()

if not opts.q then
  print(('backgrounded "%s" on gpu[%s] & screen[%s]'):format(args[1], opts.gpu, opts.screen))
end

Add these to your /home/.shrc file to start them after boot.

Be sure to insert your own component addresses. Addresses may be abbreviated.

tmsp -qfm --screen=45af --gpu=7ed2
alterm -qf --screen=65ec --gpu=b9d3

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.