Gimp-Forum.net

Full Version: Trigger a script depending on time?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,
I want to write a Python script that performs a set of GIMP procedures depending on the time elapsed after starting GIMP and was wondering if this kind of script is possible. Thanks in advance.
(09-14-2017, 11:33 AM)PNGer Wrote: [ -> ]Hi all,
I want to write a Python script that performs a set of GIMP procedures depending on the time elapsed after starting GIMP and was wondering if this kind of script is possible. Thanks in advance.

The best you can do is call Gimp with  a special parameter:

For instance: this script periodically reports the number of opened images:

Code:
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-

import os,glob,sys,time
from gimpfu import *


def run():
    print 'Loaded, starting wait loop'
    while True:
    time.sleep(10)
    print "Total images:",len(gimp.image_list())

if __name__ == "__main__":
    print "Running as __main__ with args: %s" % sys.argv

Then you start Gimp as (assuming it is in a file named "wait.py"):

Linux/OSX version:

Code:
gimp --batch-interpreter python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import wait;wait.run()'

Windows version:

Code:
gimp --batch-interpreter python-fu-eval -b "import sys; sys.path=['.']+sys.path;import wait;wait.run()"