Jason's Blog

A stochastic thought repository

Farewell Google Reader

| Comments

Google has announced that they are closing Google Reader. This is quite sad for me: Reader is (in my opinion) the best feed reader available at the moment, and one of the only reasons my wife and I have a Google account in the first place.

I’m sure that Google realizes that their main service doesn’t require a log in to use … but without logging in, we produce less valuable metrics for them to sell ads.

I’m sure that Gmail is too profitable for them to consider it now, but if they ever get rid of it, there won’t be any reason for my wife and I, at least, to log in.

How to Use Systemd Timers

| Comments

I was setting up some scripts to run backups recently, and decided I would try to set them up to use systemd timers rather than the more familiar to me cron jobs.

As I went about trying to set them up, I had the hardest time, since it seems like the required information is spread around in various places. I wanted to record what I did so firstly, I can remember, but also so that others don’t have to go searching as far and wide as I did.

There are additional options associated with the each step I mention below, but this is the bare minimum to get started. Look at the man pages for systemd.service, systemd.timer, and systemd.target for all that you can do with them.

Running a Single Script

Let’s say you have a script /usr/local/bin/myscript that you want to run every hour.

Service File

First, create a service file, and put it wherever it goes on your Linux distribution (on Arch, it is either /etc/systemd/system/ or /usr/lib/systemd/system).

myscript.service
1
2
3
4
5
6
[Unit]
Description=MyScript

[Service]
Type=simple
ExecStart=/usr/local/bin/myscript

Note that it is important to set the Type variable to be “simple”, not “oneshot”. Using “oneshot” makes it so that the script will be run the first time, and then systemd thinks that you don’t want to run it again, and will turn off the timer we make next.

Timer File

Next, create a timer file, and put it also in the same directory as the service file above.

myscript.timer
1
2
3
4
5
6
7
8
9
10
11
12
[Unit]
Description=Runs myscript every hour

[Timer]
# Time to wait after booting before we run first time
OnBootSec=10min
# Time between running each consecutive time
OnUnitActiveSec=1h
Unit=myscript.service

[Install]
WantedBy=multi-user.target

Enable / Start

Rather than starting / enabling the service file, you use the timer.

1
2
3
4
# Start timer, as root
systemctl start myscript.timer
# Enable timer to start at boot
systemctl enable myscript.timer

Running Multiple Scripts on the Same Timer

Now let’s say there a bunch of scripts you want to run all at the same time. In this case, you will want make a couple changes on the above formula.

Service Files

Create the service files to run your scripts as I showed previously, but include the following section at the end of each service file.

1
2
[Install]
WantedBy=mytimer.target

If there is any ordering dependency in your service files, be sure you specify it with the After=something.service and/or Before=whatever.service parameters within the Description section.

Alternatively (and perhaps more simply), create a wrapper script that runs the appropriate commands in the correct order, and use the wrapper in your service file.

Timer File

You only need a single timer file. Create mytimer.timer, as I outlined above.

Target File

You can create the target that all these scripts depend upon.

mytimer.target
1
2
3
4
[Unit]
Description=Mytimer
# Lots more stuff could go here, but it's situational.
# Look at systemd.unit man page.

Enable / Start

You need to enable each of the service files, as well as the timer.

1
2
3
4
5
systemctl enable script1.service
systemctl enable script2.service
...
systemctl enable mytimer.timer
systemctl start mytimer.service

Good luck.

Bastion on Linux

| Comments

I just finished playing through the main story line of Bastion. It was an amazing game, especially the music.

Getting the best performance out of it on my Arch Linux box was, however, a bit difficult, so with this short post I want to let others avoid a bit of frustration and enjoy the game to its fullest.

  • First, make absolutely sure you have compositing1 turned off. With it on, the video would stutter horribly (1 or less FPS) at some random point in the game. Switching to a different virtual desktop would temporarily fix the issue, but about 1/3 of the time this would crash the game.

    How do you know if you have compositing turned on? If your desktop uses any animation or transparency, odds are you do.

  • Ensure you have the latest stable drivers for your video card.

  • If the game crawls in scenes with rain or snow, turn it off in the game’s source files. On my machine, the game was installed to /opt/games/Bastion. From that directory, run the following search and replace command as root (or via sudo):

1
2
  sed -i 's/MaxFlyers=".*/MaxFlyers="0"/g' Content/Game/FlyerSettings.xml

If you haven’t had a chance to play this great game yet, give it a try.

Other (Linux specific) tweaks applicable for gaming:

  • Arch Wiki Gaming
  • Windows API implementation for Linux: Wine
  1. To turn this off, search on Google for “compositing” along with your Linux distribution and / or window manager. For me (Arch Linux, xmonad), I made sure that xcompmgr wasn’t called in my .xinitrc.

My Path to Arch Linux

| Comments

When I started using Linux 5 years ago, Ubuntu was a wonderful distribution for me. It was easy to set up, made access to drivers easy, and had a giant repository of software. Between Octave and the myriad of programming tools available, I was set for my engineering coarsework1. And for downtime, Wine let me satisfy my World of Warcraft addiction.

Over time, my computing aesthetic taste gradually trended minimalist. I realized while Ubuntu comes by default with a wealth of useful applications installed by default, I never used them. They cluttered my menus and disk drive. My next several Ubuntu installs used the text based alternate installer to build up only what I needed from a clean slate.

Simultaneously, I explored shell scripting, using conky to keep track of my system status, mutt to view my email in the terminal, and vim to edit my files. I realized that I felt more in control of my computing experience this way. I was hooked.

All this time I was using Gnome 2 as my desktop environment, but was intersting in trying alternatives. The Gnome Project’s introduction of version 3 of their desktop environment, and Ubuntu’s switch to Unity gave me the excuse I needed to do so, since I would be switching anyway.

And since I was looking for alternatives, why not try a different distribution too? Arch Linux seemed like a great alternative to someone with my tastes. The project aims to be simple, elegant, user-centric, open, and free (as in freedom). From the previous link, on simplicity:

Arch Linux defines simplicity as without unnecessary additions, modifications, or complications, and provides a lightweight UNIX-like base structure that allows an individual user to shape the system according to their own needs. In short: an elegant, minimalist approach.

Just what I was looking for! Moreover, they have excellent documentation through their wiki. I had never found a comparable source of knowledge for Ubuntu. I highly recommend looking through it and using it as a resource even if you don’t use Arch.

I’ve been using Arch for almost a year now. I have 3 machines running it:

  • My desktop, using xmonad as a window manager.
  • A Thinkpad laptop, using Gnome 3 so that my wife is able to find her way around as well. She doesn’t share my minimalist aesthetic.
  • I ended up renting a server on Linode that is using Arch. My home server is having some trouble, and I haven’t had the time to mess with it at a hardware level yet. I’ve been quite happy with them so far.

If you are like me, and enjoy both minimal aesthetic and the feeling of complete control over your machine, consider using Arch Linux.

Feel free to share your experiences in the comments.

  1. Indeed, looking for an alternative to buying or pirating Matlab was what lead me to try Linux in the first place. All I needed to know was that I could use Open Office to write documents and still find a way to play games.