<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jan-Hendrik Kuperus on Medium]]></title>
        <description><![CDATA[Stories by Jan-Hendrik Kuperus on Medium]]></description>
        <link>https://medium.com/@jhkuperus?source=rss-3fb0a5abe9b8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*b5CCIwJiXgjFWo7IBs8SmQ.png</url>
            <title>Stories by Jan-Hendrik Kuperus on Medium</title>
            <link>https://medium.com/@jhkuperus?source=rss-3fb0a5abe9b8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:36:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jhkuperus/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Pomodoro Timer with Slack and Alfred]]></title>
            <link>https://medium.com/@jhkuperus/pomodoro-timer-with-slack-and-alfred-9cd0a1f329dc?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cd0a1f329dc</guid>
            <category><![CDATA[alfred-app]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[pomodoro-technique]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Fri, 17 Jul 2020 11:27:48 GMT</pubDate>
            <atom:updated>2020-07-17T11:27:48.616Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtDkQ9yR4GvlrEBCjdbnIQ.jpeg" /></figure><p>Are you looking for a way to integrate that “awesome productivity hack” with the rest of your workflow, but just can’t seem to get it right? Have you tried a ton of these timers, apps, websites and whatnot, but they all just feel like another thing to remember or like two (comfy) left shoes? That’s how I felt when I tried to integrate the Pomodoro-technique into my workflow.</p><p>I use Slack a lot and I absolutely love it. At some point, I had a trial for a plugin that allows you to work on a task and have your status be set to 🍅 — Until 20:33 . This would then also block notifications apart from direct mentions. This was great, but the rest of the integration just didn’t fit. Then I found a great app for my phone, where I could start timers for 25 minutes and then extend it by 5 minutes as needed, or go for a long/short break and then return to the next 25 minutes. Fantastic. It just didn’t integrate with Slack.</p><p>It was time to build something myself. The new feature would have to meet the following requirements:</p><ul><li>Be keyboard-activated</li><li>Integrate with Slack</li><li>Audibly and visibly remind me of the end of a focus-session</li><li>Preferably not require new software</li></ul><h4>Integrating with Slack</h4><p>The first thing I needed to figure out, was how to do things in Slack. I figured as long as I can at least post that I’m in a Pomodoro session until a specified time, I would already be half-way there. That’s when I found out about a little tool called <a href="https://github.com/rockymadden/slack-cli">slack-cli</a>. It can do pretty much <em>anything</em> with Slack, right from the command-line. The best part is, it’s 100% bash-scripting and available through brew :</p><pre>$ brew tap rockymadden/rockymadden<br>$ brew install rockymadden/rockymadden/slack-cli</pre><p>Now you can send messages, set/update/remove reminders, work with files and update your presence! After some playing around with the various commands and arguments, I found this to do exactly what I wanted:</p><pre>$ slack status edit --text=&quot;Pomodoro - In cycle&quot; --emoji=&quot;:tomato:&quot; --expiration=$expiryValue &amp;&amp; <br>  slack snooze start --minutes=&quot;25&quot;</pre><p>It sets a temporary status on me, with a 🍅-emoji behind my name and then activates snooze, which turns most notifications off for 25 minutes. The value in $expiryValue is the result of adding 25 minutes to the current timestamp using date -v +25M &quot;+%s&quot; .</p><h4>Creating the Workflow</h4><p>TLDR: Just <a href="https://github.com/jhkuperus/alfred-workflows/raw/master/JH%20Pomodoro.alfredworkflow">download the workflow</a> and import it.</p><p>If you’ve read <a href="https://medium.com/@jhkuperus/introducing-alfred-personal-productivity-d166c458c219">other</a> <a href="https://medium.com/@jhkuperus/bookmark-magic-with-alfred-personal-productivity-45d952dad438">stories</a> of <a href="https://medium.com/@jhkuperus/controlling-macos-wifi-with-alfred-personal-productivity-b3a2f5030665">mine</a>, you will not be surprised to find out I used Alfred to create my pomodoro-workflow. It allows me to tick off the other three requirements I had for my new “tool”. The workflow offers two new inputs, chosen from a List Filter block. In my setup, the List Filter uses the keyword .pd after which I can type either start or stop. The workflow then looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9pSURNHrxeKhMHLcWNtiHQ.png" /><figcaption>The Pomodoro Workflow</figcaption></figure><p>The List Filter block is pretty straight forward with its configuration. The only thing it needs are two entries which have start and stop as their value in the Arg-field:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6MCumGL0025p3mdbLbbkTQ.png" /><figcaption>Configuration of the List Filter block</figcaption></figure><p>The second block from the left is a Conditional block (found under Utilities). When you double click it, you can define multiple conditions, each of which will get its own output for the remainder of the workflow. Here we just need one condition, to check whether you typed start, otherwise we will just assume you typed stop. The labels on the outputs are configured in this dialog as well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HSqVFOES2zSW_7WxYW9PtA.png" /><figcaption>Configuration for the Conditional block</figcaption></figure><p>After the conditional block, the workflow continues in one of the two paths. The scripts blocks either enable your pomodor-mode (top flow) or disables it (bottom flow) in Slack. The script to enable your pomodoro status in Slack looks like this:</p><pre>expiryStatus=$(date -v +25M &quot;+%H:%M&quot;)<br>expiryValue=$(date -v +25M &quot;+%s&quot;)</pre><pre>slack status edit --text=&quot;Pomodoro - In cycle&quot; --emoji=&quot;:tomato:&quot; --expiration=$expiryValue &amp;&amp; <br>  slack snooze start --minutes=&quot;25&quot;</pre><pre>slack reminder add --text=&quot;Pomodoro done. Time to slack off.&quot; --time=$expiryValue</pre><p>First, we calculate the time 25 minutes in the future. These values can then be given to the two slack commands. The first edits your status to 🍅 with a hover-text of Pomodoro — In cycle Until 14:32. It also enables the snooze-status, which suppresses most notifications. Finally, it also creates a reminder for when the pomodor-cycle is over.</p><p>The script for the bottom flow basically cancels everything:</p><pre>pomodoroReminder=$(slack reminder list | jq -r &#39;.reminders[] | select(.text | startswith(&quot;Pomodoro done&quot;)).id&#39;)</pre><pre>if [[ -z $pomodoroReminder ]];<br>then<br>  echo &quot;Reminder was already deleted, skipping...&quot;<br>else<br>  slack reminder delete $pomodoroReminder<br>fi</pre><pre>slack status clear<br>slack snooze end</pre><p>At the top it tries to find any reminder that might still be active with the Pomodoro done text and then deletes that reminder if it exists. At the bottom, your Slack status is cleared and the snooze flag is also removed, returning Slack into its normal online state for you.</p><p>Next up in both the top and bottom flow is a <em>Arg and Vars</em> block. These are blocks where you can modify the value flowing into the block and assign variables. In this workflow, we will leave the value of {query} unchanged, as we’re not using it here. We do however set a variable to either true or false to indicate whether the pomodoro is still active or not. We need to do this, because the <em>Delay</em> block cannot be cancelled once activated. The top block sets the variable cancelled to false:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VlfgijT0dTaP6SYuyw4yAw.png" /><figcaption>Configuration of the top Arg and Vars block</figcaption></figure><p>The bottom one sets it to true, to indicate the current pomodoro-cycle has ended prematurely.</p><p>The bottom flow is basically done after this, it just shows a MacOS Notification telling you the pomodoro was cancelled. The top flow has a few things left to do: wait 25 minutes and then let you know the pomodoro is done. The delay block does exactly what it sounds like: wait for a specified time and then continue the workflow. In this flow, I’ve set the time to 1500 seconds, which is equivalent to 25 minutes. After the Delay, there is another Conditional block, checking to see if perhaps the pomodoro was cancelled. Here, if cancelled == true holds, the workflow ends and nothing happens. If cancelled == false holds, it will instead execute one last script before posting a notification that the pomodoro is done:</p><pre>slack status clear &amp;&amp; say &#39;Pomodoro done&#39;</pre><p>This resets your status in Slack and uses MacOS’ speech synthesis to audibly tell you “Pomodoro done”. I added this one because I am usually listening to music during a pomodoro and this awkward voice that interrupts your music never fails to snag my attention; exactly what it needs to do.</p><p>That’s it. Now every time you want to start a cycle of 25 minutes of deep focus and let your team know about it, just activate Alfred and type .pd start and you’re off.</p><p>If you make any custom tweaks to this workflow, be sure to comment on this story and share it! Thanks for making it all the way down here 😅.</p><p>Cheers!</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cd0a1f329dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Table flip everything!]]></title>
            <link>https://medium.com/@jhkuperus/table-flip-everything-157d7dec9589?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/157d7dec9589</guid>
            <category><![CDATA[alfred-app]]></category>
            <category><![CDATA[unicode]]></category>
            <category><![CDATA[fun]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Thu, 02 Jul 2020 10:17:37 GMT</pubDate>
            <atom:updated>2020-07-02T10:20:03.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tg0MAwBT1kXXDKLG2KxrGA.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@magda-ehlers-pexels?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Magda Ehlers</a> from <a href="https://www.pexels.com/photo/red-and-green-painted-house-3735571/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><p>The noble art of ASCII-art has moved a bit to the background in the past decade with a few nice exceptions like ASCII movie converters producing magnificent scenes like <a href="https://www.youtube.com/watch?v=fGuLp5EEZcE">this one from The Matrix</a>. Also, you can’t really call yourself a geek if you haven’t seen the telnet-powered ASCII art version of Star Wars (just enter telnet towel.blinkenlights.nl and sit back).</p><p>Luckily, not all is lost. Communicating through written text is still a big part of the software development profession, be it through Slack or commit messages or text-alerts on your phone. Little gems like :) =]:-) :-O \o/ can still be used to add some sentiment to your messages. After all Fixed tests doesn’t make you feel half as much a bad-ass as Fixed tests B-) will.</p><p>With the introduction of Unicode, we can make even more awesome things. Here are a few emoticons I use regularly in Slack these days:</p><ul><li>ಠ_ಠ — Great to disapprove with a teammate, or to respond to a failed build.</li><li>三三ᕕ( ᐛ )ᕗ — Fast Gary to run away from questions like “who is going to write that documentation for this service?”</li><li>(☞ﾟヮﾟ)☞ — Nice way to say “Good one!” to that person making fun of that other team’s planning mishap.</li><li>◞( ､ᐛ)､＿/ — Okay this one is scary. Gary coding can’t be good.</li><li>(╯°□°）╯︵ ┻━┻ — Do I have to explain the noble Table Flip?</li></ul><p>So how do you type these? Well I don’t. I use Alfred’s Snippet feature. In my setup, the snippet-collection is call Uber ASCII Art and you can <a href="https://www.jhkuperus.nl/downloads/alfred/Uber%20ASCII%20Art.alfredsnippets">download it from my personal site</a>.</p><h4>Hey! You promised to flip everything!</h4><p>I did, here you go: (╯°□°）╯︵ ɓuᴉɥʇʎɹǝʌǝ. Now you can copy-paste that and stop reading. Or you keep reading and I’ll explain how an Alfred workflow is doing this for me with any text. Any text? (╯°□°）╯︵ ¡ʇxǝʇ ʎuɐ sǝ⅄</p><p>The workflow is not extremely difficult. It just consists of three nodes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ekREwDKRu3Bug3g-crax7g.png" /><figcaption>Workflow to create table flip art</figcaption></figure><p>The Keyword-tile just specifies the .flip keyword and the requirement for an argument. The magic happens in the middle block, where this script is being executed with whatever you type after .flip :</p><pre>FLIPPED=$(echo $1 | rev | tr &#39;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?&#39; &#39;ɐqɔpǝɟɓɥᴉſʞןɯuodbɹsʇnʌʍxʎzꓯꓭↃꓷƎℲ⅁ΗIᒋꓘ⅂ꟽNOꓒÒꓤSꓕꓵꓥꤵX⅄Z¡¿&#39;)</pre><pre>echo &quot;(╯°□°）╯︵ $FLIPPED&quot;</pre><p>The third block executes a small piece of AppleScript to paste the now table-flipped text into whatever application you were working on:</p><pre>on alfred_script(q)<br>  tell application &quot;System Events&quot;<br>    set the clipboard to q<br>    keystroke &quot;v&quot; using command down<br>  end tell<br>end alfred_script</pre><p>That’s it. Now you too can flip everything! Have fun and make sure to make and share a lot of variations! :)</p><p>（ ^_^）o自自o（^_^ ）</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=157d7dec9589" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turn Your Keyboard into a Soundboard]]></title>
            <link>https://medium.com/@jhkuperus/turn-your-keyboard-into-a-soundboard-a2387c8dea01?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2387c8dea01</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[fun]]></category>
            <category><![CDATA[soundboards]]></category>
            <category><![CDATA[hammerspoon]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Tue, 16 Jun 2020 07:22:13 GMT</pubDate>
            <atom:updated>2020-06-16T07:22:13.660Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GbfzD5B7NPwBcUAI2V5WnA.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@mali?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">mali maeder</a> from <a href="https://www.pexels.com/photo/adult-audience-band-celebration-219101/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><p>Are the only sounds on your office floor the random rickety-clicks of your colleagues’ keyboards? Are meetings dull and devoid of humor? Then pick yourself up, find some sound fragments and start bringing a new vibe to your work floor. (And probably annoy the heck out of some of your co-workers 😇)</p><p>Back when I started playing with Hammerspoon, I browsed its entire API to see what things I could do with it. My eyes fell on the category hs.sound and I knew at that moment I had to build a soundboard. Once I had setup my Hyper-key and several really useful key-bindings, I went to work.</p><p>Not long after, I could complete a co-worker’s pun with a “BA-DUM-TISS” sound at the press of a button. Or end a meeting with the Warcraft’s Peon saying “WORK WORK”. My personal favourites were a piece of completely arbitrary “elevator music” and the introduction of “Driving home for Christmas”.</p><h4>The Setup</h4><p>Trust me when I say, the code is not the hard part. The hard part is finding good audio fragments to use. If you’re looking for inspiration, have a look the <a href="https://www.myinstants.com/">My Instants</a> website. They have a brilliant collection of small sound snippets from various movies, songs and even games.</p><p>Once you’ve collected some sounds, you can start building your soundboard with Hammerspoon. To keep things manageable, the mappings between keys and sound-files are stored in a table. This table is then read by a function, binding the sound-file to the specified key. Here’s a part of my setup:</p><pre>local soundBoard = {<br>  badumtiss =       { key = &#39;1&#39;, file = &#39;badumtiss.mp3&#39; },<br>  metalgearsolid =  { key = &#39;2&#39;, file = &#39;metalgearsolid.mp3&#39; },<br>  winError =        { key = &#39;3&#39;, file = &#39;windows-error.mp3&#39; },<br>  sadtrombone =     { key = &#39;4&#39;, file = &#39;sadtrombone.mp3&#39; },<br>  crickets =        { key = &#39;5&#39;, file = &#39;crickets.mp3&#39; },<br>  batman =          { key = &#39;6&#39;, file = &#39;batman-transition.mp3&#39; },<br>  shocked =         { key = &#39;7&#39;, file = &#39;shocked.mp3&#39; },<br>  inception =       { key = &#39;8&#39;, file = &#39;inceptionbutton.mp3&#39; },<br>  haGay =           { key = &#39;9&#39;, file = &#39;ha-gay.mp3&#39; },<br>  workwork =        { key = &#39;0&#39;, file = &#39;wc-work-work.mp3&#39; },<br>  workComplete =    { key = &#39;-&#39;, file = &#39;wc-work-complete.mp3&#39; },<br>  ns =              { key = &#39;=&#39;, file = &#39;ns-ding-dong.mp3&#39; },<br>  -- ... many more here<br>}</pre><pre>-- Initialise Soundboard!<br>for n,s in pairs(soundBoard) do<br>  -- Change the path here to where your sound files are stored:<br>  s.sound = hs.sound.getByFile(os.getenv(&quot;HOME&quot;) .. &#39;/.hammerspoon-assets/soundboard/&#39; .. s.file)</pre><pre>  -- Bind to Hyper+Cmd+s.key<br>  hyper.bindKeyWithModifiers(s.key, {&#39;cmd&#39;}, function()<br>    s.sound:stop()<br>    s.sound:play()<br>  end)<br>end</pre><p>The table in my file holds entries for almost all keys, but the bulk of them have been omitted here, because the idea is illustrated well enough in this sample. The for-loop below it (where it says -- Initialise Soundboard!) loops over this table and binds the specified key to a function that plays the given sound. Make sure you either put the sounds in the path specified (~/.hammerspoon-assets/soundboard/) or adjust the path accordingly.</p><p>If you place this snippet in your ~/.hammerspoon/init.lua you will now be able to play sounds by pressing Hyper+⌘+&lt;anything&gt;. Please remember the above snippet references hyper, which is <a href="https://medium.com/macoclock/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521">the hyper key created in an earlier post</a>. If you don’t use the Hyper key, change the hyper.bindKeyWithModifiers call to your appropriate key-combination.</p><p>A fun thing to note with this soundboard is the fact that Hammerspoon is able to play a lot of sounds simultaneously. If you press different key-combo’s quickly after one another, they will start playing together. That is a particularly fun way to use this soundboard if you are skilled in putting samples together. You might just create your next dubstep-hit with just the keyboard of your Mac.</p><p>Have fun annoying people around you! 😇🙊</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2387c8dea01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Current Date/Time Anywhere — Personal Productivity]]></title>
            <link>https://medium.com/@jhkuperus/using-current-date-time-anywhere-personal-productivity-45d14dc6547d?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/45d14dc6547d</guid>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[hammerspoon]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Thu, 04 Jun 2020 21:43:04 GMT</pubDate>
            <atom:updated>2020-06-04T21:43:04.853Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Lxym35Dj5bSBLMc8EkYZg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jealousweekends?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Jealous Weekends</a> on <a href="https://unsplash.com/s/photos/calendar?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Using Current Date/Time Anywhere — Personal Productivity</h3><p>Dates are important. To record things that happened in the past, or to plan things in the future, you’ll need them. (If you were thinking of the romantic version of dates, I’m afraid you’ll find no advise on those here… Sorry! 😇)</p><p>On most machines, there is a way to display the current date, or time, or both, somewhere on your screen permanently. But let’s be honest, how often do you look up dat your status bar? I have mine display just the time, because I don’t like all that clutter up there.</p><p>But, every now and again I do need to know the current date. Whether it is because I wonder if I forgot anyone’s birthday, or because I have received a new bill or photo to archive in a nicely sorted fashion, I do need the date. To facilitate myself in this, I have three keyboard shortcuts which give the current date/time in three different formats:</p><p><strong>Hyper+T</strong> — Displays the current date time in a very detailed format, like so: Monday, 01 June 2020, 23:23. When I press the key, the value shows up on my screen like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KXMVW3SDB9AitmaMLDRG1A.png" /></figure><p>It disappears after a few seconds. It is in view just long enough to read it and short enough not be annoying. And as a bonus, it puts this exact value in my pasteboard. That lets me use this value in a piece of text or a chat conversation with just the <strong>Hyper+T</strong> and <strong>⌘V</strong> buttons to paste it wherever I want.</p><p><strong>Hyper+Shift+T —</strong> Displays the current date in a compressed format, like so: 20200601. It’s the date in YYYYMMdd-format, which allows for chronological sorting. I prefix all of my important files with this, just to be able to use my memory of when something was added.</p><p><strong>Hyper+Shift+</strong>⌘+T — Displays the current date in sortable format, but with dashes, like so: 2020–06–03. It’s again in the YYYY-MM-dd-format. I use this format in documents to detail entries for a certain date. They simply read a little better than the condensed form. I don’t use them for file names, because the dashes make them more difficult to type quickly.</p><h4>The Code</h4><p>The code required to make this work is actually extremely simple. If you plan on using the Hyper-key and have not set it up, please refer to <a href="https://medium.com/macoclock/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521">my post on setting up a Hyper-key</a>. You can also use “regular” shortcuts.</p><p>The tool I use to make this work is <a href="https://www.hammerspoon.org/docs/hs.hotkey.html">Hammerspoon</a>. Among many other things, Hammerspoon allows you to create arbitrary keyboard shortcuts. The snippet below is part of the ~/.hammerspoon/init.lua file which Hammerspoon reads all of its configuration from. If you’re unfamiliar with Hammerspoon, there is a previous article from me on <a href="https://medium.com/@jhkuperus/introducing-hammerspoon-personal-productivity-d32c0c825caf">what it can do and how to set it up</a>.</p><pre>-- Date Handy Dandyness<br>hyper.bindKey(&quot;t&quot;, function()<br>  local time = os.date(&quot;%A, %d %B %Y, %H:%M&quot;)<br>  hs.alert.show(time)<br>  hs.pasteboard.setContents(time)<br>end)</pre><pre>hyper.bindShiftKey(&quot;t&quot;, function()<br>  local time = os.date(&quot;%Y%m%d&quot;)<br>  hs.alert.show(time)<br>  hs.pasteboard.setContents(time)<br>end)</pre><pre>hyper.bindCommandShiftKey(&quot;t&quot;, function()<br>  local time = os.date(&quot;%Y-%m-%d&quot;)<br>  hs.alert.show(time)<br>  hs.pasteboard.setContents(time)<br>end)</pre><pre>-- Or use a regular (non-Hyper) shortcut:<br>hs.hotkey.bind(&quot;cmd&quot;, &quot;t&quot;, nil, function()<br>  ...<br>end)</pre><p>That’s it. If you need more formats, just copy paste one of the three and alter the value in os.date(...) to display and copy whatever format it is you need. You could also go nuts and display other things. The current temperature of your CPU, the weather outside, or the current value of 1 Bitcoin. If it is a value that changes regularly and you need to use it often, this simple key-binding will help you out a lot.</p><p>If you create any other cool ways to use this, don’t be shy and leave it in a comment, or as an idea on my <a href="https://github.com/jhkuperus/dotfiles">dotfiles repository</a>.</p><p>Cheers!</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45d14dc6547d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Magical One-Handed App-Switcher — Personal Productivity]]></title>
            <link>https://medium.com/@jhkuperus/magical-one-handed-app-switcher-personal-productivity-a959c2e9842a?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a959c2e9842a</guid>
            <category><![CDATA[hammerspoon]]></category>
            <category><![CDATA[mac-os-x]]></category>
            <category><![CDATA[productivity]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Thu, 21 May 2020 19:21:44 GMT</pubDate>
            <atom:updated>2020-05-21T19:21:44.879Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMwTgcJpJb8e1_K1skg01w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@arkhoff?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">ARTUR KERKHOFF</a> on <a href="https://unsplash.com/s/photos/magical-sword?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Magical One-Handed App-Switcher — Personal Productivity</h3><p>Do you hate ⌘-TAB (or alt-TAB on Windows)? I do. The fact that the order of applications changes all the time is highly frustrating. In order to use it to quickly change between applications, I have to remember the order. That’s doable for two or three applications, but not for eight or twelve.</p><p>When any kind of work has me in a good flow, I want that flow to be maintained between applications. Most commonly, this means I am writing code in say IntelliJ, running some remote log-viewers in iTerm and checking the application in Chrome. This means I have to switch a lot between these applications and maybe also back and forth between Slack a few times. Any time I want to switch, I know exactly to which application I want to switch. I don’t have to press ⌘-TAB and look at all the applications, deciding which one to go to, I <em>know</em> which one I want.</p><p>This is where my Magical One-Handed App-Switcher comes in. Yes, it sounds like some sort of weapon from Dungeons and Dragons, because that is what it feels like once it’s incorporated into your arsenal of tools. What it does? It allows me to switch to any of a pre-determined set of 14 applications instantly by pressing two keys with my right hand. How it works? By using <a href="https://medium.com/macoclock/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521">the Hyper-key</a>. Here’s what it looks like on my keyboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*scM7Xqzz6s7dHBXtq5zeaw.png" /><figcaption>Hyper+App-key switches to the app instantly</figcaption></figure><p>All of these keys are well in range of my right hand’s neutral position. To switch to an app, I press the Hyper-key with my thumb and press one of the other keys to instantly switch to that application.</p><p>The scripting to make this work is done with Hammerspoon and the Hyper key also needs the use of Karabiner. How to set these up can be found <a href="https://medium.com/macoclock/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521">in another one of my posts</a>. The script uses one simple function to make this work:</p><pre>local This = {}</pre><pre>-- Quickly move to and from a specific app<br>-- (Thanks Teije)<br>local previousApp = &quot;&quot;</pre><pre>function This.switchToAndFromApp(bundleID)<br>  local focusedWindow = hs.window.focusedWindow()</pre><pre>  if focusedWindow == nil then<br>    hs.application.launchOrFocusByBundleID(bundleID)<br>  elseif focusedWindow:application():bundleID() == bundleID then<br>    if previousApp == nil then<br>      hs.window.switcher.nextWindow()<br>    else<br>      previousApp:activate()<br>    end<br>  else<br>    previousApp = focusedWindow:application()<br>    hs.application.launchOrFocusByBundleID(bundleID)<br>  end<br>end</pre><pre>return This</pre><p>By calling this function with the Bundle ID of an application, Hammerspoon will either bring it to the foreground or start it. As an extra convenience, it also remembers the app you came from, so pressing the same button twice, gets you back to the application you were before switching. This last bit is especially useful when you have to quickly check a window for something and then go back to work. Press it once to switch to the app, press the same key again to switch back.</p><p>To use it from your init.lua script and configure the buttons, you can use this:</p><pre>local am = require(&#39;app-management&#39;)<br>local hyper = require(&#39;hyper&#39;)</pre><pre>hyper.install(&#39;F18&#39;)</pre><pre>-- Global Application Keyboard Shortcuts<br>hyper.bindKey(&#39;m&#39;, function() <br>  am.switchToAndFromApp(&quot;com.postbox-inc.postbox&quot;) end)<br>hyper.bindKey(&#39;p&#39;, function() <br>  am.switchToAndFromApp(&quot;com.spotify.client&quot;) end)<br>hyper.bindShiftKey(&#39;p&#39;, function()<br>  hs.spotify.displayCurrentTrack() end)<br>hyper.bindKey(&#39;]&#39;, function()<br>  am.switchToAndFromApp(&quot;com.googlecode.iterm2&quot;) end)<br>hyper.bindKey(&#39;[&#39;, function()<br>  am.switchToAndFromApp(&quot;com.apple.ActivityMonitor&quot;) end)<br>hyper.bindKey(&#39;;&#39;, function()<br>  am.switchToAndFromApp(&quot;com.google.Chrome&quot;) end)<br>hyper.bindShiftKey(&#39;\\&#39;, function()<br>  am.switchToAndFromApp(&quot;chat.rocket&quot;) end)<br>hyper.bindKey(&#39;l&#39;, function()<br>  am.switchToAndFromApp(&quot;com.jetbrains.intellij&quot;) end)<br>hyper.bindKey(&#39;k&#39;, function()<br>  am.switchToAndFromApp(&quot;com.apple.keychainaccess&quot;) end)<br>hyper.bindKey(&#39;\&#39;&#39;, function()<br>  am.switchToAndFromApp(&quot;com.apple.Notes&quot;) end)<br>hyper.bindKey(&#39;/&#39;, function()<br>v am.switchToAndFromApp(&quot;com.apple.iCal&quot;) end)<br>hyper.bindKey(&#39;.&#39;, function()<br>  am.switchToAndFromApp(&quot;com.apple.finder&quot;) end)<br>hyper.bindKey(&#39;,&#39;, function()<br>  am.switchToAndFromApp(&quot;net.cozic.joplin-desktop&quot;) end)<br>hyper.bindKey(&#39;`&#39;, function()<br>  print(pcall(minimizeAllButFocussedWindow)) end)<br>hyper.bindKey(&#39;\\&#39;, function()<br>  am.switchToAndFromApp(&quot;com.tinyspeck.slackmacgap&quot;) end)</pre><pre>-- show the bundleid of the currently open window<br>hyper.bindkey(&#39;b&#39;, function() <br>    local bundleid = <br>      hs.window.focusedwindow():application():bundleid()<br>    hs.alert.show(bundleid)<br>    hs.pasteboard.setcontents(bundleid)<br>end)</pre><p>As you can see, you need to know the BundleID of the apps you want to use in this fashion. Luckily, there is a simple way to figure out this BundleID. The last key-binding adds Hyper-b, which shows the BundleID of the currently active application and also puts it in the pasteboard.</p><p>The <a href="https://github.com/jhkuperus/dotfiles/blob/master/hammerspoon/app-management.lua">app-switching file can be found in my dotfiles repository</a>, along with the above snippet from the init.lua file.</p><p>Enjoy the magic!</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a959c2e9842a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick folder access with Alfred — Personal Productivity]]></title>
            <link>https://medium.com/@jhkuperus/quick-folder-access-with-alfred-personal-productivity-6c39db7313ab?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c39db7313ab</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[life-hacking]]></category>
            <category><![CDATA[alfred-app]]></category>
            <category><![CDATA[shortcuts]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Thu, 14 May 2020 14:44:44 GMT</pubDate>
            <atom:updated>2020-05-14T14:44:44.631Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XQNYR9qb4RtYNX5hrbUWqQ.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@olly?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Andrea Piacquadio</a> from <a href="https://www.pexels.com/photo/pensive-female-worker-choosing-folder-with-documents-in-modern-office-3791185/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><h3>Quick folder access with Alfred — Personal Productivity</h3><p>Have you tried <a href="https://medium.com/@jhkuperus/bookmark-magic-with-alfred-personal-productivity-45d952dad438">using your browser’s bookmarks from Alfred</a>? If you did and you like it, you will probably like what comes next. This post will use some of that same brainpower of yours to make certain places on your laptop more accessible.</p><p>Whether you a have a system to organise the folders on your disk or not, navigating to a specific folder usually still involves several levels of folders, some clicking, moving a mouse and, last but not least, some cognitive effort to try and remember the exact location of what you are looking for. For things you occasionally need, this is fine. When it comes to the things you need to access a lot, it’s a hassle and one that can easily pile on some frustration while you are working.</p><p>Let’s solve this using Alfred.</p><h4>The Workflow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*AJX6DaDth5W5Y0-1Ry1sqQ.png" /><figcaption>Workflow to navigate to a path using a mnemonic</figcaption></figure><p>What!? Is it that easy? Well yes, actually it is. Alfred has an action-block called <em>Reveal File in Finder</em>, which does exactly what the name implies. Connect this with a keyword-block using your mnemonic and you’re done. Simply add the location of the folder you want to open:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4HMO_9CcyMljqKYTyyDow.png" /><figcaption>Configuring the Reveal File in Finder block</figcaption></figure><p>Now you can add as many as these small workflows as you need mnemonic access to folders. Here’s a bit of inspiration:</p><ul><li>fa — Opens the Financial Administration folder</li><li>cus — Opens the Customers folder, where an alphabetical list of folders per Customer lives with offers, bills, deals and contracts</li><li>tax — Opens the Taxes folder, containing all forms pertaining various forms of taxes</li><li>bkup — Opens the network share Backup to browse my backups!</li></ul><h4>Custom File Searches</h4><p>As a little bonus, you can also use this method to intentionally narrow your search to files within a certain folder. For example, when I need to find the CV of one of my employees, I can now simply type cv &lt;name of employee&gt; to find their CV. All this needs, is to change the initial block of the workflow to a File Filter block:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*0q8kukMGHHSstVulbjNHPw.png" /><figcaption>Workflow to search within a specific set of files</figcaption></figure><p>Make sure the <em>Reveal Path</em> setting in the Reveal File in Finder block is empty, as it will then reveal the path that is passed in. The File Filter block will send the path of the selected file as its output.</p><p>You can configure a lot of things with the File Filter block. The configuration-window has a total of four tabs which allow you to specify what types of files to display, what keyword starts the search, which folders Alfred should look in, what metadata of the file should be matched and how to sort and select the best matches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjXGR1ivScOdPWP0e2zfqw.png" /><figcaption>Setup the File Filter block</figcaption></figure><p>One important thing to note here, is the fact that file types have to be entered as UTIs (Uniform Type Identifier). I didn’t magically know these values for the Pages and Word documents shown above. Luckily Alfred allows you to drop files in there and he will then take the UTI of that file and add it to the list.</p><p>This should help you access presentations, drafts of articles, recipes or basically just about anything you want a whole lot faster. Use the fact that your brain loves these shortcuts. Not having to recall an entire tree-structure while looking for pictures of your cat saves energy and all your brain wants to do all day is save energy.</p><p>Cheers!</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c39db7313ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Window Management with Hammerspoon — Personal Productivity]]></title>
            <link>https://medium.com/@jhkuperus/window-management-with-hammerspoon-personal-productivity-c77adc436888?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c77adc436888</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[hammerspoon]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 19:19:01 GMT</pubDate>
            <atom:updated>2020-04-22T19:19:01.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LfhOiDr6LJuZlBg27xKWCA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@evelinafriman?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Evelina Friman</a> on <a href="https://unsplash.com/s/photos/windows?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Window Management with Hammerspoon — Personal Productivity</h3><p>With all these 4K/5K/8K screens on the market, window management is becoming more and more important. I used to be happy with just being able to put two applications next to each either vertically or horizontally. Now I need more fine-grained control over the position of each of my windows.</p><p>I could obviously buy one of the tools available for this on the web, such as Magnet or BetterTouchTool. Sadly, all of them seem to just miss the sweet spot of window management I’m looking for. The biggest problem for me is the fact that they occupy certain global key combinations and they’re not always willing to share or change those.</p><p>So, when you’re a software developer and the “right” tool doesn’t seem to exist, what do you do? You roll your own 😇. You could go the hardcore way and try to figure this out with ObjectiveC and the MacOS core docs, but that’s actually not necessary. The folks behind Hammerspoon did that for you already!</p><p>When I fell in love with Hammerspoon and created my Hyper key, window management was one of the first things I built with it. My most wanted key-combination at that time was a quick way to move a window from one monitor to the next.</p><p>By now, I have keys to maximise windows, put them in the left, right, top or bottom half of the screen and also for placing them in the top-left, top-right, bottom-left and bottom-right quarters of the screen.</p><h4>Moving a window</h4><p>Before we begin, I’d like to note that the coming pieces of code bind the window-management functions to shortcuts using the Hyper-key. If you want to use this as well, make sure you have followed my <a href="https://medium.com/@jhkuperus/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521">earlier post to setup a Hyper-key</a>. If you don’t want to do this, just assign other key-bindings to the functions.</p><p>The code starts by using hs.grid to divide the screen into an easy to use grid. This saves us the trouble of calculating the exact screen position every time and allows us to simply talk about parts of the screen.</p><p>The following code snippets all form a single file called window-management.lua which will later be imported from init.lua. Let’s get started with building the grid:</p><pre>local This = {}</pre><pre>-- To easily layout windows on the screen, we use hs.grid to create<br>-- a 4x4 grid. If you want to use a more detailed grid, simply <br>-- change its dimension here<br>local GRID_SIZE = 4<br>local HALF_GRID_SIZE = GRID_SIZE / 2</pre><pre>-- Set the grid size and add a few pixels of margin<br>-- Also, don&#39;t animate window changes... That&#39;s too slow<br>hs.grid.setGrid(GRID_SIZE .. &#39;x&#39; .. GRID_SIZE)<br>hs.grid.setMargins({5, 5})<br>hs.window.animationDuration = 0</pre><p>This shows just how easy the setup is of the hs.grid module. The above is almost a convoluted way of saying hs.grid.setGrid(&#39;4x4&#39;). But if you want to experiment, you can now just change the GRID_SIZE and see the rest being adjusted automatically. You’ll also see the values GRID_SIZE and HALF_GRID_SIZE popup later.</p><p>With this out of the way, I define a table of screen positions which can later be used to direct screens to certain position on the screen. Note that the x, y, w and h coordinates are grid cell numbers. These numbers start in the top-left corner of your screen. Here are the positions I use:</p><pre>local screenPositions       = {}<br>screenPositions.left        = {<br>  x = 0, y = 0,<br>  w = HALF_GRID_SIZE, h = GRID_SIZE<br>}<br>screenPositions.right       = {<br>  x = HALF_GRID_SIZE, y = 0,<br>  w = HALF_GRID_SIZE, h = GRID_SIZE<br>}<br>screenPositions.top         = {<br>  x = 0, y = 0,<br>  w = GRID_SIZE, h = HALF_GRID_SIZE<br>}<br>screenPositions.bottom      = {<br>  x = 0, y = HALF_GRID_SIZE,<br>  w = GRID_SIZE, h = HALF_GRID_SIZE<br>}</pre><pre>screenPositions.topLeft     = {<br>  x = 0, y = 0,<br>  w = HALF_GRID_SIZE, h = HALF_GRID_SIZE<br>}<br>screenPositions.topRight    = {<br>  x = HALF_GRID_SIZE, y = 0,<br>  w = HALF_GRID_SIZE, h = HALF_GRID_SIZE<br>}<br>screenPositions.bottomLeft  = {<br>  x = 0, y = HALF_GRID_SIZE,<br>  w = HALF_GRID_SIZE, h = HALF_GRID_SIZE<br>}<br>screenPositions.bottomRight = {<br>  x = HALF_GRID_SIZE, y = HALF_GRID_SIZE,<br>  w = HALF_GRID_SIZE, h = HALF_GRID_SIZE<br>}</pre><pre>This.screenPositions = screenPositions</pre><p>The final part of the script merely contains two functions which move a window to a desired position. These functions allow the movement of a specific window and also offer a convenience to simply move the focused window:</p><pre>-- This function will move either the specified or the focuesd<br>-- window to the requested screen position<br>function This.moveWindowToPosition(cell, window)<br>  if window == nil then<br>    window = hs.window.focusedWindow()<br>  end<br>  if window then<br>    local screen = window:screen()<br>    hs.grid.set(window, cell, screen)<br>  end<br>end</pre><pre>-- This function will move either the specified or the focused<br>-- window to the center of the sreen and let it fill up the<br>-- entire screen.<br>function This.windowMaximize(factor, window)<br>   if window == nil then<br>      window = hs.window.focusedWindow()<br>   end<br>   if window then<br>      window:maximize()<br>   end<br>end</pre><pre>return This</pre><p>Now all that is left, is to bind these functions to keys in our init.lua script:</p><pre>local wm = require(&#39;window-management&#39;)</pre><pre>-- Window Management<br>hyper.bindKey(&quot;up&quot;, function()<br>  wm.windowMaximize(0)<br>end)<br>hyper.bindKey(&quot;right&quot;, function()<br>  wm.moveWindowToPosition(wm.screenPositions.right)<br>end)<br>hyper.bindKey(&quot;down&quot;, function()<br>  hs.window.focusedWindow():moveOneScreenEast()<br>end)<br>hyper.bindShiftKey(&quot;down&quot;, function()<br>  hs.window.focusedWindow():moveOneScreenWest()<br>end)<br>hyper.bindKey(&quot;left&quot;, function()<br>  wm.moveWindowToPosition(wm.screenPositions.left)<br>end)</pre><pre>hyper.bindShiftKey(&quot;1&quot;, function()<br>  wm.moveWindowToPosition(wm.screenPositions.topLeft)<br>end)<br>hyper.bindShiftKey(&quot;2&quot;, function()<br>  wm.moveWindowToPosition(wm.screenPositions.topRight)<br>end)<br>hyper.bindShiftKey(&quot;3&quot;, function()<br>  wm.moveWindowToPosition(wm.screenPositions.bottomLeft)<br>end)<br>hyper.bindShiftKey(&quot;4&quot;, function()<br>  wm.moveWindowToPosition(wm.screenPositions.bottomRight)<br>end)<br>hyper.bindShiftKey(&quot;5&quot;, function()<br>  wm.moveWindowToPosition(wm.screenPositions.top)<br>end)<br>hyper.bindShiftKey(&quot;6&quot;, function()<br>  wm.moveWindowToPosition(wm.screenPositions.bottom)<br>end)</pre><p>The above definitions now let you use these shortcuts to move the focused window around:</p><ul><li>Hyper+Up : Maximise window to max size of monitor</li><li>Hyper+Down / Hyper+Shift+Down : Move the window between monitors</li><li>Hyper+Left / Hyper+Right : Put the window in the left or right half of the monitor</li><li>Hyper+Shift+1 : Put the window in the top-left quarter</li><li>Hyper+Shift+2 : Put the window in the top-right quarter</li><li>Hyper+Shift+3 : Put the window in the bottom left quarter</li><li>Hyper+Shift+4 : Put the window in the bottom right quarter</li><li>Hyper+Shift+5 : Put the window in the top half</li><li>Hyper+Shift+6 : Put the window in the bottom half</li></ul><p>You now have all the ingredients to create your own window management. You can play with the grid size, add additional window positions and bind them to whatever keys you like. If you want to get extra fancy, you can also create “scenes” where certain application windows are always in a fixed location. After all, we are only using the focused window in this code, but you can move any window around through the <a href="https://www.hammerspoon.org/docs/hs.window.html">hs.window</a> api.</p><p>As always, the entire source of the window management utilities can be found on my <a href="https://github.com/jhkuperus/dotfiles/blob/master/hammerspoon/window-management.lua">GitHub dotfiles repository</a>.</p><p>Enjoy your window managing super powers!</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c77adc436888" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solve Shortcut Hell in MacOS — Building a Hyper Key]]></title>
            <link>https://medium.com/macoclock/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cb8838bf521</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[hammerspoon]]></category>
            <category><![CDATA[karabiner-elements]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Tue, 21 Apr 2020 21:39:48 GMT</pubDate>
            <atom:updated>2020-04-23T09:24:21.492Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jic_CJooOknsTUEzZTqa3w.jpeg" /><figcaption>Photo by <a href="https://www.pexels.com/@ferarcosn?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Fernando Arcos</a> from <a href="https://www.pexels.com/photo/under-construction-signage-on-laptop-keyboard-211122/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><h3>Solve Shortcut Hell in MacOS — Building a Hyper Key</h3><p>If you like shortcuts and try to use them in every application, you will run into it eventually: Shortcut Hell. Two (or more) applications wanting to use the same shortcut and no way to change them.</p><p>Well, what if I told you there’s a way to create a completely new layer on your keyboard? What if I told you this way no application will ever be able to steal your shortcuts? All you need to sacrifice is one tiny button on your keyboard. Best of all: you get to choose which button you sacrifice.</p><p>Introducing: <em>the Hyper key!</em></p><p>The Hyper key is a custom sibling of Shift, Option, Control and Command. It acts as a new modifier to all the other keys on your keyboard. Hammerspoon enables this behaviour by defining a completely new “modal” key, over which you have complete control. While it is most natural to enable and disable this mode in tandem with a key-press and -release, you can actually enable it whenever you like.</p><p>Hammerspoon does require a little help to get this done. That help comes from Karabiner, a tool for reassigning keys on your keyboards. Karabiner can do a whole lot more, but right now this is all I use it for (and for remapping Windows-keyboards to proper Mac-layout 😇).</p><h4>Setting up Karabiner</h4><p>You can begin by <a href="https://karabiner-elements.pqrs.org/">downloading Karabiner-Elements from its website</a>. Once installed, start it and make sure it starts when you login. Then, you can start remapping keys in the <em>Simple modifications</em> tab, view your currently connected devices in the <em>Devices</em> tab (and later also disconnected devices, since Karabiner remembers them).</p><p>To start setting up the Hyper key, create a new item on the <em>Simple modifications</em> tab and remap the right_option to f18 for all devices. Of course this is where you can choose which key should be your Hyper key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n88QnD2tmFN2tJaBWYmraA.png" /><figcaption>Remapping a key to F18 for the Hyper key</figcaption></figure><p>Why F18 you ask? Well, it’s a key that’s (probably) not on your keyboard and yet MacOS supports function keys up to 20. That means anything above F12 is free to use for these things. F18 is just the value that was used in an example I once found, which led to this setup. It kinda stuck.</p><h4>Setting up Hammerspoon</h4><p>Hammerspoon is an interface between a Lua scripting engine and various MacOS APIs. For more information on its capabilities and ways to install it, please see <a href="https://medium.com/@jhkuperus/introducing-hammerspoon-personal-productivity-d32c0c825caf">my previous post about it</a>.</p><p>If you are not familiar with Hammerspoon and/or Lua, I suggest you put the coming code snippets in a file ~/.hammerspoon/hyper.lua and import it from a file ~/.hammerspoon/init.lua. This will allow you to follow the post below exactly and keep your init.lua clean so you can more easily add other features to it later.</p><p>Now that right_option is causing keypress/-release events for f18, we can use Hammerspoon to tap into the MacOS keyboard event system and create our own layer of keys.</p><p>The feature we will use for this is called hs.hotkey.modal. It allows us to create a keyboard mode, which we can programmatically turn on and off. To turn it on and off, we use the events from the f18 key we remapped in Karabiner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*bY3hb0a2p4Cyw8yzt-sKCw.png" /><figcaption>How Hammerspoon’s modal works to create a new keyboard modifier state</figcaption></figure><p>Let’s see what this would look like in the Lua script (put it in ~/.hammerspoon/hyper.lua (or if you’re impatient, <a href="https://github.com/jhkuperus/dotfiles/blob/master/hammerspoon/hyper.lua">download it here</a>):</p><pre>local This = {}</pre><pre>-- Hyper mode needs to be bound to a key. Here we are binding<br>-- it to F17, because this is yet another key that&#39;s unused.<br>-- Why not F18? We will use key-events from F18 to turn hyper<br>-- mode on and off. Using F17 as both the modal and source of key<br>-- events will result in a very jittery Hyper mode.</pre><pre>This.hyperMode = hs.hotkey.modal.new({}, &#39;F17&#39;)</pre><pre>-- Enter Hyper Mode when Hyper-key is pressed<br>function enterHyperMode()<br>   This.hyperMode:enter()<br>end</pre><pre>-- Leave Hyper Mode when Hyper-key is pressed<br>function exitHyperMode()<br>   This.hyperMode:exit()<br>end</pre><p>This is the base of the Hyper mode. The new modal that is created, which can be turned on and off using the enterHyperMode and exitHyperMode functions. Now we still need to bind to some keyboard events to actually enable the Hyper key.</p><pre>-- Binds the enter/exit functions of the Hyper modal to all<br>-- combinations of modifiers<br>function This.install(hotKey)<br>  hs.hotkey.bind({}, hotKey, enterHyperMode, exitHyperMode)<br>  hs.hotkey.bind({&quot;shift&quot;}, hotKey, enterHyperMode, exitHyperMode)<br>  hs.hotkey.bind({&quot;ctrl&quot;}, hotKey, enterHyperMode, exitHyperMode)<br>  hs.hotkey.bind({&quot;ctrl&quot;, &quot;shift&quot;}, hotKey, enterHyperMode,<br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;cmd&quot;}, hotKey, enterHyperMode, exitHyperMode)<br>  hs.hotkey.bind({&quot;cmd&quot;, &quot;shift&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;cmd&quot;, &quot;ctrl&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;cmd&quot;, &quot;ctrl&quot;, &quot;shift&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;alt&quot;}, hotKey, enterHyperMode, exitHyperMode)<br>  hs.hotkey.bind({&quot;alt&quot;, &quot;shift&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;alt&quot;, &quot;ctrl&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;alt&quot;, &quot;ctrl&quot;, &quot;shift&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;alt&quot;, &quot;cmd&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;alt&quot;, &quot;cmd&quot;, &quot;shift&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;alt&quot;, &quot;cmd&quot;, &quot;ctrl&quot;}, hotKey, enterHyperMode, <br>    exitHyperMode)<br>  hs.hotkey.bind({&quot;alt&quot;, &quot;cmd&quot;, &quot;shift&quot;, &quot;ctrl&quot;}, hotKey, <br>    enterHyperMode, exitHyperMode)<br>end</pre><pre>return This</pre><p>The install function will bind to all of the events of the key passed in through the parameterhotkey. It binds both a key press and a key release function, to turn the Hyper-mode on and off.</p><p>Now we have the basics and we can use this to bind arbitrary Lua-functions to keys combined with our Hyper-key. Here is an example init.lua file which imports the Hyper mode and binds a few keys:</p><pre>-- Load and install the Hyper key extension. Binding to F18<br>local hyper = require(&#39;hyper&#39;)<br>hyper.install(&#39;F18&#39;)</pre><pre>-- Quick Reloading of Hammerspoon<br>hyper.bindKey(&#39;r&#39;, hs.reload)</pre><pre>-- Global Application Keyboard Shortcuts<br>hyper.bindKey(&#39;p&#39;, function()<br>    am.switchToAndFromApp(&quot;com.spotify.client&quot;)<br>  end)<br>hyper.bindShiftKey(&#39;p&#39;, function()<br>    hs.spotify.displayCurrentTrack()<br>  end)<br>hyper.bindKey(&#39;]&#39;, function()<br>    am.switchToAndFromApp(&quot;com.googlecode.iterm2&quot;)<br>  end)</pre><p>These are just a few examples of what you can do. The am.switchToAndFromApp is part of another extension, which I will be sharing shortly in a follow-up post. If you’re ready to get to know Hammerspoon, <a href="https://www.hammerspoon.org/docs/">browse the docs</a> and find something fun to do.</p><p>Congratulations, you have unlocked your very own Hyper-key. Thanks for reading and please come back again soon for some inspiration to use it (for serious stuff and fun 😇).</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cb8838bf521" width="1" height="1" alt=""><hr><p><a href="https://medium.com/macoclock/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521">Solve Shortcut Hell in MacOS — Building a Hyper Key</a> was originally published in <a href="https://medium.com/macoclock">Mac O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Staying Sane Working From Home]]></title>
            <link>https://medium.com/@jhkuperus/staying-sane-working-from-home-bcf3de0ff30b?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcf3de0ff30b</guid>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[working-from-home]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Sun, 29 Mar 2020 21:38:50 GMT</pubDate>
            <atom:updated>2020-03-30T08:01:22.191Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_w6981z7qd4eVkA2hE-FQ.png" /><figcaption>Photo by <a href="https://www.pexels.com/@kaboompics?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Kaboompics .com</a> from <a href="https://www.pexels.com/photo/women-s-working-space-6259/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><p>In this new (hopefully temporary) reality, you’ve been forced to work from home. Opinions differ on whether working from home is more or less productive than working from the office. Let’s leave that argument for what it is though.</p><p>Do you feel like you’re underperforming? Perhaps you feel you can’t concentrate enough? Are there too many other things to do around the house? Have you started drawing your co-workers’ portraits on the wall?</p><p>Me and my teammates have been working from home on and off for the past two years. Basically every person on our team has had one fixed working-from-home-day and could occasionally work from home several days at a time, when the need arose.</p><p>We have had ample time to test and refine parts of our process to both stay productive and sane when working remote. Some of these things are long standing staples, some have been pushed forward by the current pandemic conditions.</p><h4>Set yourself a schedule</h4><p>At the office, you probably have a “simple” schedule, like 9 to 5. You’ll have a full block of 8 hours to be in the work-mindset and very little to distract you. At least, very little home-bound things to distract you. You won’t drive home and do the laundry mid-working-day.</p><p>At home, this completely reversed. You are now in the same space where all your other todo-items are. That room you still need to tidy up. That pile of books you wanted to read through. The game that is just sitting in your console waiting to be played. It can definitely be hard to just work 8 hours straight in these conditions. Especially if you have a family that is now also home 24/7.</p><p>To counter this, divide your day into blocks. Blocks where you will focus on work and blocks where you will focus on home-life. This comes in handy when you have kids and partner to share time with. Your partner and you can take shifts doing the work-blocks and home-blocks.</p><p>I’ve found it a lot easier to sit down and focus on work for two hours in a row and then allowing my activities to divert energy from work. It is however important to stick to it. Also because your teammates will expect you to be available in your blocks. Oh that’s right, <em>you should communicate your schedule with your team!</em></p><h4>Accept the high cognitive load</h4><p>These are crazy times. You will be distracted by a news report, or funny tweet going around the planet. Everybody is in the same situation, under the same stress of social distancing and/or quarantine measures. This is undoubtedly going to make it harder to concentrate.</p><p>Accept it. It is part of our reality now and would be counter-productive to pretend you have to “let it go and just go to work”.</p><p>Don’t forget to be okay with it when you get distracted. Being kind to yourself is half the job. In fact, it can be a tremendous help if you allow yourself regular off-time. Let’s get to that in the next section.</p><h4>Allow yourself time off</h4><p>At the office, no single person is productive 100% of the time. Anyone who claims to be, is either lying or has reason to seek out a therapist. Here’s a little list of things that happen in an office and can certainly not be seen as “productive”:</p><ul><li>coffee-breaks</li><li>lunches</li><li>time before and after meetings</li><li>colleagues celebrating their birthday</li><li>people that walk in and have a pressing question (at least they often believe it’s pressing, even if it isn’t)</li></ul><p>To be happy with your work and actually be productive, you should allow for these kinds of things when working from home. Recently I’ve found a nice routine where I work in pomodoro’s (or pomodori for you Italian-savvy readers out there 😉).</p><p>Each pomodoro-session requires me to work 25 minutes undisturbed on a single task. Once that session is over, I get a 5 minute break. When I am working like this, I often have a turn-based game sitting in the background. Whenever my pomodoro finishes, I switch to the game, play a few turns and then get back working on the next 25-minute increment.</p><h4>Be kind to yourself!</h4><p>I mentioned it already, but it’s worth repeating. You will feel like you should have done more, should have concentrated more. This is just because there are fewer external sources of distraction.</p><p>Sometimes it’s even better to embrace the distraction. If you’re working on a hard problem, or repetitive task and you feel like you’ve hit a wall, stop, drop and do something else. If the laundry is calling you, do that. If the car needs a good scrubbing, get wet! If the kids are asking you to build that mega-Lego-railroad you’ve been promising them for years, do it.</p><p>These tasks will allow you to break out of the patterns that were holding you back on your work. Your brain will welcome the change of pace and almost always come up with a solution during this “recreational” time.</p><h4>Nurture your mental and physical health</h4><p>Sitting is the new smoking. Being home-bound can weigh on you. Make sure to make and take time for exercise. Exercising your brain is easy: read a book, find and follow an online yoga class, play chess, or talk to your spouse/partner/roommate.</p><p>Physical exercise can be difficult if you don’t have gym-equipment at home. I don’t. That doesn’t stop me from doing a few sets of push-ups and sit-ups every morning. It’s maybe not a full workout, but it keeps me active in times where it is too easy to sit down and do nothing.</p><h4>Stay in touch!</h4><p>When working from home, you may find the ability to have “crunch-time” always on a good thing for a few days, but at some point you will need contact with a teammate.</p><p>Actually, the only way a team can maintain productivity as a whole while working remote is communication and rituals. Maintain those rituals. We’ve even setup additional rituals to stay in contact. We’re playing games through our chat-channels; have extra coffee-break video-calls in pairs and are extra vigilant that everyone is online during our standup-calls.</p><h4>Physical-distancing vs Social-distancing</h4><p>Finally, remember that when we’re told to uphold social distancing with a minimum of 1.5 meters, what policymakers actually mean is physical distancing. This is the time to do Social-bonding through media that allow us to uphold physical-distancing.</p><p>Feel free to share additional tips and tricks to stay sane in the comments!</p><p>Cheers and stay safe and sane,</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcf3de0ff30b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Hammerspoon — Personal Productivity]]></title>
            <link>https://medium.com/@jhkuperus/introducing-hammerspoon-personal-productivity-d32c0c825caf?source=rss-3fb0a5abe9b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d32c0c825caf</guid>
            <category><![CDATA[power-user]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[hammerspoon]]></category>
            <dc:creator><![CDATA[Jan-Hendrik Kuperus]]></dc:creator>
            <pubDate>Mon, 23 Mar 2020 08:26:00 GMT</pubDate>
            <atom:updated>2020-06-16T22:10:39.282Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y96u2PN6Y69VLB9BbUAkYQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@toddquackenbush?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Todd Quackenbush</a> on <a href="https://unsplash.com/s/photos/hammer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introducing Hammerspoon — Personal Productivity</h3><p>Hammers and spoons… Not exactly two items you’ll be using together a lot in daily life. But, when it comes to automating things in MacOS, it’s like bringing the power of shell scripting to the level of the Graphical User Interface of MacOS. I’ll leave it up to you which is the hammer and which the spoon.</p><p>So what the heck is Hammerspoon you ask? Well, from its own website it says that <em>at its core, Hammerspoon is just a bridge between the operating system and a Lua scripting engine.</em> That really is it. If you want it to do anything cool, you’ll have to either download a script for it, or write it yourself. Once you do, there’s not much you cannot do in MacOS.</p><p>I remember when Hammerspoon was first recommended to me. I was complaining about how applications and the MacOS system sometimes fight about keyboard shortcuts. Back then, I was outraged that some of the shortcuts of my window-management utility were hijacked by other applications. That’s when I learned how to turn my right-⌥ into a new modifier: the Hyper-key.</p><p>The creation of this <a href="https://medium.com/@jhkuperus/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521">Hyper-key is a post on its own</a>. Suffice it to say it’s such an extremely powerful function, that basically all my keyboard shortcut magickery spawned from it. So is Hammerspoon just a keyboard-shortcut-creating-tool? Not at all, you can respond to a whole array of triggers, some of which I’ve listed here:</p><ul><li>Watch for Application Events</li><li>Watch for File System Events</li><li>Watch for Network Events</li><li>Watch for Battery Events</li><li>etc. etc.</li></ul><p>Just imagine what you can do with any of these triggers when you combine them with other APIs Hammerspoon offers. Here’s another non-exhaustive list of things Hammerspoon can do:</p><ul><li>Control applications and windows</li><li>Draw directly onto the screen</li><li>Control your computer’s power state</li><li><a href="https://medium.com/@jhkuperus/turn-your-keyboard-into-a-soundboard-a2387c8dea01">Play sounds and music directly</a></li><li>Show informative or interactive dialogs</li><li>Perform actions on the filesystem</li><li>Perform HTTP requests</li><li>Host an HTTP server</li><li>Send iMessage or SMS through your phone</li><li>Run arbitrary AppleScript</li></ul><p>As with an earlier post of mine introducing the Alfred app, this post marks the beginning of a set of posts describing automations I have built on my development system. Most of these are aimed at making my life easier, by allowing me to use as little effort as needed to get certain mundane tasks done. There are also a few more fun-inspired things you can do with Hammerspoon, those will definitely be highlighted in their own posts as well.</p><p>The next post in this series will be <a href="https://medium.com/macoclock/solve-shortcut-hell-in-macos-building-a-hyper-key-1cb8838bf521">how to install Hammerspoon and Karabiner and how to create a new modifier for all your shortcuts: the Hyper key</a>.</p><p>Cheers!</p><p>— JH</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d32c0c825caf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>