Tutorial – Mastodon

Tutorial – Mastodon

Author(s):

The open and simple Mastodon API makes it easy to create applications to interact with this federated microblogging platform. Here are some of the clients that the community has come up with and how you can use them.

Last issue [1], I introduced the Fediverse [2] and, in particular, what is becoming the rising star in the federated universe: Mastodon [3]. Mastodon, a microblogging platform á la Twitter, is succeeding because it is simple to use, while at the same time packed with features. It comes with none of the shady shenanigans proprietary platforms inflict upon their users, and it looks slick, cool, and attractive.

Thanks to Mastodon's open and simple API, you can easily write scripts to interact with your account. This has led to a whole gaggle of web clients, desktop and mobile apps, and command-line tools for Mastodon.

Web Clients

To begin with, there is Mastodon's own default web interface. Your first interaction with Mastodon is probably going to be through this. It comes with a lot of features, so many that I dedicated a large chunk of last month's article to explaining all of Mastodon's ins and outs. That said, there are more web clients out there.

Halcyon [4] is one of them. Halcyon is good if you want to enjoy the simplicity of the good, old Twitter look and feel (Figure 1) – from back when Twitter actually looked good.

Figure 1: Halcyon is a web client that makes your Mastodon feed look like the old Twitter.

Then there is Mastodon Scheduler [5]. More than a web client for Mastodon, Mastodon Scheduler is a web application, one that lets you schedule toots to be posted at a later date. A word of warning, you cannot add attachments to posts submitted with Mastodon Scheduler.

For Mastodon Scheduler to work, you need to register a new application with your account. Log in to your Mastodon account, go to Settings | Development and click the New application button. Fill in the Application name text box with, say, Scheduler (although the name does not seem to matter all that much), and click SUBMIT at the bottom of the page. This will log your application with the federated network.

Now, if you click on your application's name, it will show a list of three keys at the top of the page. The key labeled Your access token is what you need to input in the Access token text box on the Mastodon Scheduler form.

Finally, Pinafore [6] is another web-based front end, which may not seem to add anything new until you try it on a mobile device (Figure 2). Then it makes sense: On a tall, narrow screen, it makes Mastodon much less intimidating than using the default web interface.

Figure 2: Pinafore makes sense as a web interface for mobile devices.

Mobile Apps

Then again, there are a lot of mobile apps that you can use to toot on Mastodon. Tusky [7], for example, is a good-looking, entry-level app. It allows you to manage several accounts simultaneously and post, boost, and draft toots. When you are browsing your timelines, you can swipe right or left and see another timeline, so you can swipe from your home, to notifications, to local, to the federated timeline, and then back again.

If you want something with more features, check out SubwayTooter [8]. Apart from allowing you to manage several accounts like Tusky, the array of options is impressive – tap the hamburger menu icon in the lower left-hand corner of the app to see them all. In addition to being able to swipe through multiple columns like in Tusky, you can display two columns at the same time when you hold your phone horizontally (Figure 3) and add new columns to the list.

Figure 3: SubwayTooter is the only mobile Mastodon client that lets you see two timelines simultaneously.

To do this, say you want to add a column that shows all posts that contain the #linux hashtag. Tap the hamburger menu (bottom left), tap the search icon (a magnifying glass), and type in your search term. That in itself already creates a new column with all the search results. However, if you tap the first result containing the hashtagged term, it will create a new column with all the toots containing the hashtag.

At the bottom of the screen, you have a kind of map that shows you where you are in the list of columns and what columns you have on the right and left. Your home timeline is represented by a house icon, notifications are a speech bubble with an exclamation mark, the local timeline is an icon of a running man for some reason, and the federated timeline is a man on a bike.

You also have a column for liked toots (represented by a star icon) and a column for conversations with other users (two overlapping speech bubbles). A hashtag column is represented by a #, and a search is represented by a magnifying glass.

If you want to get rid of a column, just tap the X in the upper right-hand corner. You can reorder columns by tapping on the hamburger menu and selecting Columns list.

SubwayTooter's other interesting feature is the possibility to schedule your toots directly from within the app. This is something that is built into Mastodon's protocol (supposedly). Some servers do not support scheduled toots, and others seem a bit flaky. Either way, it's a great idea that I am looking forward to seeing implemented more universally in the Fediverse.

Precisely to avoid the kinks, Fedilab [9], an app I started talking about last issue [1], adds one more feature: scheduling from the device itself. When you write your toot, you can choose to schedule and then decide whether you'd prefer to schedule it on the server (which, as mentioned, may not work) or let the app take charge. In my experience, the latter is more reliable. Fedilab also allows you to swipe through columns and add new ones, just like SubwayTooter.

Desktop Applications

While there are plenty Mastodon clients for mobile phones, desktop clients are pretty thin on the ground. The only one that seems to work is Whalebird [10], an Electron-based application. In other words, it is basically a thinly veiled web app wrapped in a desktop interface (Figure 4).

Figure 4: Whalebird is a desktop Mastodon application built with Electron.

The first time you run Whalebird, you give it your instance and your login details, and it will open your Mastodon instance in a web browser and ask you to authorize the application. Once you do that, it will give you an authorization code that you copy and paste into Whalebird.

Whalebird is pretty basic. Although it supports managing several accounts, it can only show one column at a time, and there are no scheduling features. It is quite pretty to look at, though.

The other tested clients did not run, did not compile, or did not contain the boasted hooks to Mastodon.

Command-Line Tooting

There are some interesting command-line clients. Mastotool [11], for example, allows you to log in to your account, search for keywords in your toots, and grab some stats (number of toots, followers, most boosted toot, highest scoring toot, accounts from other people with whom you frequently interact, etc.). That's it, and that is the author's stated purpose for it. It is kind of useful. However, since collecting data is its main point, the fact that the stats are not very comprehensive limits mastotool's usefulness.

On the other hand, toot [12] is more the real deal, allowing you to post, boost, delete, and do all sorts of things from the command line.

To configure your account run

toot login

and follow the instructions. As with Whalebird, at one point you will be required to authorize the toot with your Mastodon instance and copy and post an authorization code into the command line.

Once you are done, tooting with toot is pretty simple. The following

toot post "Tooting from toot" -m Pictures/someimage.jpg

will post "Tooting from toot" and the image to your timeline.

To print out all the available commands that allow you to poll your account, manage lists, follow other users, and so on, use:

toot help

Toot also has an experimental curses interface to read toots (Figure 5). You can scroll through your timeline's list, but that is about it – as far as I can see, you cannot boost, reply, or even switch to another timeline from the curses interface. Maybe these will be features added in a future version.

Figure 5: Toot comes with an experimental curses interface that allows you to browse your timeline from the command line.

Also interesting is madonctl [13], especially as a tool you can integrate into your own scripts.

To log into your account, run:

madonctl config dump -i your_mastodon.instance -L your@email.com -P "Your secret login password" > config.yaml

You usually need to copy the file that this creates into .config/madonctl/madonctrl.yaml, although you can point madonctl to other configuration files with the --config option

madonctl account show --config .config/madonctl/myotheraccount.yaml

This will show stats and data from your non-default account.

If you need to change anything, you can edit the file directly. A typical madonctl configuration file looks like Listing 1.

Listing 1

madonctl.yaml

01 instance: 'https://your_mastodon.instance'
02 app_id: 'e6d56c608a350735868c7884985f1f849f24d3bf43cc316a0fdfc3b1e17bccaf'
03 app_secret: '2fd94d21455cb0f494a4ef09d994f00d84ccb025e6f576ca5f0eaaa05e5b8f9b'
04
05 token: 'f-G932jfd83erfjdfij847WIOSWKsDw9sekdeII'
06 login: 'your@email.com'
07 password: 'Your secret login password'
08 safe_mode: false
09
10 #default_visibility: unlisted
11
12 #template_directory: ''
13 #default_output: theme
14 #default_theme: ansi
15 #color: auto
16 #verbose: false
17 ...

The instance value on line 1 refers to your Mastodon instance (i.e., wherever your account is hosted – mastodon.social, mastodon.technology, etc.). You do not have to supply the app_id (line 2) or the app_secret (line 3), but you do have to get a token (line 5) from your Mastodon instance. You do that by registering a new application as explained earlier when discussing Mastodon Scheduler.

Once you have completed and saved the configuration file, you can start interacting with your new account.

The command

madonctl account show

will give you data about the account you are logged into, such as the description, its ID, number of followers, number of statuses (posts), and so on. And

madonctl toot "Hello"

will post a message to your timeline.

Although neither toot nor madonctl have commands to schedule toots, it is not difficult to imagine ways of using Linux tools to do the scheduling for you. You can use the traditional at [14] command, for example, to do the trick (Figure 6). The disadvantage is that your machine will have to be on at the time the toot is scheduled.

Figure 6: You can use Linux's at tool to schedule a future toot.

Conclusion

The variety of Mastodon clients is wide and diverse, which is a testimony to how easy it is to create applications that interact with Mastodon. Although the mobile applications seem to cover most of the features that make Mastodon great (and then some), their web, desktop, and command-line counterparts all fall short.

That's why in my next installment, I'll be showing you how to easily write your own client and give it the features you need.

Until then, toot along!