<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=1647&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / How to send a signal whenever mouse button is clicked? [SOLVED]]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=1647</link>
		<description><![CDATA[The most recent posts in How to send a signal whenever mouse button is clicked? [SOLVED].]]></description>
		<lastBuildDate>Thu, 12 Oct 2017 18:40:23 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: How to send a signal whenever mouse button is clicked? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5503#p5503</link>
			<description><![CDATA[<p>Thanks, ralph.ronnquist. I&#039;ll explore that option.</p><p>In the meantime, I found yet another gem. Here is a python script that sends a signal to somescript whenever there is any mouse or keyboard activity:</p><div class="codebox"><pre><code>from pynput import keyboard
from pynput import mouse
import os

def send_signal()
        os.system(&#039;pkill -USR1 somescript&#039;)

def on_press(key): 
	send_signal()

def on_move(x, y):
	send_signal()

def on_click(x, y, button, pressed):
	send_signal()

def on_scroll(x, y, dx, dy):
	send_signal()

with mouse.Listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener:
	with keyboard.Listener(on_press=on_press) as listener:
		listener.join()</code></pre></div><p>It would be easy to adapt the above to only send the signal in a subset of cases (e.g., only on left clicks).</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Thu, 12 Oct 2017 18:40:23 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5503#p5503</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to send a signal whenever mouse button is clicked? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5486#p5486</link>
			<description><![CDATA[<p>A smaller footprint&#160; solution would simply read byte triplets from <span class="bbu">/dev/input/mice</span>, where &lt;9,0,0&gt; means left button down, and &lt;8,0,0&gt; means left button up; all other triplets mean other things. I would use <span class="bbu">newlisp</span>, of course, to remain in small foot print scripting, but a small C program could also do.</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Wed, 11 Oct 2017 12:38:51 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5486#p5486</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to send a signal whenever mouse button is clicked? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5482#p5482</link>
			<description><![CDATA[<p>Thanks. I don&#039;t actually use that, but I&#039;m glad to know about it. It might come in handy some time.</p>]]></description>
			<author><![CDATA[dummy@example.com (fsmithred)]]></author>
			<pubDate>Wed, 11 Oct 2017 11:05:20 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5482#p5482</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to send a signal whenever mouse button is clicked? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5473#p5473</link>
			<description><![CDATA[<p>@fsmithred - If you just need your system to do something for you (e.g., stop a script) when coming out of idle (i.e., when there is any keyboard or mouse activity), you may like this: <a href="https://unix.stackexchange.com/a/122816" rel="nofollow">https://unix.stackexchange.com/a/122816</a></p><p>I tried it and it worked like a charm. I just needed to install libxss-dev (provides scrnsaver.h) before compiling.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Tue, 10 Oct 2017 23:59:46 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5473#p5473</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to send a signal whenever mouse button is clicked? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5468#p5468</link>
			<description><![CDATA[<p>Thanks, fsmithred. I took a look at xscreensaver&#039;s code. I&#039;m too lazy to parse through all that <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>I found a solution. It requires that python3 and the pyuserinput module (which contains pymouse) be installed.</p><div class="codebox"><pre><code>#!/usr/bin/python3
from pymouse import PyMouseEvent
import os
class ClickDetector(PyMouseEvent):
    def __init__(self):
        PyMouseEvent.__init__(self)
    def click(self, x, y, button, press):
        &#039;&#039;&#039;Send signal when left click is pressed.&#039;&#039;&#039;
        if button == 1:
            if press:
                os.system(&#039;pkill -USR1 somescript&#039;)
ClickDetector().run()</code></pre></div><p>If the above is running in the background, my mouse works normally and any time I left-click on anything a SIGUSR1 is sent to somescript.</p><p>Perhaps you can adapt the above and use it instead of xscreensaver for your purposes, although as-is it does not respond to keyboard input.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Tue, 10 Oct 2017 17:11:56 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5468#p5468</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to send a signal whenever mouse button is clicked? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5466#p5466</link>
			<description><![CDATA[<p>This is not exactly what you&#039;re looking for, but maybe it can be adapted or maybe it will give you an idea. I set up xscreensaver to run a script that would stop if I clicked the mouse or keyboard. You could either have it run/stop somescript or have it run a script that did something with somescript. Maybe looking in the xscreensaver source code will give you ideas, too.<br /><a href="http://forums.debian.net/viewtopic.php?f=3&amp;t=124555#p591933" rel="nofollow">http://forums.debian.net/viewtopic.php? … 55#p591933</a></p>]]></description>
			<author><![CDATA[dummy@example.com (fsmithred)]]></author>
			<pubDate>Tue, 10 Oct 2017 15:20:52 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5466#p5466</guid>
		</item>
		<item>
			<title><![CDATA[How to send a signal whenever mouse button is clicked? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5464#p5464</link>
			<description><![CDATA[<p>I&#039;d like to rig my mouse so that any time I left-click, not only do I get a normal left click but also send a signal to a script.</p><p>I tried both of these in my xbindkeys, but with them I lose the ability to use the mouse click altogether (i.e., I can move the mouse but nothing happens when I click on things):</p><div class="codebox"><pre><code>&quot;xdotool click 1; pkill -USR1 somescript&quot;
  b:1 + release</code></pre></div><div class="codebox"><pre><code>&quot;xvkbd -text &quot;\m1&quot;; pkill -USR1 somescript&quot;
  b:1 + release</code></pre></div><p>I tried adding a short delay to the command. Also tried just b:1 without &quot;+ release&quot;. No luck with either.</p><p>Any ideas? I&#039;ve been going around in circles with this. A CLI solution would be preferable.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Tue, 10 Oct 2017 13:06:06 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5464#p5464</guid>
		</item>
	</channel>
</rss>
