<?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=3057&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / how to automatically get xinput id of keyboard? [SOLVED]]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=3057</link>
		<description><![CDATA[The most recent posts in how to automatically get xinput id of keyboard? [SOLVED].]]></description>
		<lastBuildDate>Mon, 07 Oct 2019 18:28:37 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=18172#p18172</link>
			<description><![CDATA[<p>Just a quick followup: I found a way to detect keyboard input without needing the keyboard id at all!</p><div class="codebox"><pre><code>$ LANG=C xinput --test-xi2 --root | awk &#039;
/RawKeyPress/ { relevant=1 }
relevant==1 &amp;&amp; /detail/ { print $2; relevant=0 }
&#039;</code></pre></div><p>The most obvious application of this is a keylogger (<a href="https://github.com/bdantas/keylogger" rel="nofollow">https://github.com/bdantas/keylogger</a>), but the keylogger itself may just be a stepping stone to something more useful (e.g., <a href="https://github.com/bdantas/iksilo)" rel="nofollow">https://github.com/bdantas/iksilo)</a>.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Mon, 07 Oct 2019 18:28:37 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=18172#p18172</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17856#p17856</link>
			<description><![CDATA[<p>I tinkered with ralph.ronnquist&#039;s solution in post #13 and figured out that this is what&#039;s actually going on when you decompress the logic:</p><div class="codebox"><pre><code>$ master_id=$(LANG=C xinput list | grep -i &#039;master keyboard&#039; | egrep -o &#039;id=[0-9]+&#039; | egrep -o &#039;[0-9]+&#039;)
$ keyboard_id=$(LANG=C xinput list $master_id | grep &#039;XIKeyClass&#039; | egrep -o &#039;[0-9]+&#039;)</code></pre></div><p>This version is easier for my pea brain to grasp.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sun, 15 Sep 2019 00:46:57 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17856#p17856</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17852#p17852</link>
			<description><![CDATA[<p>Why would you need the xinput id if you don&#039;t have xinput installed?</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 14 Sep 2019 17:45:01 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17852#p17852</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17851#p17851</link>
			<description><![CDATA[<p>That would not work on my devuan system:<br />chris@rigel:~/bin$ xinput --list<br />bash: xinput: command not found</p><p>So how can it be done without asking the user to install xinput?</p><p>Chris</p>]]></description>
			<author><![CDATA[dummy@example.com (chris2be8)]]></author>
			<pubDate>Sat, 14 Sep 2019 17:02:05 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17851#p17851</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17849#p17849</link>
			<description><![CDATA[<p>Yes, that works even on my wife&#039;s wonky hardware where multiple &quot;slave keyboards&quot; are listed. <img src="https://dev1galaxy.org/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p><div class="codebox"><pre><code>eileen@vaio:~$ xinput list --id-only | xargs -n 1 -I+ sh -c &quot;xinput list + | grep -wv + | grep XIKeyClass&quot; | egrep -o &#039;[0-9]+&#039;
12</code></pre></div><p>Wow, ralph.ronnquist. Very impressive. Thank you!</p><p>I understand the logic of the command, but don&#039;t understand how you figured out that it was the necessary logic. Will chew on it.</p><p>BTW, I had also found that nugget on stackexchange, but do not want to give users anything in addition to the shell script I&#039;ve created. The script is here if you are curious:<br /><a href="https://github.com/bdantas/iksilo" rel="nofollow">https://github.com/bdantas/iksilo</a></p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 14 Sep 2019 16:16:30 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17849#p17849</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17847#p17847</link>
			<description><![CDATA[<p>Perhaps it&#039;s important that the id of the entry is different from the id of the origin class. E.g. in post#8 above, the origin class id, 11, is the same as the id of the entry it concerns, and it should therefore be ignored. This logic could be done as:</p><div class="codebox"><pre><code>xinput list --id-only | \
    xargs -n 1 -I+ sh -c &quot;xinput list + | grep -wv + | grep XIKeyClass&quot; | \
    grep -oE &quot;[0-9]+&quot;</code></pre></div><p>I.e., in words: for each of the available ids, check the details for the id, but ignoring lines containing the id, for a <span class="bbc">XIKeyClass</span> line, and then reduce resulting lines to the number they contains. Ideally there should be only one resulting line, but if there are more... well.</p><p>Then you might want to check out <a href="https://unix.stackexchange.com/questions/89538/how-to-tell-which-keyboard-was-used-to-press-a-key" rel="nofollow">https://unix.stackexchange.com/question … ress-a-key</a> on how to &quot;really&quot; do this <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Sat, 14 Sep 2019 13:45:17 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17847#p17847</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17846#p17846</link>
			<description><![CDATA[<p>That one gives me two numbers, 13 and 12, which corrspond to:</p><div class="codebox"><pre><code>↳ Microsoft Wired Keyboard 600            	id=13	[slave  pointer  (2)]
↳ Microsoft Wired Keyboard 600            	id=12	[slave  keyboard (3)]</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (fsmithred)]]></author>
			<pubDate>Sat, 14 Sep 2019 12:55:35 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17846#p17846</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17845#p17845</link>
			<description><![CDATA[<p>Doesn&#039;t work on my wife&#039;s Sony Vaio:</p><div class="codebox"><pre><code>$ LANG=C xinput --list | grep -i keyboard | egrep -iv &#039;virtual|video|button|bus&#039;
    ↳ Sony Vaio Keys                          	id=7	[slave  keyboard (3)]
    ↳ USB 2.0 Camera: USB 2.0 Camera          	id=10	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=12	[slave  keyboard (3)]
    ↳ Sony Vaio Jogdial                       	id=14	[slave  keyboard (3)]</code></pre></div><p>This is tough.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 14 Sep 2019 11:59:35 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17845#p17845</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17843#p17843</link>
			<description><![CDATA[<p>Thank you both. I think we&#039;re getting warmer. Does this work on all your test systems?</p><div class="codebox"><pre><code>LANG=C xinput --list | grep -i keyboard | egrep -iv &#039;virtual|video|button|bus&#039; | egrep -o &#039;id=[0-9]+&#039; | egrep -o &#039;[0-9]+&#039;</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 14 Sep 2019 11:16:51 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17843#p17843</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17842#p17842</link>
			<description><![CDATA[<p>Few things kill a perfectly good theory as effectivly as does reality....</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Sat, 14 Sep 2019 10:58:56 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17842#p17842</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17840#p17840</link>
			<description><![CDATA[<p>The first line with XIKeyClass on my desktop is my mouse. On the laptop, it&#039;s Virtual Core Keyboard.</p><div class="codebox"><pre><code>⎜   ↳ Logitech USB Receiver                     id=11   [slave  pointer  (2)]
        Reporting 6 classes:
                Class originated from: 11. Type: XIButtonClass
                Buttons supported: 7
                Button labels: &quot;Button 0&quot; &quot;Button Unknown&quot; &quot;Button Unknown&quot; &quot;Button Wheel Up&quot; &quot;Button Wheel Do
wn&quot; &quot;Button Horiz Wheel Left&quot; &quot;Button Horiz Wheel Right&quot;
                Button state:
                Class originated from: 11. Type: XIKeyClass</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (fsmithred)]]></author>
			<pubDate>Sat, 14 Sep 2019 10:22:45 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17840#p17840</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17835#p17835</link>
			<description><![CDATA[<p>Perhaps it&#039;s merely incidental, or perhaps it&#039;s because it&#039;s the detail associated with the &#039;master keyboard&#039; where something in the <span class="bbc">xinput</span> code makes it a reliable feature. I did do a quick test with a couple of different hardware set ups, including a laptop with a USB keyboard, and it seemed to offer the right result for those.</p><p>It&#039;s also a guess that the label <span class="bbc">XIKeyClass</span> is a code label without i18n, and that no i18n of that detail line will morph the id number, or add any other digits into the mix.</p><p>It works while it works <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Eventually someone with direct insight into the source might pass by, to confirm or refute.</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Sat, 14 Sep 2019 03:58:49 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17835#p17835</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17833#p17833</link>
			<description><![CDATA[<p>Wow, thanks guys! </p><p>ralph.ronnquist&#039;s suggestion works in Devuan, in Tiny Core Linux (which uses BusyBox instead of coreutils), and even in OpenBSD. I modified it slightly to something that does same thing but makes more sense to me:</p><div class="codebox"><pre><code>xinput --list --long | grep XIKeyClass | head -n 1 | egrep -o &#039;[0-9]+&#039;</code></pre></div><p>There&#039;s no way I would have figured this out on my own. Thanks again, ralph. You&#039;re a wizard!</p><p>The only thing I don&#039;t understand is why the entry of interest always happens to be the first match.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 14 Sep 2019 02:04:07 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17833#p17833</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17832#p17832</link>
			<description><![CDATA[<p>Can you not just do</p><div class="codebox"><pre><code>LANG=C xinput --list --long</code></pre></div><p>Or similar?</p>]]></description>
			<author><![CDATA[dummy@example.com (bgstack15)]]></author>
			<pubDate>Sat, 14 Sep 2019 00:58:38 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17832#p17832</guid>
		</item>
		<item>
			<title><![CDATA[Re: how to automatically get xinput id of keyboard? [SOLVED]]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=17831#p17831</link>
			<description><![CDATA[<p>To avoid the language problem, I would go for using <span class="bbc">xinput --list --long</span>, and the id of the &quot;originating class&quot; from the first line with type <span class="bbc">XIKeyClass</span>. Perhaps something like the following:</p><div class="codebox"><pre><code>xinput --list --long | grep -Fwm1 XIKeyClass | egrep -oE &#039;[0-9]*&#039;</code></pre></div><p>which would allow almost any i18n of the sought line, merely expecting <span class="bbc">XIKeyClass</span> to be present, and the id being the only number on the line.</p><p>That method should find at least one of the currently available keyboards; I think it&#039;ll pick &quot;the last one&quot; if you connect additional USB or Bluetooth keyboards. Or possibly it&#039;s &quot;the last one used&quot;.</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Fri, 13 Sep 2019 23:26:21 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=17831#p17831</guid>
		</item>
	</channel>
</rss>
