|
@@ -36,6 +36,50 @@
|
|
|
<main id="content" role="main">
|
|
|
<div class="postindex">
|
|
|
|
|
|
+ <article class="h-entry post-text" itemscope itemtype="http://schema.org/Blog">
|
|
|
+ <header>
|
|
|
+ <h1 class="p-name entry-title" itemprop="headline">
|
|
|
+ <a href="/posts/console-keymap-switching.html" class="u-url">Console Keymap Switching</a>
|
|
|
+ </h1>
|
|
|
+ </header>
|
|
|
+ <div class="e-content entry-content">
|
|
|
+ <p>At the office, we have some people who use DVORAK. Normally, this isn’t a problem. To each his own after all. It does become a bit problematic though, when we’re dealing with the servers around the office.</p>
|
|
|
+<p>We normally leave the servers on QWERTY. After all, most people start off as QWERTY typists and migrate to something else. That said, it’s apparently difficult to stay fluent in both. People tend to forget how to type in QWERTY once they learn DVORAK or something else. While it is true that they can just look a the keyboard while typing, my coworkers would prefer it to just be in DVORAK.</p>
|
|
|
+<p>For the console, they’d typically do <code>sudo loadkeys dvorak</code> after logging in. The problem with this is, after they logout, the keymapping is still on DVORAK. This has been quite annoying for a few times since I can’t even login to change the keymap. What I wanted was something like you get in the graphical login screens where you can pick your keymap before logging in. Apparently, there isn’t a readily available thing for the console.</p>
|
|
|
+<p>I googled around for solutions and came across <a href="http://superuser.com/questions/548234/how-can-i-easily-toggle-between-dvorak-and-qwerty-keyboard-layouts-from-a-linux">a nice idea</a>. You could alias <code>asdf</code> to load the DVORAK mapping and <code>aoeu</code> (the equivalent to asdf in DVORAK) to load the QWERTY mapping. This actually makes sense since you don’t really have to know where the letters are. The only problem is, you once again have to be logged in to change the key mappings.</p>
|
|
|
+<p>After some further searching, I found <a href="http://unix.stackexchange.com/questions/2884/toggle-between-dvorak-and-qwerty">something close to what I wanted</a>. Apparently, Alt+Up sends a KeyboardSignal keycode to the init process, which can act on that. It also works anywhere, even before being logged in. For SysVinit systems, you can just add a line to your inittab for a command to be run when Alt+Up is pressed.</p>
|
|
|
+<p>In the office, however, we generally use Arch Linux which uses SystemD. But apparently, it also has a mechanism of accepting the Alt+Up press. It runs the kbrequest target whenever it gets the keypress. <code>kbrequest.target</code> is normally aliased to run the rescue service though, so you have to manually create the file in <code>/etc/systemd/system/kbrequest.target</code> and fill it with a description:</p>
|
|
|
+<div class="highlight"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ini" data-lang="ini"><span style="color:#fff;font-weight:bold">[Unit]</span>
|
|
|
+<span style="color:#007f7f">Description</span>=<span style="color:#0ff;font-weight:bold">kbrequest target</span>
|
|
|
+</code></pre></div><p>We can then add a service to be run whenever the target is called. Something like <code>/etc/systemd/system/keymap-switch.service</code>:</p>
|
|
|
+<div class="highlight"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-ini" data-lang="ini"><span style="color:#fff;font-weight:bold">[Unit]</span>
|
|
|
+<span style="color:#007f7f">Description</span>=<span style="color:#0ff;font-weight:bold">Keymap Switch Service</span>
|
|
|
+
|
|
|
+<span style="color:#fff;font-weight:bold">[Service]</span>
|
|
|
+<span style="color:#007f7f">Type</span>=<span style="color:#0ff;font-weight:bold">oneshot</span>
|
|
|
+<span style="color:#007f7f">ExecStart</span>=<span style="color:#0ff;font-weight:bold">/usr/local/bin/keymap-switch</span>
|
|
|
+
|
|
|
+<span style="color:#fff;font-weight:bold">[Install]</span>
|
|
|
+<span style="color:#007f7f">WantedBy</span>=<span style="color:#0ff;font-weight:bold">kbrequest.target</span>
|
|
|
+</code></pre></div><p>After enabling said service, we only need the actual keymap switcher, <code>/usr/local/bin/keymap-switch</code>. The StackOverflow answer provides different ways of detecting the current keymap so we know which one to switch to. Since we’re using SystemD, we can use that instead for managing which keymap we’re actually using. It stores the current settings inside <code>/etc/vconsole.conf</code>. We can also then switch keymaps by using <code>localectl set-keymap</code>.</p>
|
|
|
+<div class="highlight"><pre tabindex="0" style="color:#e5e5e5;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-sh" data-lang="sh"><span style="color:#0f0;font-weight:bold">#!/bin/sh
|
|
|
+</span><span style="color:#0f0;font-weight:bold"></span><span style="color:#fff;font-weight:bold">source</span> /etc/vconsole.conf
|
|
|
+
|
|
|
+<span style="color:#fff;font-weight:bold">if</span> [ <span style="color:#0ff;font-weight:bold">"</span>$TERM<span style="color:#0ff;font-weight:bold">"</span> = <span style="color:#0ff;font-weight:bold">"dumb"</span> ]; <span style="color:#fff;font-weight:bold">then</span>
|
|
|
+ <span style="color:#fff;font-weight:bold">if</span> [ <span style="color:#0ff;font-weight:bold">"</span>$KEYMAP<span style="color:#0ff;font-weight:bold">"</span> = <span style="color:#0ff;font-weight:bold">"dvorak"</span> ]; <span style="color:#fff;font-weight:bold">then</span>
|
|
|
+ localectl set-keymap us
|
|
|
+ <span style="color:#fff;font-weight:bold">else</span>
|
|
|
+ localectl set-keymap dvorak
|
|
|
+ <span style="color:#fff;font-weight:bold">fi</span>
|
|
|
+<span style="color:#fff;font-weight:bold">fi</span>
|
|
|
+</code></pre></div><p>After putting it all together, it works! We can switch keymaps on the fly by simply pressing Alt+Up.</p>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <small class="dateline">Posted: <time class="published dt-published" itemprop="datePublished" datetime="2013-10-29">2013-10-29</time></small>
|
|
|
+ | <small class="commentline"><a href="/posts/console-keymap-switching.html#isso-thread">Comments</a></small>
|
|
|
+ </article>
|
|
|
+ </article>
|
|
|
+
|
|
|
<article class="h-entry post-text" itemscope itemtype="http://schema.org/Blog">
|
|
|
<header>
|
|
|
<h1 class="p-name entry-title" itemprop="headline">
|
|
@@ -129,26 +173,6 @@ sed -i .bak <span style="color:#0ff;font-weight:bold">'/^72/ s/,600/,60/'
|
|
|
</article>
|
|
|
</article>
|
|
|
|
|
|
- <article class="h-entry post-text" itemscope itemtype="http://schema.org/Blog">
|
|
|
- <header>
|
|
|
- <h1 class="p-name entry-title" itemprop="headline">
|
|
|
- <a href="/posts/graphserver.html" class="u-url">GraphServer</a>
|
|
|
- </h1>
|
|
|
- </header>
|
|
|
- <div class="e-content entry-content">
|
|
|
- <p>Link: <a href="http://graphserver.github.io/graphserver/">http://graphserver.github.io/graphserver/</a></p>
|
|
|
-<p>One other routing webapp I saw was GraphServer. It’s actually more of a general purpose Graph library which supports GTFS and OSM data than an actual dedicated routing software like OpenTripPlanner. It’s also based off python and C instead of Java, so it feels a lot less heavy.</p>
|
|
|
-<p>The instructions on the website are already pretty good. There are just some minor errors with it. Where it says <code>gs_gtfsdb_build</code>, you should actually use <code>gs_gtfsdb_compile</code>. Also, when running <code>gs_osmdb_compile</code> you might need to use <code>-t</code> for tolerant in case you follow the instructions on chopping up the original OSM data.</p>
|
|
|
-<p>A nice suggestion from the GraphServer instructions was to crop the OSM data to minimize the graph size. This is actually quite helpful if you downloaded the entire Philippine OSM dump. It reduced the original 900MB file to 135MB which was a lot more workable. I did hit a problem with their instructions though. The linked version of osmosis is an old one, which doesn’t support 64-bit ids. The <a href="http://wiki.openstreetmap.org/wiki/Osmosis">latest version of Osmosis</a> easily did the job though.</p>
|
|
|
-<p>The actual routing though, was not exactly good. I only tried one route which should normally take 1-2 transfers, it suggested a route which involved 4+ transfers. It also didn’t provide any alternate routes aside from that one. I’m not sure if it’s a limitation of the provided routeserver, but I didn’t bother checking if it supported parameters which might provide better routes.</p>
|
|
|
-<p>I think graphserver could be useful, but it seems more involved than say OpenTripPlanner. There do seem to be people who use graphserver for their routing apps, but for the bounds of the contest, or just as a side project, it might require too much effort.</p>
|
|
|
-
|
|
|
- </div>
|
|
|
- <small class="dateline">Posted: <time class="published dt-published" itemprop="datePublished" datetime="2013-07-23">2013-07-23</time></small>
|
|
|
- | <small class="commentline"><a href="/posts/graphserver.html#isso-thread">Comments</a></small>
|
|
|
- </article>
|
|
|
- </article>
|
|
|
-
|
|
|
</div>
|
|
|
<nav class="postindexpager">
|
|
|
<ul class="pager clearfix">
|