#RPGaDay2020 1: Beginning

Reading the Fublog, I got introduced to the RPG-a-Day writing prompts. It sounded like a really cool idea, so I’ll give it a try! Each day in August 2020, there’s a word prompt to encourage us to create something cool, positive, and awesome about RPGs. As my best creative tool is words, I’ll choose to write some things.

I love that the actual roadmap for this is a hex-grid map. For RPGs with mini-based combat, I do enjoy these.

My first real introduction to RPGs was as a kid with the PC-game Baldur’s Gate. I’d read about it in a magazine, and it seemed amazing! At that time, my father made frequent business trips to America, and he’d always bring each of us kids back a present. So, that time, I asked for a cool RPG. My father went to an American store, and asked what the new cool thing was. Baldur’s Gate had just been released, so naturally the salesman convinced him to get that. When he got back to the Netherlands, I was extatic. Ever since then, I’d been hooked on RPGs in some form or another. I’ve also replayed Baldur’s Gate frequently.

Soon after, D&D 3rd edition became the next big thing in the Netherlands. Fortunately, I had some friends at high school who enjoyed all the nerdy things I did as well, and we invested in a set of D&D 3rd edition books. We played together for years, and had so many wonderful adventures. It wasn’t until we lost touch when we all went to our respective universities that I had a gap in roleplaying.

In one way or another since that first Baldur’s Gate experience, though, I’ve always been finding something to scratch that RPG itch.

My First Sed Script (That Became a Bash Script?)

Last post, I wrote about a Sed script I wrote to help me switch configurations. As always, I’ve learned a little in the meantime, and I’ve updated the script to reflect that. As a result, it’s not a Sed script anymore, but a Bash script that calls on Sed directly to perform tasks.

I noticed that I was not being very efficient. For one, I created three files to do something that could be done in one. For another, two of those files (the Sed scripts) were virtually identical, with only two words being changed in four instances. When saw what I had done, I was reminded of a thing I read somewhere, but sadly cannot recall where:

If you’re doing something more than once, you’re not using a computer correctly.

Anonymous?

It’s a little provocative, of course, but I like the central idea of it. A computer is meant to automate tasks, and if you, the human user, are repeatedly performing the same task, surely you should let the computer handle that? Furthermore, there’s an added risk of error: I could edit one file and forget to edit the others to match. Or, of course, were I to write a much, much larger program, copy-pasting the same code only leads to a less legible program in the end.

So, I figured to replace the repeated words with a variable, set in the Bash script, and that reduced the need for two separate Sed scripts. Now that I was down to just the one small script, I realized I could just put it directly in Bash. I would lose the Sed syntax highlighting in Vim (as it would be highlighting Bash), but to be fair the Sed highlights aren’t that great anyway. So, long story short, I ended up with the following, single script:

#!/bin/bash
# switch_config.sj -- Bash script to switch over i3wm configs
# $1 = switch argument

# Check what file to change
case $1 in
    -d|--desktop) to=Desktop
	    	  from=Laptop
		  ;;
    -l|--laptop)  to=Laptop
	    	  from=Desktop
		  ;;
    *) echo "Select either -d, --desktop, -l, or --laptop"; exit 1
	    	  ;;
esac

# Back up file, using \cp to avoid interactive alias
\cp config -f config.old

# Catch potential errors
if [ $# != 1 ]
	then echo "Error: please provide one argument."; exit 1
fi


echo "Swapping i3wm configuration over from $from to $to."

# Using sed, comment out one set, and uncomment the other
sed -i '
/# '"$from"'/,/^$/{
	/# '"$from"'/b
	/^$/b
	/^#/!s/\(.*$\)/\#\1/
}

/# '"$to"'/,/^$/{
	/# '"$to"'/!s/#//
}
' config

My First Sed script

2020.07.22 edit: There’s a followup to this post, that you can read here. It has an updated version of the script.

For the past weeks, I’ve been reading through O’Reilly’s Sed & Awk, 2nd Edition, to learn those powerful commandline tools. The other day, I had a practical problem for which Sed seemed like the perfect solution out of the box. It’s small, and quite trivial, but it made me proud nonetheless.

In brief, the situation I run into is that I run Manjaro Linux using the i3WM windows manager on both my desktop and laptop, and I would like to share configuration files between them; however, due to their different resolutions, I want most but not all settings to be shared. Specifically, I have a few windows I keep on a scratchpad (basically: floating windows that you can hide, as well as keep consistent across workspaces). I still tweak these files every so often as I try to add features I like or adjust the look of this or that. I then share the config file between my two PCs, which leads me to having to adjust a few settings:

 # Laptop configuration
 for_window [class="^popup_term$"] resize set 960 540
 for_window [class="^popup_note$"] resize set 455 758
 bindsym $mod+equal [class="^popup_note$"] scratchpad show, move position 906 5
  
 # Desktop configuration
 #for_window [class="^popup_term$"] resize set 960 540
 #for_window [class="^popup_note$"] resize set 455 1070
 #bindsym $mod+equal [class="^popup_note$"] scratchpad show, move position 2540 324

By the way, you can see the constant tweaks here, because I used to have the popup-term class take different sizes depending on PC or laptop, but I recently settled on using the same resolutions for both. So, that one, for instance, will have to be edited out again into the general settings. The settings above used to be part of those settings, but I split them off to separate the desktop/laptop-specific configurations. Then, using my newly-gained Sed skills I made a tiny script that just comments out one set of code and removes the comments for the other:

# Commands to switch to desktop configuration

# Comment out laptop configurations
/# Laptop/,/^$/{
        /# Laptop/b
        /^$/b
        /^#/!s/\(.*$\)/\#\1/
}

# Uncomment desktop configurations
/# Desktop/,/^$/{
        /# Desktop/!s/#//
}

It’s a fairly straightforward substitution: anything between the start of the Laptop section to the first blank line gets subjected to the code. Using a branch to nowhere (using a branch without a label in Sed means it skips to the end of the script), I make sure to skip the title (I want to keep that a comment), and to skip the blank line (just to keep it looking neat). Then, a basic regex takes every line that doesn’t start with a comment and replaces those lines with a # and the line. Lastly, we do the inverse in the Desktop section: we simply replace the # character with nothing in all lines except the title. Since we’re only removing a character, there’s no need to filter out anything else.

Because I have two scripts, one for the move to desktop and one to laptop, I made a small bash script to switch between them:

#!/bin/bash
# Bash script to switch over i3wm configs

computer=

# Back up file, using \cp to avoid interactive alias
\cp config -f config.old

# Catch potential errors
if [ $# != 1 ]
        then echo "Error: please provide one argument."; exit 1
fi

# Check what file to change
case $1 in
    -d|--desktop) computer=desktop;;
    -l|--laptop) computer=laptop;;
    *) echo "Select either -d, --desktop, -l, or --laptop"; exit 1
esac

echo "Swapping configuration over to $computer."

# Implement the change using sed
if [ $computer == desktop ]
        then sed -i -f desktop.sed config
        else sed -i -f laptop.sed config
fi

This way, I don’t have to take the individual steps myself, and just use the one command to take care of it. Plus, if one day I figure out a way to check if the config file has changed from a previous version, I could use this to automate an adjustment. For now, I’m just happy I figured out a practical means of automating something I used to have to do manually each time I edited the configuration file.

Crimping Cable

Today was another step in the process of making this apartment ours: networking. We have fibre optic internet, so a theoretical 1Gbit network for our ISP; in reality, of course, we get somewhere between 7-800Gbit, but that’s still pretty great. However, up to this point, we had a ratty WiFi connection that only got us about 5-60Mbit—quite unsatisfactory. The harrowing tale of getting the Internet hooked up is for another day (possibly October 31st, given the tale), but for now I’m just happy that the first set is done.

In total, there’s a couple of stages to this project: drawing a cable from the router in the living room to the switch in the living room; installing an ethernet wall outlet there; drawing it through the bedroom, installing outlets on the other side; installing the office switch and hooking up the PCs; and, finally, drawing a cable from the living room switch to the media player switch, and connecting all the Internet media to that switch.

Now, to be clear: I’ve never done something like this before in my life. That is to say, I’ve built a network out of switches and cables, but all the cables were pre-cut, and I never put in a wall outlet before. So, today was a fun experience learning a new skill. I crimped a single cat6 cable, quite nervous about making mistakes (as the videos on it always emphasize how you need to push the cables through, and if you have a slight issue here or there, you’ll lose out on performance!). Fortunately, cutting it down to size was a breeze with the kit I bought, and crimping a new connector on it turned out to be the simplest thing ever. In fact, tacking the cable to the plinth in the living room turned out to be more of a challenge than crimping that cable was!

It’s the first of many cables, so I’m looking forward to continuing the process over the next week.

Gross Keyboard Cleaning

Every now and then, you just need to really clean your keyboard. I snack at my desk (something I really shouldn’t do with a mechanical keyboard), so every once in a while mine really needs a clean. I figured at least some of you must like watching gross stuff like this, right? In case you’re creeped out by that, just go ahead and skip this one, because there’s pictures. Lots of them.

Burning Wheel: Demoing Twilight in Verdorben Duchy

Last Friday, I ran the first session of the Twilight in Verdorben Duchy demo game of Burning Wheel for my wife and two of our friends. Since it was the first time I GMed anything in years, I wanted to keep it small and relatively simple. Burning Wheel has long-since been my absolute favorite RPG, and I was very excited to be running it again (though I also absolutely love being a player).

Continue reading “Burning Wheel: Demoing Twilight in Verdorben Duchy”

Torchbearer, 2nd Ed Kickstarter

I’ve been a fan of tabletop roleplaying games for ages. Starting out (like most) with Dungeons & Dragons, through podcasts I discovered quite a few others. Among my all-time favorites are Burning Wheel and Torchbearer. Torchbearer is having a kickstarter for the second edition right now! If you’re interested in tabletop RPG gaming, I recommend you go have a look. You won’t regret it.

Electronics: Pomodoro Timer

Now that my law degree is taking a bit of a backseat (a lot has been delayed because of the COVID-19 pandemic), I’ve dipped back into my electronics hobby. I’d basically put that on a backburner to favor the law degree. So what am I to do with so much time? Well, use my very basic electronics skills to make something to manage time!

Continue reading “Electronics: Pomodoro Timer”