A silly web development tip

I have two windows open: a text editor window with a CSS stylesheet loaded and a Konqueror window with an html page that uses the stylesheet. I change a color, reload Konqueror, change border style, reload Konqueror, change margin, reload Konqueror...

Can these reloads be automated? Of course they can!

# reload_konq.py

import sys, os, time

def send_message(instance):
    os.system("dcop %s konqueror-mainwindow#1 reload" % instance)

if __name__ == '__main__':
    """$ sys.argv[0] foo.html konqueror-27967
    That will make the script look at foo.html every 2 seconds and if it has changed,
    the script will reload the first tab in the konqueror instance with PID 27967
    f = sys.argv[1]
    k = sys.argv[2]

old_mtime = os.stat(f).st_mtime

while 1:
        if old_mtime != os.stat(f).st_mtime:
            old_mtime = os.stat(f).st_mtime


The polling ugliness is needed till pyinotify becomes mainstream, i.e. comes in a pre built package :-)

PS: The site root has a new color scheme. Hot or Not?


nice.... maybe i should u ask you to recommend color schemes :)

Not really. All I do is cherry pick colors I like from the sites I like :-)

Well, the design is nice, but the color scheme needs improvement.

any suggestions?

If your editor is scriptable (Vim, or Emacs, for example), then you could bind a key to save-file-and-send-dcop-command. No polling required (and if you use Vim, then the python code may work with minimal changes)

BTW, isn't DBus the new way to do this stuff? Or has konquerer not yet got?

I was using Kate but maybe I should explore Vim's capabilities in that direction.

DBus will replace DCOP only in KDE4. Meanwhile in GNOME land, there's no functional DCOP equivalent.

Markdown formatting supported