5

I want to run streamripper in its own X Terminal (window), then split the terminal horizontally, and then run mplayer in the lower half.
This is simple enough to do manually, but getting a script to do it eludes me.

mplayer cannot be allowed to run immediately. It needs to wait for stream data, so a test for this would be better than "wait x seconds" (which is effectively what the manual method does.

If the terminal is significant to this, anything will do, but I currently have installed konsole, gnome-terminal, and terminator (in Ubuntu)

Peter.O
  • 32,426
  • 28
  • 115
  • 163

1 Answers1

4

Although some terminal programs have support for splitting, you won't be able to access this functionality from the shell which is running in a different layer and doesn't have access to the software displaying it.

What you can do is use a terminal multiplexer such as GNU Screen or tmux that allow you to run multiple shells in "panes" inside a console.

Screen has been around since the dawn of time and works, but lately the project has falled into dis-repair and it's not being well maintained. Tmux is kind of a new player on the scene but the code is very clean and mature, it has a few more features than screen, and it's a good deal easier to learn and configure. Even though I still use screen out of force of habit, I highly recomend you use tmux for this.

You should be able to write a script that launches a tmux session, runs your streamripper code in one pane, waits for a condition, then adds another pane to the same session, displays it as a split screen, then runs mplayer in the new pane.

Caleb
  • 69,278
  • 18
  • 196
  • 226
  • If I have time later I'll add some sample code for a script that does something like this in tmux. – Caleb Jul 01 '11 at 08:27
  • I'm quite new to `screen`, but I have tried it. My impression is that even when the console is closed, any running shell app keeps running. Is there some way to avoid this behaviour (maybe it is just a simple *screen* option), because I don't want to inadvertently have streamripper chugging away "windowless" because I forgot it was running as a screen session.. It can chew up a **lot** of data over a few days... – Peter.O Jul 01 '11 at 08:41
  • I've just read your info about `tmux`...I'll have a look at it... – Peter.O Jul 01 '11 at 08:45
  • @fred: I'm not sure about screen since I would never dream of killing a screen session if the terminal goes way, but I'm pretty sure I saw something like that when I was reviewing tmux docs. Basically an action to run when the session gets detached. You could always script this too ... it's easy to get a list of detached sessions and you could use a cron job to clean them up or warn you about them so you could choose to let them run or reconnect to close them. – Caleb Jul 01 '11 at 08:53
  • Thanks... It seems that I got that minor *phobia* from when I first experimented with *screen*, when I actually wanted a detachment... I've briefly tried both *screen* and *tmux* again with this in mind.. and it seems fine; as you mentioned. It requires actual and obvious action on my part to either kill or detach the session, – Peter.O Jul 01 '11 at 09:25
  • @fred `splitvt` provides terminal splitting without the other features of `screen`. – Gilles 'SO- stop being evil' Jul 01 '11 at 11:56
  • @gilles: Thanks, `splitv` is interesting, but I think it won't suit my particular requirement of being able to stop and start mplayer at will.. *splitvt* seems to be a *one-hit-wonder*; it just exits back to the parent terminal window... Even if it can do more, I may as well focus on `tmux`, which I'm having a hell of a time to get working; I haven't found the knack of running commands to individual windows from outside of *tmux*... **yet**.. I'll sleep on it :) – Peter.O Jul 01 '11 at 14:30
  • @fred: I know there are some questions on here that demonstrate both running commands and sending keystrokes to specific panes in tmux from a script. You might search around a little. I'll try to put something specific together for you if I can get time. – Caleb Jul 01 '11 at 14:35
  • @Caleb: Yes, thanks. I'm sure it can be done.. I'm just missing some trivial but significant issue... I'll crack this nut tomorrow; for sure :)... I like `tmux` already... – Peter.O Jul 01 '11 at 14:42
  • Thanks Caleb... I've got a bit to learn yet, about my expectations vs how it actually works, but `tmux` certainly does the job... Here is a example of running the two apps in a split window: `tmux new -d -s riplay 'watch -n 1 -d date' \; split-window -d 'watch -n 2 -d date' \; downp` ... using `watch date` for the commands – Peter.O Jul 01 '11 at 19:05