Virtuale console tricks feat. mplayer, ttyecho & ct

Post tutorials, HOWTO's and other useful resources here.
Post Reply
User avatar
Posts: 1581
Joined: 11 Jan 2011, 02:46
Distribution: Porteus 3.1.0 x86-64 XFCe
Location: Germany

Virtuale console tricks feat. mplayer, ttyecho & ct

Post#1 by Rava » 17 Apr 2016, 14:48

I already posted the code of my ct script here, I have to find it again so that I can link to it.
When you have a root terminal open in X, you can use my script to look into the virtual console, e.g. you have a backup job running there. No need to change to the VT with your keyboard, just type

Code: Select all

# ct 1
for "copy console 1" aka tty1, and you get something like so:

Code: Select all

root@porteus:/mnt# ct 3

 Welcome to Rava's Happy Porteus ^-^                Porteus x86_64 3.1.0 Rava1

                --  An apple a day keeps the doctor away.  --

                           ** Terminal is tty3 **
                       * Sun Apr 17  2016   11:36:17 *
porteus login:
You can see, I have a custom tty login, and currently there is no one logged into tty3.

But there is much more.

With ttyecho you can copy text to a terminal or a virtual console. You again need to be root for that. When you add the -n at the geginning the text will be ended with a Carriage Return aka an "enter" and thus a program can be started, on another console.

Like, using mplayer to play a playlist. Like so:

Code: Select all

# ./ttyecho -n /dev/tty5 mplayer -playlist /path/to/playlist.pls

But Cave!
The way gnome-mplayer saves playlists is not compatible how mplayer needs them. One keeps the whitespace as they are, the other one saves its playlist them converted.

mplayer wants the syntax like so:

Code: Select all

File1=file:///mnt/sda2/sound/One Piece/One Piece OST - Mother Sea (First Part) [Extended Version].mp3
while gnome-mplayer saves it like so:

Code: Select all


But once you made a version mplayer is happy with, all you need is log into any virtual console (this is the only time you actually "physically" have to go there), you can login as non root user, in my case I login as "rava" (there is no "guest" in my Porteus. Especially I am not just a guest on my Porteus. :D )

Anyhow, you need to give mplayer the option -playlist or else it tries to open the playlist as a media file and that will fail.

Now let's put it all together:

Code: Select all

./ttyecho -n /dev/tty5 mplayer -playlist /mnt/sda2/sound/OP.pls
And when all is right, all songs from the playlist start playing.
You could even remove control mplayer by giving it the ">" character for "next song", but mplayer also pauses every time I tried this "remote control thingy", so to stop it either use kill or killall, or again "physically" go to the virtual terminal.

All in all, a neat trick having things done without hogging a screen in X, you can still look into the console with my ct script, and you also can even run more than one program using ttyecho. You just have to be logged into the virtual console you want to use prior running ttyecho.

I have compiled ttyecho for x86-64 Porteus 3.1,please tell me if anyone is interested in it, and I will share it with you folks.
Yours Rava

Post Reply