These are good ideas. We'll give them a try. It seems to me this should be included in the linuxwacom project to accompany the wacomcpl tool.

On 01/25/2011 12:19 PM, Favux ... wrote:
That sounds good.  Or you can create a little daemon.  Cyberfish came
up with this about 2 years ago.  Call it monitor_wacom.c:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <assert.h>

void log_msg(const char *msg) {

	FILE *log_file = fopen(".monitor_wacom.log", "a");

	if (log_file) {
		time_t time_g;
		time(&time_g);
		char date_str[100];
		strcpy(date_str, asctime(localtime(&time_g)));
		date_str[strlen(date_str) - 1] = '\0'; /* get rid of the \n */
		fprintf(log_file, "%s : %s\n", date_str, msg);
	}

	fclose(log_file);
}

void run_script(const char *filename) { /* only run xsetwacom lines */
	FILE *script_file = fopen(filename, "r");
	
	if (!script_file) {
		log_msg("Failed to open script (double check your entry in Startup
Applications). Terminating.");
		exit(1);
	}

	char buf[1024];
	char l_buf[1024];
	int count = 0;
	while ((fgets(buf, 1023, script_file))) {
		if (strstr(buf, "xsetwacom")) {
			int r = system(buf);
			if (r != 0) {
				sprintf(buf, "xsetwacom returned error on line - %s", buf);
				log_msg(l_buf);
			}
			++count;
		}
	}

	sprintf(l_buf, "Script ran. %d matching lines executed.", count);

	log_msg(l_buf);
}

int main(int argc, char **argv) {

	char script_name[1024];

	if (argc != 2) {
		log_msg("Script not specified, using .xinitrc");
		strcpy(script_name, ".xinitrc");
	} else {
		strcpy(script_name, argv[1]);
	}
	
	run_script(script_name);

	FILE* in = popen("dbus-monitor --session
type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'",
"r");
	
	if (!in) {
		log_msg("Cannot spawn dbus-monitor process. Terminating.");
		return 1;
	}

	while (1) {
		char buf[1024];
		assert(fgets(buf, 1023, in));
		
		if (buf[0] == 's' /* early exit optimization */ && strstr(buf,
"ActiveChanged") != NULL) {
			assert(fgets(buf, 1023, in));
			if (strstr(buf, "false") != NULL) {
				/* resumed */
				log_msg("Exit from screensaver detected. Running script.");
				run_script(script_name);
			} else {
				/* put to sleep */
			}
		}
	}
}


gcc -O2 monitor_wacom.c -o .monitor_wacom

And then in Startup Applications:

/home/yourusername/.monitor_wacom /home/yourusername/.xinitrc

Favux

On Tue, Jan 25, 2011 at 2:06 PM, Cedric Sodhi <man...@gmx.net> wrote:
Hello, this is the same for all devices, I think. At least it's the same
for my Intuos4. But I think that's okay.

It's not the responsibility of the driver to re-initialize the device
with the old settings - the driver is simply the method to communicate
with it, it shall not offer any "special service" such as remembering
options. You should use a dedicated tool for that.

There is a certain problem though, which, however, is not to blame on
the wacom but rather on X11 polcies, that is, usually UDEV should handle
hotplugging these days but udev (or anything started from it) will have
problems with setting xinput props because it lacks the authz to do so.

I suggest you set up a simple bash script which is started with xinit
and will listen for the wacom being plugged or not. Most easily, you
could do this by setting up an udev rules which provides a user-readable
switch (such as a file /tmp/wacom_is_plugged) when the wacom is up and
removes it if it isnt.

The bash script can simply run in a loop (with sleep 1000 or so) and
execute your wacom_set_props.sh script if udev communicates it that the
device has been plugged.

I've a similar setup (not for the wacom but for an external) monitor and
it works flawlessly and, best of all, is very flexible.

regards,
Cedric

On Tue, Jan 25, 2011 at 11:48:53AM -0800, Steven L. Seed wrote:
   Has anyone noticed that when you hotplug a Cintiq that has been calibrated
   with the wacomcpl, you lose the calibration (it resets) after you hotplug
   the tablet? This is particularly problematic in our environment where the
   tablets are attached via kvm switches to work with multiple systems. We
   are on RHEL6 running Xorg 1.7.7-26 and the wacom driver version 0.10.5-8.

   --
   [1][IMG]

References

   Visible links


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d

        
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


--
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to