Mike Dransfield schrieb:
I would like to have a small app written in python/gtk
which would be triggered with a keystroke.  The user
would hit the keystroke and the application would be
launched by the annotate plugin.

It could then provide a basic palette and text entering
functions (copy/paste, selecting font, style, color).  When
it is activated it can  change the action for  annotate so
the modifiers are removed, the user can then annotate
whatever they like, without worrying about modifiers
etc (an arrow tool will be provided which can be used
to move/select windows).

Great, this sounds exactly like what the new Vista Snipping Tool does.
It has a lot of cool features and i already thought about how to
implement some of them into compiz.

When they are finished they can click a button which
would activate screenshot so that they can then take a
screenshot.

The screenshot plugin would then save the file and send
a signal through dbus to the helper app.  This can then
pick up the file and launch an email application or anything
else which can handle the image (instant messenger/web
forum etc etc).

Another approach could be to add an option to the screenshot plugin
which launches an external app. This could launch your helper app or
something else. I'm using this to upload screenshots to my flickr account.

Here is a patch for screenshot.c which adds a launch_app option.
What do you think?

Cheers. Gerd

diff --git a/plugins/screenshot.c b/plugins/screenshot.c
index ad27772..f3d504e 100644
--- a/plugins/screenshot.c
+++ b/plugins/screenshot.c
@@ -26,19 +26,22 @@
 #include <stdlib.h>
 #include <string.h>
 #include <dirent.h>
+#include <unistd.h>
 
 #include <compiz.h>
 
 #define SHOT_INITIATE_BUTTON_DEFAULT	       Button1
 #define SHOT_INITIATE_BUTTON_MODIFIERS_DEFAULT CompSuperMask
 
-#define SHOT_DIR_DEFAULT "Desktop"
+#define SHOT_DIR_DEFAULT        "Desktop"
+#define SHOT_LAUNCH_APP_DEFAULT "eog"
 
 static int displayPrivateIndex;
 
-#define SHOT_DISPLAY_OPTION_INITIATE 0
-#define SHOT_DISPLAY_OPTION_DIR      1
-#define SHOT_DISPLAY_OPTION_NUM	     2
+#define SHOT_DISPLAY_OPTION_INITIATE   0
+#define SHOT_DISPLAY_OPTION_DIR        1
+#define SHOT_DISPLAY_OPTION_LAUNCH_APP 2
+#define SHOT_DISPLAY_OPTION_NUM        3
 
 typedef struct _ShotDisplay {
     int		    screenPrivateIndex;
@@ -251,6 +254,7 @@ shotPaintScreen (CompScreen		 *s,
 		    if (n >= 0)
 		    {
 			char name[256];
+			char *app;
 			int  number = 0;
 
 			if (n > 0)
@@ -265,12 +269,31 @@ shotPaintScreen (CompScreen		 *s,
 
 			sprintf (name, "screenshot%d.png", number);
 
+			app = sd->opt[SHOT_DISPLAY_OPTION_LAUNCH_APP].value.s;
+
 			if (!writeImageToFile (s->display, dir, name, "png",
 					       w, h, buffer))
 			{
 			    fprintf (stderr, "%s: failed to write "
 				     "screenshot image", programName);
 			}
+			else if (*app != '\0')
+			{
+			    char *comm;
+
+			    comm = malloc (sizeof(app) + sizeof(dir) + sizeof(name) + 2);
+			    if (comm)
+			    {
+				sprintf (comm, "%s %s/%s", app, dir, name);
+
+				if (fork () == 0)
+				{
+				    execl ("/bin/sh", "/bin/sh", "-c", comm, NULL);
+				}
+
+				free (comm);
+			    }
+			}
 		    }
 		    else
 		    {
@@ -380,6 +403,15 @@ shotDisplayInitOptions (ShotDisplay *sd)
     o->value.s	      = strdup (SHOT_DIR_DEFAULT);
     o->rest.s.string  = 0;
     o->rest.s.nString = 0;
+
+    o = &sd->opt[SHOT_DISPLAY_OPTION_LAUNCH_APP];
+    o->name           = "launch_app";
+    o->shortDesc      = N_("Launch Application");
+    o->longDesc       = N_("Automatically open screenshot in this application");
+    o->type           = CompOptionTypeString;
+    o->value.s        = strdup (SHOT_LAUNCH_APP_DEFAULT);
+    o->rest.s.string  = NULL;
+    o->rest.s.nString = 0;
 }
 
 static CompOption *
_______________________________________________
compiz mailing list
compiz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/compiz

Reply via email to