Browse Source

Add keymap post

Thomas Dy 11 years ago
parent
commit
60fc9f0ae1

+ 4 - 2
output/assets/css/theme.css

@@ -47,6 +47,8 @@ a {
 code, pre {
 	font-family: Monaco, Menlo, Consolas, monospace;
 	font-size: 75%;
+	hyphens: none;
+	-moz-hyphens: none;
 }
 
 code {
@@ -263,7 +265,7 @@ header {
 	-webkit-perspective: 800;
 	   -moz-perspective: 800;
 		-ms-perspective: 800;
-			perspective: 800;			
+			perspective: 800;
 }
 
 .thomas {
@@ -283,7 +285,7 @@ header {
 	-webkit-transform: rotateY(180deg);
 	   -moz-transform: rotateY(180deg);
 		-ms-transform: rotateY(180deg);
-			transform: rotateY(180deg);		
+			transform: rotateY(180deg);
 }
 
 .thomas img:nth-child(2) {

+ 1 - 1
output/assets/js/tag_cloud_data.json

@@ -1 +1 @@
-{"programming": [12, "/categories/programming.html"], "lets-debug": [1, "/categories/lets-debug.html"], "philippine-transit-app": [12, "/categories/philippine-transit-app.html"]}
+{"sysadmin": [1, "/categories/sysadmin.html"], "programming": [12, "/categories/programming.html"], "systemd": [1, "/categories/systemd.html"], "philippine-transit-app": [12, "/categories/philippine-transit-app.html"], "lets-debug": [1, "/categories/lets-debug.html"]}

+ 2 - 0
output/categories/index.html

@@ -54,6 +54,8 @@
             <li><a class="tag" href="lets-debug.html"><span class="badge badge-info">lets-debug</span></a>
             </li><li><a class="tag" href="philippine-transit-app.html"><span class="badge badge-info">philippine-transit-app</span></a>
             </li><li><a class="tag" href="programming.html"><span class="badge badge-info">programming</span></a>
+            </li><li><a class="tag" href="sysadmin.html"><span class="badge badge-info">sysadmin</span></a>
+            </li><li><a class="tag" href="systemd.html"><span class="badge badge-info">systemd</span></a>
         </li></ul>
         <!--End of body content-->
     </div>

+ 1 - 1
output/categories/lets-debug.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer (lets-debug)</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/categories/lets-debug.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 19:52:16 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>GTFS Editor</title><link>http://pleasantprogrammer.com/posts/gtfs-editor.html</link><description>&lt;p&gt;Link: &lt;a href="https://github.com/conveyal/gtfs-editor"&gt;https://github.com/conveyal/gtfs-editor&lt;/a&gt;&lt;/p&gt;
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer (lets-debug)</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/categories/lets-debug.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 20:15:11 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>GTFS Editor</title><link>http://pleasantprogrammer.com/posts/gtfs-editor.html</link><description>&lt;p&gt;Link: &lt;a href="https://github.com/conveyal/gtfs-editor"&gt;https://github.com/conveyal/gtfs-editor&lt;/a&gt;&lt;/p&gt;
 &lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; they really meant under development&lt;/p&gt;
 &lt;p&gt;When I first saw the source of GTFS Editor, I was ecstatic. They used &lt;a href="http://playframework.com/"&gt;Play framework&lt;/a&gt;!!! Not only that, they're targeting PostgreSQL as the main database. Those are our favorite tools for building webapps at By Implication. I was a bit sad though, when I saw it was on the 1.x release of Play though. I did have some experience with that release, but not as much compared to 2.x.&lt;/p&gt;
 &lt;p&gt;Getting it to actually run though, wasn't very pleasant. The initial setup was easy enough. Get &lt;a href="http://www.playframework.com/download"&gt;Play 1.2.5&lt;/a&gt;, install Postgres with PostGIS, clone the repo and create backing database in Postgres. Some minor additional steps you need are to create the PostGIS extension on the database. The schema is automatically generated and applied by Play so that should be all that's necessary. Wonderful. Then, run play, open a browser, go to &lt;a href="http://localhost:9000"&gt;http://localhost:9000&lt;/a&gt;, compilation error. Fantastic.&lt;/p&gt;

+ 1 - 1
output/categories/philippine-transit-app.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer (philippine-transit-app)</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/categories/philippine-transit-app.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 19:52:16 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Geocoding Services</title><link>http://pleasantprogrammer.com/posts/geocoding-services.html</link><description>&lt;p&gt;A key component for any routing service is being able to do geocoding. Most people who are looking for routes most probably don't know exactly where their start and end points are on the map. Even then, manually looking for a location on a map is a time-consuming task.&lt;/p&gt;
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer (philippine-transit-app)</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/categories/philippine-transit-app.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 20:15:11 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Geocoding Services</title><link>http://pleasantprogrammer.com/posts/geocoding-services.html</link><description>&lt;p&gt;A key component for any routing service is being able to do geocoding. Most people who are looking for routes most probably don't know exactly where their start and end points are on the map. Even then, manually looking for a location on a map is a time-consuming task.&lt;/p&gt;
 &lt;p&gt;The gold standard for doing geocoding right now is Google Maps. It's hard to find a better location search experience. If they actually provided routing for jeeps here in the Philippines, I imagine there wouldn't be &lt;em&gt;that&lt;/em&gt; much you could do for the competition.&lt;/p&gt;
 &lt;p&gt;When the competition started though, I took it as a challenge to avoid Google Maps as much as possible. I wanted to see how much is currently possible with other options such as OpenStreetMap. In fact, OSM does have a geocoding service called &lt;a href="http://nominatim.openstreetmap.org"&gt;Nominatim&lt;/a&gt;.&lt;/p&gt;
 &lt;p&gt;Sadly, for a mapping app, what you want to do is not simply just geocoding. With geocoding, you take an address and turn it into coordinates. When you want to search for a place in a mapping app, you take part of an address, infer the rest of it, and give the user options to choose from.&lt;/p&gt;

+ 1 - 1
output/categories/programming.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer (programming)</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/categories/programming.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 19:52:16 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Geocoding Services</title><link>http://pleasantprogrammer.com/posts/geocoding-services.html</link><description>&lt;p&gt;A key component for any routing service is being able to do geocoding. Most people who are looking for routes most probably don't know exactly where their start and end points are on the map. Even then, manually looking for a location on a map is a time-consuming task.&lt;/p&gt;
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer (programming)</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/categories/programming.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 20:15:11 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Geocoding Services</title><link>http://pleasantprogrammer.com/posts/geocoding-services.html</link><description>&lt;p&gt;A key component for any routing service is being able to do geocoding. Most people who are looking for routes most probably don't know exactly where their start and end points are on the map. Even then, manually looking for a location on a map is a time-consuming task.&lt;/p&gt;
 &lt;p&gt;The gold standard for doing geocoding right now is Google Maps. It's hard to find a better location search experience. If they actually provided routing for jeeps here in the Philippines, I imagine there wouldn't be &lt;em&gt;that&lt;/em&gt; much you could do for the competition.&lt;/p&gt;
 &lt;p&gt;When the competition started though, I took it as a challenge to avoid Google Maps as much as possible. I wanted to see how much is currently possible with other options such as OpenStreetMap. In fact, OSM does have a geocoding service called &lt;a href="http://nominatim.openstreetmap.org"&gt;Nominatim&lt;/a&gt;.&lt;/p&gt;
 &lt;p&gt;Sadly, for a mapping app, what you want to do is not simply just geocoding. With geocoding, you take an address and turn it into coordinates. When you want to search for a place in a mapping app, you take part of an address, infer the rest of it, and give the user options to choose from.&lt;/p&gt;

+ 83 - 0
output/categories/sysadmin.html

@@ -0,0 +1,83 @@
+<!DOCTYPE html><html lang="en">
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    
+    <meta charset="utf-8">
+    <meta name="description" content="">
+    <meta name="author" content="Thomas Dy">
+    <title>Posts about sysadmin | Pleasant Programmer</title>
+    
+        <link href="../assets/css/rst.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/code.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/colorbox.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/theme.css" rel="stylesheet" type="text/css">
+    <script type="text/javascript" src="//use.typekit.net/iwm5axp.js"></script>
+    <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
+    <!--[if lt IE 9]>
+      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
+    <![endif]-->
+            <link rel="alternate" type="application/rss+xml" title="RSS (en)" href="../rss.xml">
+
+    
+            <link rel="alternate" type="application/rss+xml" title="RSS for tag sysadmin (en)" href="sysadmin.xml">
+
+    
+</head>
+<body>
+    <header>
+        <a href="../" title="Pleasant Programmer">
+            <div class="thomas">
+                <img src="../assets/img/thomas.gif" alt="DJ THOMAS IN DA HAUS">
+                <img src="../assets/img/thomas.png" alt="Pleasant Programmer">
+            </div>
+            <h1 id="blog-title">
+                Pleasant Programmer
+            </h1>
+        </a>
+        <ul class="nav">
+            <li class="twitter"><a href="http://twitter.com/pleasantprog">@pleasantprog</a></li>
+            
+            <li><a href="../archive.html">Archives</a>
+            </li><li><a href="index.html">Tags</a>
+            </li><li><a href="../rss.xml">RSS</a>
+
+        </li></ul>
+        
+        
+    </header>
+    <div class="container">
+        <div class="content">
+            
+        <!--Body content-->
+        <div class="postbox">
+        <h1>Posts about sysadmin</h1>
+        <ul class="unstyled">
+            <li><a href="../posts/console-keymap-switching.html">[2013-10-29 20:02] Console Keymap Switching</a>
+        </li></ul>
+        </div>
+        <!--End of body content-->
+
+        </div>
+    </div>
+    <footer>
+        <small><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="CC-BY-SA" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png"></a> © 2013 Thomas Dy - Powered by <a href="http://nikola.ralsina.com.ar">Nikola</a></small>
+        <script src="../assets/js/konami.js"></script>
+        <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
+        <script>
+            var easter_egg = new Konami();
+            easter_egg.code = function() { 
+                $(".thomas").toggleClass("whoa");
+                $("body").scrollTop(0);
+            }
+            easter_egg.load();
+
+            // love you, thomas!
+            // yours, @_phi + @meggykawsek
+        </script>
+    </footer>
+
+
+    <script type="text/javascript">var addthis_config={"ui_language":"en"};</script>
+    
+</body>
+</html>

+ 49 - 0
output/categories/sysadmin.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer (sysadmin)</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/categories/sysadmin.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 20:38:49 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Console Keymap Switching</title><link>http://pleasantprogrammer.com/posts/console-keymap-switching.html</link><description>&lt;p&gt;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.&lt;/p&gt;
+&lt;p&gt;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.&lt;/p&gt;
+&lt;p&gt;For the console, they'd typically do &lt;code&gt;sudo loadkeys dvorak&lt;/code&gt; 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.&lt;/p&gt;
+&lt;p&gt;I googled around for solutions and came across &lt;a href="http://superuser.com/questions/548234/how-can-i-easily-toggle-between-dvorak-and-qwerty-keyboard-layouts-from-a-linux"&gt;a nice idea&lt;/a&gt;. You could alias &lt;code&gt;asdf&lt;/code&gt; to load the DVORAK mapping and &lt;code&gt;aoeu&lt;/code&gt; (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.&lt;/p&gt;
+&lt;p&gt;After some further searching, I found &lt;a href="http://unix.stackexchange.com/questions/2884/toggle-between-dvorak-and-qwerty"&gt;something close to what I wanted&lt;/a&gt;. 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.&lt;/p&gt;
+&lt;p&gt;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. &lt;code&gt;kbrequest.target&lt;/code&gt; is normally aliased to run the rescue service though, so you have to manually create the file in &lt;code&gt;/etc/systemd/system/kbrequest.target&lt;/code&gt; and fill it with a description:&lt;/p&gt;
+&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="k"&gt;[Unit]&lt;/span&gt;
+&lt;span class="na"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;kbrequest target&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+
+
+&lt;p&gt;We can then add a service to be run whenever the target is called. Something like &lt;code&gt;/etc/systemd/system/keymap-switch.service&lt;/code&gt;:&lt;/p&gt;
+&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="k"&gt;[Unit]&lt;/span&gt;
+&lt;span class="na"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;Keymap Switch Service&lt;/span&gt;
+
+&lt;span class="k"&gt;[Service]&lt;/span&gt;
+&lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;oneshot&lt;/span&gt;
+&lt;span class="na"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/usr/local/bin/keymap-switch&lt;/span&gt;
+
+&lt;span class="k"&gt;[Install]&lt;/span&gt;
+&lt;span class="na"&gt;WantedBy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;kbrequest.target&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+
+
+&lt;p&gt;After enabling said service, we only need the actual keymap switcher, &lt;code&gt;/usr/local/bin/keymap-switch&lt;/code&gt;. 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 &lt;code&gt;/etc/vconsole.conf&lt;/code&gt;. We can also then switch keymaps by using &lt;code&gt;localectl set-keymap&lt;/code&gt;.&lt;/p&gt;
+&lt;table class="codehilitetable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
+&lt;span class="nb"&gt;source&lt;/span&gt; /etc/vconsole.conf
+
+&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$TERM"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"dumb"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;; &lt;span class="k"&gt;then&lt;/span&gt;
+&lt;span class="k"&gt;  if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$KEYMAP"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"dvorak"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;; &lt;span class="k"&gt;then&lt;/span&gt;
+&lt;span class="k"&gt;    &lt;/span&gt;localectl &lt;span class="nb"&gt;set&lt;/span&gt;-keymap us
+  &lt;span class="k"&gt;else&lt;/span&gt;
+&lt;span class="k"&gt;    &lt;/span&gt;localectl &lt;span class="nb"&gt;set&lt;/span&gt;-keymap dvorak
+  &lt;span class="k"&gt;fi&lt;/span&gt;
+&lt;span class="k"&gt;fi&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
+
+&lt;p&gt;After putting it all together, it works! We can switch keymaps on the fly by simply pressing Alt+Up.&lt;/p&gt;</description><author></author><category>sysadmin</category><category>systemd</category><guid>http://pleasantprogrammer.com/posts/console-keymap-switching.html</guid><pubDate>Tue, 29 Oct 2013 12:02:06 GMT</pubDate></item></channel></rss>

+ 83 - 0
output/categories/systemd.html

@@ -0,0 +1,83 @@
+<!DOCTYPE html><html lang="en">
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    
+    <meta charset="utf-8">
+    <meta name="description" content="">
+    <meta name="author" content="Thomas Dy">
+    <title>Posts about systemd | Pleasant Programmer</title>
+    
+        <link href="../assets/css/rst.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/code.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/colorbox.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/theme.css" rel="stylesheet" type="text/css">
+    <script type="text/javascript" src="//use.typekit.net/iwm5axp.js"></script>
+    <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
+    <!--[if lt IE 9]>
+      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
+    <![endif]-->
+            <link rel="alternate" type="application/rss+xml" title="RSS (en)" href="../rss.xml">
+
+    
+            <link rel="alternate" type="application/rss+xml" title="RSS for tag systemd (en)" href="systemd.xml">
+
+    
+</head>
+<body>
+    <header>
+        <a href="../" title="Pleasant Programmer">
+            <div class="thomas">
+                <img src="../assets/img/thomas.gif" alt="DJ THOMAS IN DA HAUS">
+                <img src="../assets/img/thomas.png" alt="Pleasant Programmer">
+            </div>
+            <h1 id="blog-title">
+                Pleasant Programmer
+            </h1>
+        </a>
+        <ul class="nav">
+            <li class="twitter"><a href="http://twitter.com/pleasantprog">@pleasantprog</a></li>
+            
+            <li><a href="../archive.html">Archives</a>
+            </li><li><a href="index.html">Tags</a>
+            </li><li><a href="../rss.xml">RSS</a>
+
+        </li></ul>
+        
+        
+    </header>
+    <div class="container">
+        <div class="content">
+            
+        <!--Body content-->
+        <div class="postbox">
+        <h1>Posts about systemd</h1>
+        <ul class="unstyled">
+            <li><a href="../posts/console-keymap-switching.html">[2013-10-29 20:02] Console Keymap Switching</a>
+        </li></ul>
+        </div>
+        <!--End of body content-->
+
+        </div>
+    </div>
+    <footer>
+        <small><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="CC-BY-SA" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png"></a> © 2013 Thomas Dy - Powered by <a href="http://nikola.ralsina.com.ar">Nikola</a></small>
+        <script src="../assets/js/konami.js"></script>
+        <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
+        <script>
+            var easter_egg = new Konami();
+            easter_egg.code = function() { 
+                $(".thomas").toggleClass("whoa");
+                $("body").scrollTop(0);
+            }
+            easter_egg.load();
+
+            // love you, thomas!
+            // yours, @_phi + @meggykawsek
+        </script>
+    </footer>
+
+
+    <script type="text/javascript">var addthis_config={"ui_language":"en"};</script>
+    
+</body>
+</html>

+ 49 - 0
output/categories/systemd.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer (systemd)</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/categories/systemd.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 20:38:49 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Console Keymap Switching</title><link>http://pleasantprogrammer.com/posts/console-keymap-switching.html</link><description>&lt;p&gt;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.&lt;/p&gt;
+&lt;p&gt;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.&lt;/p&gt;
+&lt;p&gt;For the console, they'd typically do &lt;code&gt;sudo loadkeys dvorak&lt;/code&gt; 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.&lt;/p&gt;
+&lt;p&gt;I googled around for solutions and came across &lt;a href="http://superuser.com/questions/548234/how-can-i-easily-toggle-between-dvorak-and-qwerty-keyboard-layouts-from-a-linux"&gt;a nice idea&lt;/a&gt;. You could alias &lt;code&gt;asdf&lt;/code&gt; to load the DVORAK mapping and &lt;code&gt;aoeu&lt;/code&gt; (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.&lt;/p&gt;
+&lt;p&gt;After some further searching, I found &lt;a href="http://unix.stackexchange.com/questions/2884/toggle-between-dvorak-and-qwerty"&gt;something close to what I wanted&lt;/a&gt;. 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.&lt;/p&gt;
+&lt;p&gt;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. &lt;code&gt;kbrequest.target&lt;/code&gt; is normally aliased to run the rescue service though, so you have to manually create the file in &lt;code&gt;/etc/systemd/system/kbrequest.target&lt;/code&gt; and fill it with a description:&lt;/p&gt;
+&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="k"&gt;[Unit]&lt;/span&gt;
+&lt;span class="na"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;kbrequest target&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+
+
+&lt;p&gt;We can then add a service to be run whenever the target is called. Something like &lt;code&gt;/etc/systemd/system/keymap-switch.service&lt;/code&gt;:&lt;/p&gt;
+&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="k"&gt;[Unit]&lt;/span&gt;
+&lt;span class="na"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;Keymap Switch Service&lt;/span&gt;
+
+&lt;span class="k"&gt;[Service]&lt;/span&gt;
+&lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;oneshot&lt;/span&gt;
+&lt;span class="na"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/usr/local/bin/keymap-switch&lt;/span&gt;
+
+&lt;span class="k"&gt;[Install]&lt;/span&gt;
+&lt;span class="na"&gt;WantedBy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;kbrequest.target&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+
+
+&lt;p&gt;After enabling said service, we only need the actual keymap switcher, &lt;code&gt;/usr/local/bin/keymap-switch&lt;/code&gt;. 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 &lt;code&gt;/etc/vconsole.conf&lt;/code&gt;. We can also then switch keymaps by using &lt;code&gt;localectl set-keymap&lt;/code&gt;.&lt;/p&gt;
+&lt;table class="codehilitetable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
+&lt;span class="nb"&gt;source&lt;/span&gt; /etc/vconsole.conf
+
+&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$TERM"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"dumb"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;; &lt;span class="k"&gt;then&lt;/span&gt;
+&lt;span class="k"&gt;  if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$KEYMAP"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"dvorak"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;; &lt;span class="k"&gt;then&lt;/span&gt;
+&lt;span class="k"&gt;    &lt;/span&gt;localectl &lt;span class="nb"&gt;set&lt;/span&gt;-keymap us
+  &lt;span class="k"&gt;else&lt;/span&gt;
+&lt;span class="k"&gt;    &lt;/span&gt;localectl &lt;span class="nb"&gt;set&lt;/span&gt;-keymap dvorak
+  &lt;span class="k"&gt;fi&lt;/span&gt;
+&lt;span class="k"&gt;fi&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
+
+&lt;p&gt;After putting it all together, it works! We can switch keymaps on the fly by simply pressing Alt+Up.&lt;/p&gt;</description><author></author><category>sysadmin</category><category>systemd</category><guid>http://pleasantprogrammer.com/posts/console-keymap-switching.html</guid><pubDate>Tue, 29 Oct 2013 12:02:06 GMT</pubDate></item></channel></rss>

+ 24 - 0
output/index-1.html

@@ -47,6 +47,30 @@
     <div class="container">
         <div class="content">
             
+        <div class="postbox">
+        <div class="title">
+            <h1><a href="posts/one-bus-or-maybe-jeep-away.html">One Bus (or maybe Jeep) Away</a>
+            <small>
+                 Posted: 2013-07-09 01:53
+            </small></h1>
+        </div>
+        <p>Link: <a href="http://onebusaway.org/">http://onebusaway.org/</a></p>
+<p><strong>TL;DR</strong> no routing; useless in Philippines</p>
+<p>OneBusAway is a transit information app. It provides data on what bus stops are near you, which buses pass by. You can also get schedules and the route of a particular bus given the number. It can also provide realtime updates like how many minutes until the next bus arrives. It does not, however, provide routing. There is no support for providing directions to get from point A to point B.</p>
+<p>It's comparable to what you get in some bus stops abroad. You'd get a vicinity map and a list of buses passing through the stop. You might also get the times when the next buses will pass. It's useful for locals who already know how to get around, and want to avoid waiting for the bus. But it's not particularly good for people who want to know how to get around the city.</p>
+<p>OneBusAway is quite comprehensive in its platform support though. There is a webapp, apps for iOS, Android and Windows Phone, as well as SMS and Voice support. This would all be nice but we don't have the necessary infrastructure yet in the Philippines. We don't have bus or jeepney stops. We also wouldn't have realtime data to make the app particularly useful.</p>
+<p>You can try it out for yourself by following their <a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/OneBusAway-Quickstart-Guide">Quickstart Guide</a>. One caveat is you will have to add <code>-P tripEntriesFactory.throwExceptionOnInvalidStopToShapeMappingException=false</code> when building the bundle. This has to do with the OneBusAway having difficulty matching the <a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/Stop-to-Shape-Matching">stops to the shape data</a>.</p>
+<p>Here's some screenshots of the app with the Philippine data. Notice how you only see the stops but there isn't a line for the route. This is a problem with our GTFS data. Also, at some points it's hard to tell where the jeep is going to pass since there isn't any indication of order either. This is more of a OneBusAway problem. It usually expects there to be shape data available.</p>
+<p><a href="galleries/transit/onebusaway1.png"><img alt="OneBusAway" src="galleries/transit/onebusaway1.png" title="All the stops along Katipunan Avenue are named Katipunan Avenue."></a></p>
+<p>It doesn't really handle too many routes passing through a stop. The list just overflows past the bubble. You can still actually read it by panning the map. It's just a bit weird though.</p>
+<p>If you also noticed, there are usually 2 of each route. This is how the jeepney data was modeled as jeep routes might be different going one way and going back. This isn't the case for all jeeps though, so it might also be an implementation issue with the GTFS editor.</p>
+<p><a href="galleries/transit/onebusaway2.png"><img alt="OneBusAway" src="galleries/transit/onebusaway2.png"></a></p>
+<p><a href="galleries/transit/onebusaway3.png"><img alt="OneBusAway" src="galleries/transit/onebusaway3.png"></a></p>
+            
+    <p>
+        <a href="posts/one-bus-or-maybe-jeep-away.html#disqus_thread" data-disqus-identifier="cache/posts/one-bus-or-maybe-jeep-away.html">Comments</a>
+
+        </p></div>
         <div class="postbox">
         <div class="title">
             <h1><a href="posts/jeepney-and-bus-routes.html">Jeepney and Bus Routes</a>

+ 60 - 24
output/index.html

@@ -47,6 +47,66 @@
     <div class="container">
         <div class="content">
             
+        <div class="postbox">
+        <div class="title">
+            <h1><a href="posts/console-keymap-switching.html">Console Keymap Switching</a>
+            <small>
+                 Posted: 2013-10-29 20:02
+            </small></h1>
+        </div>
+        <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="code"><pre><span class="k">[Unit]</span>
+<span class="na">Description</span><span class="o">=</span><span class="s">kbrequest target</span>
+</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="code"><pre><span class="k">[Unit]</span>
+<span class="na">Description</span><span class="o">=</span><span class="s">Keymap Switch Service</span>
+
+<span class="k">[Service]</span>
+<span class="na">Type</span><span class="o">=</span><span class="s">oneshot</span>
+<span class="na">ExecStart</span><span class="o">=</span><span class="s">/usr/local/bin/keymap-switch</span>
+
+<span class="k">[Install]</span>
+<span class="na">WantedBy</span><span class="o">=</span><span class="s">kbrequest.target</span>
+</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>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10</pre></div></td><td class="code"><div class="code"><pre><span class="c">#!/bin/sh</span>
+<span class="nb">source</span> /etc/vconsole.conf
+
+<span class="k">if</span> <span class="o">[</span> <span class="s2">"$TERM"</span> <span class="o">=</span> <span class="s2">"dumb"</span> <span class="o">]</span>; <span class="k">then</span>
+<span class="k">  if</span> <span class="o">[</span> <span class="s2">"$KEYMAP"</span> <span class="o">=</span> <span class="s2">"dvorak"</span> <span class="o">]</span>; <span class="k">then</span>
+<span class="k">    </span>localectl <span class="nb">set</span>-keymap us
+  <span class="k">else</span>
+<span class="k">    </span>localectl <span class="nb">set</span>-keymap dvorak
+  <span class="k">fi</span>
+<span class="k">fi</span>
+</pre></div>
+</td></tr></table>
+
+<p>After putting it all together, it works! We can switch keymaps on the fly by simply pressing Alt+Up.</p>
+            
+    <p>
+        <a href="posts/console-keymap-switching.html#disqus_thread" data-disqus-identifier="cache/posts/console-keymap-switching.html">Comments</a>
+
+        </p></div>
         <div class="postbox">
         <div class="title">
             <h1><a href="posts/geocoding-services.html">Geocoding Services</a>
@@ -472,30 +532,6 @@ Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
         <a href="posts/open-trip-planner.html#disqus_thread" data-disqus-identifier="cache/posts/open-trip-planner.html">Comments</a>
 
         </p></div>
-        <div class="postbox">
-        <div class="title">
-            <h1><a href="posts/one-bus-or-maybe-jeep-away.html">One Bus (or maybe Jeep) Away</a>
-            <small>
-                 Posted: 2013-07-09 01:53
-            </small></h1>
-        </div>
-        <p>Link: <a href="http://onebusaway.org/">http://onebusaway.org/</a></p>
-<p><strong>TL;DR</strong> no routing; useless in Philippines</p>
-<p>OneBusAway is a transit information app. It provides data on what bus stops are near you, which buses pass by. You can also get schedules and the route of a particular bus given the number. It can also provide realtime updates like how many minutes until the next bus arrives. It does not, however, provide routing. There is no support for providing directions to get from point A to point B.</p>
-<p>It's comparable to what you get in some bus stops abroad. You'd get a vicinity map and a list of buses passing through the stop. You might also get the times when the next buses will pass. It's useful for locals who already know how to get around, and want to avoid waiting for the bus. But it's not particularly good for people who want to know how to get around the city.</p>
-<p>OneBusAway is quite comprehensive in its platform support though. There is a webapp, apps for iOS, Android and Windows Phone, as well as SMS and Voice support. This would all be nice but we don't have the necessary infrastructure yet in the Philippines. We don't have bus or jeepney stops. We also wouldn't have realtime data to make the app particularly useful.</p>
-<p>You can try it out for yourself by following their <a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/OneBusAway-Quickstart-Guide">Quickstart Guide</a>. One caveat is you will have to add <code>-P tripEntriesFactory.throwExceptionOnInvalidStopToShapeMappingException=false</code> when building the bundle. This has to do with the OneBusAway having difficulty matching the <a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/Stop-to-Shape-Matching">stops to the shape data</a>.</p>
-<p>Here's some screenshots of the app with the Philippine data. Notice how you only see the stops but there isn't a line for the route. This is a problem with our GTFS data. Also, at some points it's hard to tell where the jeep is going to pass since there isn't any indication of order either. This is more of a OneBusAway problem. It usually expects there to be shape data available.</p>
-<p><a href="galleries/transit/onebusaway1.png"><img alt="OneBusAway" src="galleries/transit/onebusaway1.png" title="All the stops along Katipunan Avenue are named Katipunan Avenue."></a></p>
-<p>It doesn't really handle too many routes passing through a stop. The list just overflows past the bubble. You can still actually read it by panning the map. It's just a bit weird though.</p>
-<p>If you also noticed, there are usually 2 of each route. This is how the jeepney data was modeled as jeep routes might be different going one way and going back. This isn't the case for all jeeps though, so it might also be an implementation issue with the GTFS editor.</p>
-<p><a href="galleries/transit/onebusaway2.png"><img alt="OneBusAway" src="galleries/transit/onebusaway2.png"></a></p>
-<p><a href="galleries/transit/onebusaway3.png"><img alt="OneBusAway" src="galleries/transit/onebusaway3.png"></a></p>
-            
-    <p>
-        <a href="posts/one-bus-or-maybe-jeep-away.html#disqus_thread" data-disqus-identifier="cache/posts/one-bus-or-maybe-jeep-away.html">Comments</a>
-
-        </p></div>
     
 <div>
 <ul class="pager clearfix">

+ 164 - 0
output/posts/console-keymap-switching.html

@@ -0,0 +1,164 @@
+<!DOCTYPE html><html lang="en">
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    
+    <meta charset="utf-8">
+    <meta name="description" content="">
+    <meta name="author" content="Thomas Dy">
+    <title>Console Keymap Switching | Pleasant Programmer</title>
+    
+        <link href="../assets/css/rst.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/code.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/colorbox.css" rel="stylesheet" type="text/css">
+        <link href="../assets/css/theme.css" rel="stylesheet" type="text/css">
+    <script type="text/javascript" src="//use.typekit.net/iwm5axp.js"></script>
+    <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
+    <!--[if lt IE 9]>
+      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
+    <![endif]-->
+            <link rel="alternate" type="application/rss+xml" title="RSS (en)" href="../rss.xml">
+
+    
+    
+    
+</head>
+<body>
+    <header>
+        <a href="../" title="Pleasant Programmer">
+            <div class="thomas">
+                <img src="../assets/img/thomas.gif" alt="DJ THOMAS IN DA HAUS">
+                <img src="../assets/img/thomas.png" alt="Pleasant Programmer">
+            </div>
+            <h1 id="blog-title">
+                Pleasant Programmer
+            </h1>
+        </a>
+        <ul class="nav">
+            <li class="twitter"><a href="http://twitter.com/pleasantprog">@pleasantprog</a></li>
+            
+            <li><a href="../archive.html">Archives</a>
+            </li><li><a href="../categories/index.html">Tags</a>
+            </li><li><a href="../rss.xml">RSS</a>
+
+        </li></ul>
+        
+        
+    </header>
+    <div class="container">
+        <div class="content">
+            
+    <div class="postbox">
+    <div class="title">
+        
+    <h1>Console Keymap Switching</h1>
+
+        <small>
+            Posted: 2013-10-29 20:02
+            
+
+            
+          |  More posts about
+            <a class="tag" href="../categories/sysadmin.html"><span class="badge badge-info">sysadmin</span></a>
+            <a class="tag" href="../categories/systemd.html"><span class="badge badge-info">systemd</span></a>
+
+        </small>
+    </div>
+    <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="code"><pre><span class="k">[Unit]</span>
+<span class="na">Description</span><span class="o">=</span><span class="s">kbrequest target</span>
+</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="code"><pre><span class="k">[Unit]</span>
+<span class="na">Description</span><span class="o">=</span><span class="s">Keymap Switch Service</span>
+
+<span class="k">[Service]</span>
+<span class="na">Type</span><span class="o">=</span><span class="s">oneshot</span>
+<span class="na">ExecStart</span><span class="o">=</span><span class="s">/usr/local/bin/keymap-switch</span>
+
+<span class="k">[Install]</span>
+<span class="na">WantedBy</span><span class="o">=</span><span class="s">kbrequest.target</span>
+</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>
+<table class="codehilitetable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10</pre></div></td><td class="code"><div class="code"><pre><span class="c">#!/bin/sh</span>
+<span class="nb">source</span> /etc/vconsole.conf
+
+<span class="k">if</span> <span class="o">[</span> <span class="s2">"$TERM"</span> <span class="o">=</span> <span class="s2">"dumb"</span> <span class="o">]</span>; <span class="k">then</span>
+<span class="k">  if</span> <span class="o">[</span> <span class="s2">"$KEYMAP"</span> <span class="o">=</span> <span class="s2">"dvorak"</span> <span class="o">]</span>; <span class="k">then</span>
+<span class="k">    </span>localectl <span class="nb">set</span>-keymap us
+  <span class="k">else</span>
+<span class="k">    </span>localectl <span class="nb">set</span>-keymap dvorak
+  <span class="k">fi</span>
+<span class="k">fi</span>
+</pre></div>
+</td></tr></table>
+
+<p>After putting it all together, it works! We can switch keymaps on the fly by simply pressing Alt+Up.</p>
+    
+    <ul class="pager clearfix">
+        <li class="previous">
+            <a href="geocoding-services.html">← Previous post</a>
+        </li>
+    </ul>
+
+        
+        <div id="disqus_thread"></div>
+        <script type="text/javascript">
+        var disqus_shortname ="pleasantprog";
+            var disqus_url="http://pleasantprogrammer.com/posts/console-keymap-switching.html";
+        var disqus_title="Console Keymap Switching";
+        var disqus_identifier="cache/posts/console-keymap-switching.html";
+        var disqus_config = function () {
+            this.language = "en";
+        };
+        (function() {
+            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+            dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
+            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+        })();
+    </script>
+    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
+
+    </div>
+
+        </div>
+    </div>
+    <footer>
+        <small><a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US"><img alt="CC-BY-SA" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/80x15.png"></a> © 2013 Thomas Dy - Powered by <a href="http://nikola.ralsina.com.ar">Nikola</a></small>
+        <script src="../assets/js/konami.js"></script>
+        <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
+        <script>
+            var easter_egg = new Konami();
+            easter_egg.code = function() { 
+                $(".thomas").toggleClass("whoa");
+                $("body").scrollTop(0);
+            }
+            easter_egg.load();
+
+            // love you, thomas!
+            // yours, @_phi + @meggykawsek
+        </script>
+    </footer>
+
+
+    <script type="text/javascript">var addthis_config={"ui_language":"en"};</script>
+    
+</body>
+</html>

+ 50 - 0
output/posts/console-keymap-switching.md

@@ -0,0 +1,50 @@
+<!--
+.. link:
+.. description:
+.. tags: sysadmin, systemd
+.. date: 2013/10/29 20:02:06
+.. title: Console Keymap Switching
+.. slug: console-keymap-switching
+-->
+
+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.
+
+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.
+
+For the console, they'd typically do `sudo loadkeys dvorak` 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.
+
+I googled around for solutions and came across [a nice idea](http://superuser.com/questions/548234/how-can-i-easily-toggle-between-dvorak-and-qwerty-keyboard-layouts-from-a-linux). You could alias `asdf` to load the DVORAK mapping and `aoeu` (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.
+
+After some further searching, I found [something close to what I wanted](http://unix.stackexchange.com/questions/2884/toggle-between-dvorak-and-qwerty). 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.
+
+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. `kbrequest.target` is normally aliased to run the rescue service though, so you have to manually create the file in `/etc/systemd/system/kbrequest.target` and fill it with a description:
+
+    [Unit]
+    Description=kbrequest target
+
+We can then add a service to be run whenever the target is called. Something like `/etc/systemd/system/keymap-switch.service`:
+
+    [Unit]
+    Description=Keymap Switch Service
+
+    [Service]
+    Type=oneshot
+    ExecStart=/usr/local/bin/keymap-switch
+
+    [Install]
+    WantedBy=kbrequest.target
+
+After enabling said service, we only need the actual keymap switcher, `/usr/local/bin/keymap-switch`. 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 `/etc/vconsole.conf`. We can also then switch keymaps by using `localectl set-keymap`.
+
+    #!/bin/sh
+    source /etc/vconsole.conf
+
+    if [ "$TERM" = "dumb" ]; then
+      if [ "$KEYMAP" = "dvorak" ]; then
+        localectl set-keymap us
+      else
+        localectl set-keymap dvorak
+      fi
+    fi
+
+After putting it all together, it works! We can switch keymaps on the fly by simply pressing Alt+Up.

+ 3 - 0
output/posts/geocoding-services.html

@@ -75,6 +75,9 @@
         <li class="previous">
             <a href="jeep-and-bus-schedules.html">← Previous post</a>
         </li>
+        <li class="next">
+            <a href="console-keymap-switching.html">Next post →</a>
+        </li>
     </ul>
 
         

+ 49 - 13
output/rss.xml

@@ -1,5 +1,52 @@
 <?xml version="1.0" encoding="utf-8"?>
-<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/rss.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 19:52:16 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Geocoding Services</title><link>http://pleasantprogrammer.com/posts/geocoding-services.html</link><description>&lt;p&gt;A key component for any routing service is being able to do geocoding. Most people who are looking for routes most probably don't know exactly where their start and end points are on the map. Even then, manually looking for a location on a map is a time-consuming task.&lt;/p&gt;
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Pleasant Programmer</title><link>http://pleasantprogrammer.com/</link><description></description><atom:link href="http://pleasantprogrammer.com/rss.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 29 Oct 2013 20:38:49 GMT</lastBuildDate><generator>nikola</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Console Keymap Switching</title><link>http://pleasantprogrammer.com/posts/console-keymap-switching.html</link><description>&lt;p&gt;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.&lt;/p&gt;
+&lt;p&gt;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.&lt;/p&gt;
+&lt;p&gt;For the console, they'd typically do &lt;code&gt;sudo loadkeys dvorak&lt;/code&gt; 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.&lt;/p&gt;
+&lt;p&gt;I googled around for solutions and came across &lt;a href="http://superuser.com/questions/548234/how-can-i-easily-toggle-between-dvorak-and-qwerty-keyboard-layouts-from-a-linux"&gt;a nice idea&lt;/a&gt;. You could alias &lt;code&gt;asdf&lt;/code&gt; to load the DVORAK mapping and &lt;code&gt;aoeu&lt;/code&gt; (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.&lt;/p&gt;
+&lt;p&gt;After some further searching, I found &lt;a href="http://unix.stackexchange.com/questions/2884/toggle-between-dvorak-and-qwerty"&gt;something close to what I wanted&lt;/a&gt;. 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.&lt;/p&gt;
+&lt;p&gt;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. &lt;code&gt;kbrequest.target&lt;/code&gt; is normally aliased to run the rescue service though, so you have to manually create the file in &lt;code&gt;/etc/systemd/system/kbrequest.target&lt;/code&gt; and fill it with a description:&lt;/p&gt;
+&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="k"&gt;[Unit]&lt;/span&gt;
+&lt;span class="na"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;kbrequest target&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+
+
+&lt;p&gt;We can then add a service to be run whenever the target is called. Something like &lt;code&gt;/etc/systemd/system/keymap-switch.service&lt;/code&gt;:&lt;/p&gt;
+&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="k"&gt;[Unit]&lt;/span&gt;
+&lt;span class="na"&gt;Description&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;Keymap Switch Service&lt;/span&gt;
+
+&lt;span class="k"&gt;[Service]&lt;/span&gt;
+&lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;oneshot&lt;/span&gt;
+&lt;span class="na"&gt;ExecStart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/usr/local/bin/keymap-switch&lt;/span&gt;
+
+&lt;span class="k"&gt;[Install]&lt;/span&gt;
+&lt;span class="na"&gt;WantedBy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;kbrequest.target&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+
+
+&lt;p&gt;After enabling said service, we only need the actual keymap switcher, &lt;code&gt;/usr/local/bin/keymap-switch&lt;/code&gt;. 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 &lt;code&gt;/etc/vconsole.conf&lt;/code&gt;. We can also then switch keymaps by using &lt;code&gt;localectl set-keymap&lt;/code&gt;.&lt;/p&gt;
+&lt;table class="codehilitetable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="code"&gt;&lt;pre&gt;&lt;span class="c"&gt;#!/bin/sh&lt;/span&gt;
+&lt;span class="nb"&gt;source&lt;/span&gt; /etc/vconsole.conf
+
+&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$TERM"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"dumb"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;; &lt;span class="k"&gt;then&lt;/span&gt;
+&lt;span class="k"&gt;  if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$KEYMAP"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"dvorak"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;; &lt;span class="k"&gt;then&lt;/span&gt;
+&lt;span class="k"&gt;    &lt;/span&gt;localectl &lt;span class="nb"&gt;set&lt;/span&gt;-keymap us
+  &lt;span class="k"&gt;else&lt;/span&gt;
+&lt;span class="k"&gt;    &lt;/span&gt;localectl &lt;span class="nb"&gt;set&lt;/span&gt;-keymap dvorak
+  &lt;span class="k"&gt;fi&lt;/span&gt;
+&lt;span class="k"&gt;fi&lt;/span&gt;
+&lt;/pre&gt;&lt;/div&gt;
+&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
+
+&lt;p&gt;After putting it all together, it works! We can switch keymaps on the fly by simply pressing Alt+Up.&lt;/p&gt;</description><author></author><category>sysadmin</category><category>systemd</category><guid>http://pleasantprogrammer.com/posts/console-keymap-switching.html</guid><pubDate>Tue, 29 Oct 2013 12:02:06 GMT</pubDate></item><item><title>Geocoding Services</title><link>http://pleasantprogrammer.com/posts/geocoding-services.html</link><description>&lt;p&gt;A key component for any routing service is being able to do geocoding. Most people who are looking for routes most probably don't know exactly where their start and end points are on the map. Even then, manually looking for a location on a map is a time-consuming task.&lt;/p&gt;
 &lt;p&gt;The gold standard for doing geocoding right now is Google Maps. It's hard to find a better location search experience. If they actually provided routing for jeeps here in the Philippines, I imagine there wouldn't be &lt;em&gt;that&lt;/em&gt; much you could do for the competition.&lt;/p&gt;
 &lt;p&gt;When the competition started though, I took it as a challenge to avoid Google Maps as much as possible. I wanted to see how much is currently possible with other options such as OpenStreetMap. In fact, OSM does have a geocoding service called &lt;a href="http://nominatim.openstreetmap.org"&gt;Nominatim&lt;/a&gt;.&lt;/p&gt;
 &lt;p&gt;Sadly, for a mapping app, what you want to do is not simply just geocoding. With geocoding, you take an address and turn it into coordinates. When you want to search for a place in a mapping app, you take part of an address, infer the rest of it, and give the user options to choose from.&lt;/p&gt;
@@ -307,15 +354,4 @@ Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
 &lt;p&gt;&lt;img alt="UP Katipunan Route" src="http://pleasantprogrammer.com/galleries/transit/upkatipunan.jpg"&gt;&lt;/p&gt;
 &lt;p&gt;From what they said during the launch, most of the route data was collected by getting a person to ride a jeep with a smartphone. That would explain why the coordinates aren't that exact. Even then, it would have been nice if they at least cleaned up the data by moving the stops to the road. They would have had to go over them to name the stops anyway.&lt;/p&gt;
 &lt;h4&gt;Conclusion&lt;/h4&gt;
-&lt;p&gt;Overall though, I really like OpenTripPlanner. It handles most of the hard parts of the challenge. It provides a REST API for doing routing with the GTFS + OSM data. There's also a lot of potential for additional open source work. A lot can be done to improve the default webapp. Adding a default location searcher would greatly improve usability. Adding in the route viewing features of OneBusAway would also be nice. Alternatively, you could even write your own client that just interfaces with the API.&lt;/p&gt;</description><author></author><category>philippine-transit-app</category><category>programming</category><guid>http://pleasantprogrammer.com/posts/open-trip-planner.html</guid><pubDate>Tue, 09 Jul 2013 15:16:12 GMT</pubDate></item><item><title>One Bus (or maybe Jeep) Away</title><link>http://pleasantprogrammer.com/posts/one-bus-or-maybe-jeep-away.html</link><description>&lt;p&gt;Link: &lt;a href="http://onebusaway.org/"&gt;http://onebusaway.org/&lt;/a&gt;&lt;/p&gt;
-&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; no routing; useless in Philippines&lt;/p&gt;
-&lt;p&gt;OneBusAway is a transit information app. It provides data on what bus stops are near you, which buses pass by. You can also get schedules and the route of a particular bus given the number. It can also provide realtime updates like how many minutes until the next bus arrives. It does not, however, provide routing. There is no support for providing directions to get from point A to point B.&lt;/p&gt;
-&lt;p&gt;It's comparable to what you get in some bus stops abroad. You'd get a vicinity map and a list of buses passing through the stop. You might also get the times when the next buses will pass. It's useful for locals who already know how to get around, and want to avoid waiting for the bus. But it's not particularly good for people who want to know how to get around the city.&lt;/p&gt;
-&lt;p&gt;OneBusAway is quite comprehensive in its platform support though. There is a webapp, apps for iOS, Android and Windows Phone, as well as SMS and Voice support. This would all be nice but we don't have the necessary infrastructure yet in the Philippines. We don't have bus or jeepney stops. We also wouldn't have realtime data to make the app particularly useful.&lt;/p&gt;
-&lt;p&gt;You can try it out for yourself by following their &lt;a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/OneBusAway-Quickstart-Guide"&gt;Quickstart Guide&lt;/a&gt;. One caveat is you will have to add &lt;code&gt;-P tripEntriesFactory.throwExceptionOnInvalidStopToShapeMappingException=false&lt;/code&gt; when building the bundle. This has to do with the OneBusAway having difficulty matching the &lt;a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/Stop-to-Shape-Matching"&gt;stops to the shape data&lt;/a&gt;.&lt;/p&gt;
-&lt;p&gt;Here's some screenshots of the app with the Philippine data. Notice how you only see the stops but there isn't a line for the route. This is a problem with our GTFS data. Also, at some points it's hard to tell where the jeep is going to pass since there isn't any indication of order either. This is more of a OneBusAway problem. It usually expects there to be shape data available.&lt;/p&gt;
-&lt;p&gt;&lt;a href="http://pleasantprogrammer.com/galleries/transit/onebusaway1.png"&gt;&lt;img alt="OneBusAway" src="http://pleasantprogrammer.com/galleries/transit/onebusaway1.png" title="All the stops along Katipunan Avenue are named Katipunan Avenue."&gt;&lt;/a&gt;&lt;/p&gt;
-&lt;p&gt;It doesn't really handle too many routes passing through a stop. The list just overflows past the bubble. You can still actually read it by panning the map. It's just a bit weird though.&lt;/p&gt;
-&lt;p&gt;If you also noticed, there are usually 2 of each route. This is how the jeepney data was modeled as jeep routes might be different going one way and going back. This isn't the case for all jeeps though, so it might also be an implementation issue with the GTFS editor.&lt;/p&gt;
-&lt;p&gt;&lt;a href="http://pleasantprogrammer.com/galleries/transit/onebusaway2.png"&gt;&lt;img alt="OneBusAway" src="http://pleasantprogrammer.com/galleries/transit/onebusaway2.png"&gt;&lt;/a&gt;&lt;/p&gt;
-&lt;p&gt;&lt;a href="http://pleasantprogrammer.com/galleries/transit/onebusaway3.png"&gt;&lt;img alt="OneBusAway" src="http://pleasantprogrammer.com/galleries/transit/onebusaway3.png"&gt;&lt;/a&gt;&lt;/p&gt;</description><author></author><category>philippine-transit-app</category><category>programming</category><guid>http://pleasantprogrammer.com/posts/one-bus-or-maybe-jeep-away.html</guid><pubDate>Mon, 08 Jul 2013 17:53:59 GMT</pubDate></item></channel></rss>
+&lt;p&gt;Overall though, I really like OpenTripPlanner. It handles most of the hard parts of the challenge. It provides a REST API for doing routing with the GTFS + OSM data. There's also a lot of potential for additional open source work. A lot can be done to improve the default webapp. Adding a default location searcher would greatly improve usability. Adding in the route viewing features of OneBusAway would also be nice. Alternatively, you could even write your own client that just interfaces with the API.&lt;/p&gt;</description><author></author><category>philippine-transit-app</category><category>programming</category><guid>http://pleasantprogrammer.com/posts/open-trip-planner.html</guid><pubDate>Tue, 09 Jul 2013 15:16:12 GMT</pubDate></item></channel></rss>

+ 15 - 0
output/sitemap.xml

@@ -49,6 +49,16 @@
   <lastmod>2013-10-29</lastmod>
   <priority>0.5000</priority>
  </url>
+ <url>
+  <loc>http://pleasantprogrammer.com/categories/sysadmin.html</loc>
+  <lastmod>2013-10-29</lastmod>
+  <priority>0.5000</priority>
+ </url>
+ <url>
+  <loc>http://pleasantprogrammer.com/categories/systemd.html</loc>
+  <lastmod>2013-10-29</lastmod>
+  <priority>0.5000</priority>
+ </url>
  <url>
   <loc>http://pleasantprogrammer.com/galleries/</loc>
   <lastmod>2013-10-29</lastmod>
@@ -94,6 +104,11 @@
   <lastmod>2013-10-29</lastmod>
   <priority>0.5000</priority>
  </url>
+ <url>
+  <loc>http://pleasantprogrammer.com/posts/console-keymap-switching.html</loc>
+  <lastmod>2013-10-29</lastmod>
+  <priority>0.5000</priority>
+ </url>
  <url>
   <loc>http://pleasantprogrammer.com/posts/elevation-data-in-otp.html</loc>
   <lastmod>2013-10-29</lastmod>

+ 50 - 0
posts/console-keymap-switching.md

@@ -0,0 +1,50 @@
+<!--
+.. link:
+.. description:
+.. tags: sysadmin, systemd
+.. date: 2013/10/29 20:02:06
+.. title: Console Keymap Switching
+.. slug: console-keymap-switching
+-->
+
+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.
+
+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.
+
+For the console, they'd typically do `sudo loadkeys dvorak` 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.
+
+I googled around for solutions and came across [a nice idea](http://superuser.com/questions/548234/how-can-i-easily-toggle-between-dvorak-and-qwerty-keyboard-layouts-from-a-linux). You could alias `asdf` to load the DVORAK mapping and `aoeu` (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.
+
+After some further searching, I found [something close to what I wanted](http://unix.stackexchange.com/questions/2884/toggle-between-dvorak-and-qwerty). 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.
+
+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. `kbrequest.target` is normally aliased to run the rescue service though, so you have to manually create the file in `/etc/systemd/system/kbrequest.target` and fill it with a description:
+
+    [Unit]
+    Description=kbrequest target
+
+We can then add a service to be run whenever the target is called. Something like `/etc/systemd/system/keymap-switch.service`:
+
+    [Unit]
+    Description=Keymap Switch Service
+
+    [Service]
+    Type=oneshot
+    ExecStart=/usr/local/bin/keymap-switch
+
+    [Install]
+    WantedBy=kbrequest.target
+
+After enabling said service, we only need the actual keymap switcher, `/usr/local/bin/keymap-switch`. 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 `/etc/vconsole.conf`. We can also then switch keymaps by using `localectl set-keymap`.
+
+    #!/bin/sh
+    source /etc/vconsole.conf
+
+    if [ "$TERM" = "dumb" ]; then
+      if [ "$KEYMAP" = "dvorak" ]; then
+        localectl set-keymap us
+      else
+        localectl set-keymap dvorak
+      fi
+    fi
+
+After putting it all together, it works! We can switch keymaps on the fly by simply pressing Alt+Up.