Tech Tip: Create an Automatically Scrolling Reader

By combining three useful command-line tools (less, watch and xdotool) along with two xterm windows, you can create an automatically scrolling reader.

Say you have a good book in text-file form ('book.txt') that you just downloaded from Project Gutenberg.

Open one xterm and do the usual thing you do when you want to read that book with less:


$ less book.txt

Look at the first few characters in the title line of that xterm's window. (In mine, it was bzimmerly@zt, which is my user ID and the name of the machine I was working on.)

Open another xterm, issue this command, and watch (pun intended) the magic:


$ watch -n 1 xdotool search --name bzimmerly@zt key ctrl+m

The watch command will (every second) issue a "Return" (Ctrl-m) keystroke to the window that has "bzimmerly@zt" as a title, and it will stop only when you interrupt it with Ctrl-c! I think this is neato daddyo! (What can I say? I'm a child of the '60s!)

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Scrolling Reader using tabs

Richard B's picture

Worked fine for me under using Ubuntu 10.10 (Meerkat), so I tried using tabs - one for the document, a second for the command. Start it then click on the document tab and scrolling starts. To pause it, click on the command tab which then receives (but ignores) the "Return"s. Click the document tab to resume lazy reading.

Note, however, that if you have another terminal window open with the same title line it will send to that.

Error opening terminal: xterm-256color

Travel Directory's picture

how do we go about installing the necessary terminfo files then?

hmmpf. all I get in the

Anonymous's picture

hmmpf. all I get in the second xterm is a ">"

Thanks for sharing

Mix Twist's picture

it looks cool to give a try will be back after making and experiment with this

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState