{"id":5,"date":"2015-10-04T16:32:16","date_gmt":"2015-10-04T16:32:16","guid":{"rendered":"http:\/\/huckleberry.mhu.edu\/techmusings\/?p=5"},"modified":"2016-06-17T10:10:03","modified_gmt":"2016-06-17T14:10:03","slug":"using-xbindkeys-for-trackball-button-awesomeness","status":"publish","type":"post","link":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/2015\/10\/04\/using-xbindkeys-for-trackball-button-awesomeness\/","title":{"rendered":"Using xbindkeys for Trackball Button Awesomeness"},"content":{"rendered":"<h2>The Musing<\/h2>\n<p>About a year or two ago, I began using a trackball &#8211; I said I would never use a trackball, but whatever. Specifically, I began using the <a href=\"http:\/\/www.logitech.com\/en-us\/product\/wireless-trackball-m570\" target=\"_blank\">Logitech M570<\/a>. It took a while to get used to it, but after the initial break-in period, I&#8217;m pretty good with it.<\/p>\n<p>I use <a href=\"http:\/\/synergy-project.org\/\" target=\"_blank\">synergy<\/a> (I donate &#8211; you should, too) to manage multiple computers from my M570 and <a href=\"https:\/\/www.microsoft.com\/hardware\/en-us\/p\/natural-ergonomic-keyboard-4000\" target=\"_blank\">Microsoft Natural Keyboard 4000<\/a> (I&#8217;ve been hooked on the curved keyboard for a decade and a half, now), but I never utilized the extra buttons on the M570.<\/p>\n<p>To minimize jumping back and forth from the keyboard to the trackball, I went on a mission to both distract myself from work, and also conquer this <em>most<\/em> important problem.<\/p>\n<p>After some quick Googling about how to map mouse buttons in Fedora 21, I came across a few sites like <a href=\"http:\/\/blog.hanschen.org\/2009\/10\/13\/mouse-shortcuts-with-xbindkeys\/\" target=\"_blank\">this one<\/a> and <a href=\"http:\/\/billauer.co.il\/blog\/2011\/11\/mouse-buttons-binding-copy-paste\/\" target=\"_blank\">this one<\/a>. It looked like it was possible using <em>xte<\/em> from <em>xautomation<\/em>, <em>xev <\/em>from<em> xorg-x11-utils<\/em>, and <em>xbindkeys<\/em>.<\/p>\n<p>I used <em>dnf<\/em> to install those packages, then I used <em>xev<\/em> to find out the IDs of my trackball buttons (mine were 8 and 9). I decided to map those buttons to the <strong>Home<\/strong> and <strong>End<\/strong> keys, but when coupled with the Ctrl key, they would act like <strong>Ctrl-Page Up<\/strong> and <strong>Ctrl-Page Down<\/strong>.<\/p>\n<h2>Why those keys?<\/h2>\n<p>I chose Home and End, because the trackball wheel conquers Page Up\/Down pretty well in a browser or terminal window, but sometimes I want to go to the top\/bottom of a long page quickly; Home\/End send like a logical choice.<\/p>\n<p>I use Ctrl-Page Up\/Down to switch tabs in gnome-terminal and Firefox, so having that ability without switching my right hand to the keyboard seemed to make sense.<\/p>\n<h2>The Fix<\/h2>\n<p>First, I installed the necessary packages on Fedora with<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">sudo dnf -y install xbindkeys xautomation<\/pre>\n<p>I generated the defaults .xbindkeysrc file with<\/p>\n<pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">xbindkeys --defaults &gt; $HOME\/.xbindkeysrc<\/pre>\n<p>then commented out all of those lines and added this:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n# Page Down\r\n&quot;xte 'keydown Home' 'keyup Home'&quot;\r\nb:9\r\n\r\n# Page Up\r\n&quot;xte 'keydown End' 'keyup End'&quot;\r\nb:8\r\n\r\n# Toggle tabs left\r\n&quot;xte 'keydown Page_Up' 'keyup Page_Up'&quot;\r\ncontrol + b:9\r\n\r\n# Toggle tabs right\r\n&quot;xte 'keydown Page_Down' 'keyup Page_Down'&quot;\r\ncontrol + b:8\r\n\r\n<\/pre>\n<p>I started <em>xbindkeys<\/em> and it worked! Not the first time of course, but when does that ever happen? I had to tweak a bit to get the above additions to <em>.xbindkeysrc<\/em>.<\/p>\n<p>Then I wanted to make sure that <em>xbindkeys<\/em> started on boot &#8211; that was harder than I imagined. I used the gnome-tweak-tool to add the application to startup, after adding a <em>xbindkeys.desktop<\/em> file to <em>~\/.config\/autostart\/<\/em>. It looks like:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n&#x5B;Desktop Entry]\r\nName=xbindkeys\r\nGenericName=xbindkeys\r\nComment=Start these up at login\r\nExec=\/usr\/bin\/xbindkeys\r\nTerminal=False\r\nType=Application\r\nX-GNOME-Autostart-enabled=true\r\n<\/pre>\n<p>And that was it! Not a big task, but &#8211; if I can train myself to use them &#8211; could prove to be a time saver and increase my productivity. Of course, not spending an hour or so implementing this fix might&#8217;ve improved my productivity, too!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Musing About a year or two ago, I began using a trackball &#8211; I said I would never use a trackball, but whatever. Specifically, I began using the Logitech M570. It took a while to get used to it, but after the initial break-in period, I&#8217;m pretty good with it. I use synergy (I donate &#8211; you should, too)&hellip; <a href=\"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/2015\/10\/04\/using-xbindkeys-for-trackball-button-awesomeness\/\">More &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-5","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/posts\/5","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":17,"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":49,"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/posts\/5\/revisions\/49"}],"wp:attachment":[{"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huckleberry.mhu.edu\/randommusings\/index.php\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}