Wednesday, February 27, 2013

And then termsaver was born...

Some folks asked me how I came up with this... Truth is, I was just bored at class, and built a small script to make my screen "busy" (see code below). It is a simple 15-min coding script that displays the source code of files recursively in a directory character by characted, giving a cool impression of a "type-writing" machine.
When I then realized this was a nice thing, I searched a bit for some alternatives but couldn't find any that would be exclusive to the terminal. So I decided to share it with everyone... but I needed some spices to make it more attractive, so I looked for some feasible stuff that we could bring from traditional screensavers into the text-based world. Then new ideas such as ascii arts, floating text, and others came to life.
The first release, although not even hoping to get peopl on board to contribute, is already full capable to supporting internationalization and plugins (so ideally we will have N screensavers that can be added as different packages to termsaver main package).
Here is my original code that gave birth to the termsaver idea... for reference to enthusiasts:


import os
import sys
import time

def recurse_path_for_files(path, func, filetype = ''):
    for item in os.listdir(path):
        f = os.path.join(path, item)
        if os.path.isdir(f):
            if not item.startswith('.'):
                recurse_path_for_files(f, func, filetype)
        elif f.endswith(filetype) and \
                not os.system("file -b '" + f 
                   + "' | grep text > /dev/null"):

def main():
    start_path = '/home/bruno/workspace/'
    paths = []
    recurse_path_for_files(start_path, paths.append)

    count = 0
    while(count < 1):
        for path in paths:
            f = open(path, 'r')
            print "\n[%s]\n" % path
            for line in f.readlines():
                for char in line:

if __name__ == "__main__":
This was originally posted on APRIL 13, 2012 

No comments:

Post a Comment