<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>ericliu.ca RSS feed</title><description>Eric Liu&apos;s blog</description><link>https://www.ericliu.ca</link><item><title>Using Hammerspoon for macOS tweaks</title><link>https://www.ericliu.ca/blog/hammerspoon-intro</link><guid isPermaLink="true">https://www.ericliu.ca/blog/hammerspoon-intro</guid><description>Back when I used Windows as my daily OS, I used Task Scheduler a lot to automate small tasks. When I switched to macOS, I did some searching online and fo…</description><pubDate>Sat, 24 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Back when I used Windows as my daily OS, I used Task Scheduler a lot to automate small tasks&lt;sup&gt;&lt;a href=&quot;#user-content-fn-vencord&quot; id=&quot;user-content-fnref-vencord&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. When I switched to macOS, I did some searching online and found that launchd jobs (cron jobs were &lt;a href=&quot;https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html&quot;&gt;deprecated&lt;/a&gt;) are the usual way to automate scheduled tasks on macOS.&lt;/p&gt;
&lt;p&gt;However, I quickly got tired of creating a .plist file for every single automation I wanted to set up. Plists for launchd jobs have a lot of boilerplate for even simple jobs and I personally think XML is quite verbose compared to JSON or YAML. For example, one simple task I had was to periodically dump my installed packages from Homebrew for backup purposes. You would first have to create a plist file with the following contents:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-xml&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&amp;gt;
&amp;lt;plist version=&quot;1.0&quot;&amp;gt;
&amp;lt;dict&amp;gt;
    &amp;lt;key&amp;gt;Label&amp;lt;/key&amp;gt;
    &amp;lt;string&amp;gt;updatebrewfile&amp;lt;/string&amp;gt;
    &amp;lt;key&amp;gt;ProgramArguments&amp;lt;/key&amp;gt;
    &amp;lt;array&amp;gt;
        &amp;lt;string&amp;gt;/bin/bash&amp;lt;/string&amp;gt;
        &amp;lt;string&amp;gt;/Users/newwares/bin/update-brewfile.sh&amp;lt;/string&amp;gt;
    &amp;lt;/array&amp;gt;
    &amp;lt;key&amp;gt;StandardErrorPath&amp;lt;/key&amp;gt;
    &amp;lt;string&amp;gt;/tmp/updatebrewfile.err&amp;lt;/string&amp;gt; &amp;lt;!-- apparently these were optional --&amp;gt;
    &amp;lt;key&amp;gt;StandardOutPath&amp;lt;/key&amp;gt;
    &amp;lt;string&amp;gt;/tmp/updatebrewfile.out&amp;lt;/string&amp;gt;
    &amp;lt;key&amp;gt;StartInterval&amp;lt;/key&amp;gt;
    &amp;lt;integer&amp;gt;3600&amp;lt;/integer&amp;gt;
&amp;lt;/dict&amp;gt;
&amp;lt;/plist&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then a separate file somewhere else with the actual script&lt;sup&gt;&lt;a href=&quot;#user-content-fn-brewfile&quot; id=&quot;user-content-fnref-brewfile&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;#!/bin/bash
/opt/homebrew/bin/brew bundle dump --global --force
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Needing to keep track of 2 files and 19 lines of XML for a 1-line script was not okay. I quickly started searching for an alternative to launchd and came across Hammerspoon.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.hammerspoon.org/&quot;&gt;Hammerspoon&lt;/a&gt; is a scriptable macOS automation tool. It exposes many macOS APIs via Lua, so you have a lot of control over how you organize your automations and can do a lot more than just cron jobs. The code to do the same task of dumping a Brewfile now becomes:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-lua&quot;&gt;local M = {}
M.brewfile_timer = hs.timer.doEvery(3600, function()
	hs.execute(&quot;/opt/homebrew/bin/brew bundle dump --global --force&quot;)
end)
return M
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is much more concise! One pitfall when using Hammerspoon is that if you create a timer, watcher or anything that needs to be long-lived, you &lt;em&gt;must&lt;/em&gt; ensure it is reachable throughout Hammerspoon’s runtime. Otherwise, the Lua garbage collector will clean it up and your watcher will stop working. Usually this means assigning the result to a variable and exposing it globally. In order to avoid cluttering the global scope, I assigned the result to a table that a loader file then requires. This is a common idiom in regular Lua as well.&lt;/p&gt;
&lt;p&gt;Over time, I set up more sophisticated scripts to tweak macOS behaviour that I wouldn’t be able to do natively. Some of my current tweaks are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: My keyboard’s RGB config resets itself every time it loses connection.&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Set up a USB watcher that calls a simple script using &lt;a href=&quot;https://github.com/srwi/qmk-via-api&quot;&gt;qmk-via-api&lt;/a&gt; to set my desired RGB as soon as my keyboard gets a USB connection.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: When I play music with earbuds in, my volume is sometimes set too high at first which causes discomfort.&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: Watch for Spotify’s &lt;code&gt;com.spotify.client.PlaybackStateChanged&lt;/code&gt; &lt;a href=&quot;https://www.hammerspoon.org/docs/hs.distributednotifications.html&quot;&gt;distributed notification&lt;/a&gt; and if I’m using earbuds, set my volume to a fixed number of ticks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: When editing Markdown or Typst files in Neovim, I don’t have an easy way to do a split-screen live preview like in VS Code. The most well-known Markdown/Typst live preview plugins require opening a localhost URL in a web browser to see the preview.&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;: This one was more involved than the other automations I had&lt;sup&gt;&lt;a href=&quot;#user-content-fn-nvim-preview&quot; id=&quot;user-content-fnref-nvim-preview&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;. The main idea is to have Neovim and Hammerspoon communicate through Hammerspoon &lt;a href=&quot;https://www.hammerspoon.org/docs/hs.urlevent.html&quot;&gt;URL schemes&lt;/a&gt;. Configure the Typst/Markdown preview Neovim plugin to also open the Hammerspoon URL scheme when starting the preview, passing the localhost URL as a query parameter. Then, in Hammerspoon, handle that URL event and launch a guest-mode web browser with the provided localhost URL. Simultaneously, arrange the Neovim window and the browser window to create a split-screen view. To clean up after quitting Neovim, close the browser and restore the original window layout.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A lot of the functionality I required (USB connection watching, checking the primary audio output) is built into Hammerspoon’s Lua API already, so it’s easy to use. Another great thing about being able to use Hammerspoon for all of my automation needs is that everything is in one place. That way, when something behaves unexpectedly, I only have to check one location.&lt;/p&gt;
&lt;p&gt;Overall, I think Hammerspoon is a pretty painless way to tweak macOS. I managed to achieve everything that I wanted to do (for now) and it wasn’t difficult to learn Hammerspoon when I first tried it out.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-vencord&quot;&gt;
&lt;p&gt;The most memorable use was for keeping my &lt;a href=&quot;https://github.com/Vendicated/Vencord&quot;&gt;Vencord&lt;/a&gt; fork up to date with upstream. Every time I logged in, a terminal window would pop up running &lt;code&gt;git pull &amp;amp;&amp;amp; pnpm build --dev&lt;/code&gt; for 10 seconds or so. I couldn’t find a clean way to hide the terminal popup, so I just lived with it. &lt;a href=&quot;#user-content-fnref-vencord&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-brewfile&quot;&gt;
&lt;p&gt;I actually use more arguments to dump tools that aren’t installed through Homebrew as well, like cargo/uv/npm/App Store, but I wanted to keep this snippet simple. &lt;a href=&quot;#user-content-fnref-brewfile&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 2&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;user-content-fn-nvim-preview&quot;&gt;
&lt;p&gt;This took 50 lines of code in Hammerspoon and 5 lines in Neovim. &lt;a href=&quot;#user-content-fnref-nvim-preview&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 3&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded></item><item><title>My courses</title><link>https://www.ericliu.ca/blog/course-list</link><guid isPermaLink="true">https://www.ericliu.ca/blog/course-list</guid><description>These are all the courses (excluding PD) that I’ve completed at the University of Waterloo so far.</description><pubDate>Thu, 15 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;These are all the courses (excluding PD) that I’ve completed at the University of Waterloo so far.&lt;/p&gt;
&lt;h3&gt;CS&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;CS 145 (functional programming)&lt;/li&gt;
&lt;li&gt;CS 146 (C, interpreters, compilers)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Math&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;MATH 135 (algebra/intro to number theory)&lt;/li&gt;
&lt;li&gt;MATH 137 (calculus 1)&lt;/li&gt;
&lt;li&gt;MATH 136 (linear algebra 1)&lt;/li&gt;
&lt;li&gt;MATH 138 (calculus 2)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Other&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;COMMST 223 (public speaking)&lt;/li&gt;
&lt;li&gt;SCI 206 (physics of how things work)&lt;/li&gt;
&lt;li&gt;ENGL 108D (digital lives)&lt;/li&gt;
&lt;li&gt;ECON 101 (intro to microeconomics)&lt;/li&gt;
&lt;/ul&gt;
</content:encoded></item><item><title>Books are awesome</title><link>https://www.ericliu.ca/blog/books-are-awesome</link><guid isPermaLink="true">https://www.ericliu.ca/blog/books-are-awesome</guid><description>Note: I will only be talking about fiction books in this post The last time I read a book for fun was probably back in elementary school. I remember enjoy…</description><pubDate>Thu, 15 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;em&gt;Note: I will only be talking about fiction books in this post&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The last time I read a book for fun was probably back in elementary school. I remember enjoying &lt;em&gt;The 39 Clues&lt;/em&gt; back then. Between then and now, I only read books because they were assigned to me in class, and it’s difficult to enjoy them when there are deadlines for reading or when you’re trying to extract talking points for a literary commentary.&lt;/p&gt;
&lt;p&gt;Another reason I quit reading for fun was that reading a new book requires you to trust the author: you first have to read the first ~100 pages to get through the exposition and internalize the names of the characters. After that, if the book falls flat, then that initial investment of time is wasted. After I experienced this several times in a row, I became hesitant to start new books.&lt;/p&gt;
&lt;p&gt;My primary form of entertainment had ended up being video games and TV shows. Recently, I noticed that I mainly liked my current games because of their overarching stories. At the same time, I was getting dissatisfied with the consistency of story quality in those games&lt;sup&gt;&lt;a href=&quot;#user-content-fn-genshin&quot; id=&quot;user-content-fnref-genshin&quot; data-footnote-ref aria-describedby=&quot;footnote-label&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. Since I knew I was looking for consistent story quality and since my current forms of entertainment weren’t satisfying those needs, I decided to reconsider reading.&lt;/p&gt;
&lt;p&gt;I asked around for book recommendations and settled on the &lt;em&gt;Red Rising&lt;/em&gt; series, which is set in a dystopia (one of my favourite genres). As a quick intro to the premise, humans are born into Colors, which determine their social status and physical traits. Reds are of the lowest status, while Golds are the highest.&lt;/p&gt;
&lt;p&gt;There are several reasons why I came to enjoy the series so much:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The premise/setting is intriguing, which helps alleviate exposition boredom&lt;/li&gt;
&lt;li&gt;The characters (not just the protagonist) are smart and use that to set up unexpected twists&lt;/li&gt;
&lt;li&gt;The books are very consistent in terms of story quality&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Red Rising&lt;/em&gt; has reinspired my love for reading. Even when I was only halfway through the first book, my enjoyment had far surpassed the enjoyment I derived from (story-focused) video games and TV shows/movies.&lt;/p&gt;
&lt;p&gt;I’m also more likely to stick with book series because after finishing a really good first book, the next books can be read without having to relearn exposition. It’s much easier to trust the author to write a good next book if their previous books were good.&lt;/p&gt;
&lt;p&gt;I’m currently on the fifth book in the series (&lt;em&gt;Dark Age&lt;/em&gt;), but if you don’t want to get spoiled, don’t look at the descriptions of the later books yet. If your reading preferences match mine, then I highly recommend checking this series out.&lt;/p&gt;
&lt;section data-footnotes class=&quot;footnotes&quot;&gt;&lt;h2 class=&quot;sr-only&quot; id=&quot;footnote-label&quot;&gt;Footnotes&lt;/h2&gt;
&lt;ol&gt;
&lt;li id=&quot;user-content-fn-genshin&quot;&gt;
&lt;p&gt;For example, Genshin Impact only has good story moments every two years or so in my opinion. &lt;a href=&quot;#user-content-fnref-genshin&quot; data-footnote-backref=&quot;&quot; aria-label=&quot;Back to reference 1&quot; class=&quot;data-footnote-backref&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content:encoded></item><item><title>First post</title><link>https://www.ericliu.ca/blog/first</link><guid isPermaLink="true">https://www.ericliu.ca/blog/first</guid><description>Redoing the styling of my website really exposed how little content I have on here: just social links and projects. I’m partially starting this blog to fi…</description><pubDate>Wed, 14 Oct 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Redoing the styling of my website really exposed how little content I have on here: just social links and projects. I’m partially starting this blog to fill up the space, but I think it’d be nice to have the option to document my thoughts here as well.&lt;/p&gt;
&lt;p&gt;I like Svelte’s ease of use, but I decided to use Astro instead of SvelteKit because of Astro’s primary focus and optimizations for static sites. For example, each blog post here is a markdown file that Astro processes into its own page, and it autogenerates TypeScript types for each post’s metadata. If I need client-side JS in the future, then Astro also supports multiple UI frameworks (like Svelte), so it should be pretty painless to add.&lt;/p&gt;
&lt;p&gt;Putting some time into font selection also finally made me realize why I dislike Times New Roman: the stroke contrast is too high.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;table style=&quot;table-layout: fixed; width: 100%; text-align: center;&quot;&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Times New Roman&lt;/th&gt;
      &lt;th&gt;Georgia&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;
        &lt;span style=&quot;display: block; font-size: 35cqi; line-height: 1; font-family: &apos;Times New Roman&apos;, serif&quot;&gt;N&lt;/span&gt;
      &lt;/td&gt;
      &lt;td&gt;
        &lt;span style=&quot;display: block; font-size: 35cqi; line-height: 1; font-family: Georgia, serif&quot;&gt;N&lt;/span&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Georgia is a bit better and I ended up going with it.&lt;/p&gt;
</content:encoded></item></channel></rss>