The Waving Flag: Notes

Crossposting To The Fediverse

In 2018 I opened a Fediverse account. Fuelled by dissatisfaction with Twitter I hoped it would offer a saner and less toxic alternative with more focus of hobbies and wargaming. Six years on I'm still waiting for my network to fully mature, but some automation has helped speed the process.

Crossposting blog posts

This is now increasingly expensive when conventional social media sites are the target. Thankfully this isn't the case with the Fediverse. There's an excellent open source script that can be run locally on linux and automated as a cronjob: Feediverse.

Installation, as described by the authors, is straightforward unless you are using LTS Ubuntu 24.04 or it's derivatives. These versions require (suggest?) the use of pipx instead of pip:

pipx install feediverse

At the moment I crosspost three blogs with these templates in .feediverse config file:

feeds:
- include_images: false
  template: "{title} \n{link} \n{hashtags} #viaRSS\n"
  url: https://www.blogger.com/feeds/2202580486252841248/posts/default
- include_images: false
  template: "{title} \n{link} \n{hashtags} #viaRSS\n"
  url: https://draft.blogger.com/feeds/4144713597805238177/posts/default
- include_images: false
  template: "{title} \n{link} \n{hashtags} #notes #viaRSS\n"
  url: https://vexillia.bearblog.dev/feed/

With a view to automation I scripted the crossposter as follows:

#!/bin/bash
feediverse --dedupe url
exit

This works when run locally and allows me to crosspost via the system menus without having to worry about adding the dedupe switch (a highly recommended option). Naturally, running this script as a cronjob didn't work!

When feediverse was installed via pip this script worked, but the virtual environments setup by pipx makes things more complex. After much digging I discovered that the related virtual environment had to be activated before running a python script as follows:

#!/bin/bash

source /home/vexillia/.local/share/pipx/venvs/feediverse/bin/activate
python /home/vexillia/.local/share/pipx/venvs/feediverse/bin/feediverse --dedupe url

exit

Saved as feediverse_cron.sh, this script works as a cronjob (but not locally):

0 * * * * ~/System/scripts/feediverse_cron.sh

Crossposting blog comments

Feediverse has one drawback. It always posts items with their visibility set to "public". When I started to crosspost comments from my blog the moderators of my instance asked if I could post them as "unlisted" so they were just visible to my followers.

To do this I use a fork of feediverse: better_fediverse. This fork hard codes the visibility of posts, so it was a matter of minutes to locate better_feediverse.py in .local/share/pipx/venvs/better-feediverse/lib/python3.12/site-packages and change line 102 from

 masto.status_post(postbody, visibility="public")

to

masto.status_post(postbody, visibility="unlisted")

Of course, you have to remember to repeat the edit when you update the python script. A bit inelegant, but the script hasn't been updated since 2022 and works well as is.

To automate the crossposting I updated feediverse_cron.sh as follows:

#!/bin/bash

source /home/vexillia/.local/share/pipx/venvs/feediverse/bin/activate
python /home/vexillia/.local/share/pipx/venvs/feediverse/bin/feediverse --dedupe url

source /home/vexillia/.local/share/apipx/venvs/better-feediverse/bin/activate
python /home/vexillia/.local/share/pipx/venvs/better-feediverse/bin/better_feediverse

exit

This demonstrates how, with multiple python scripts, each virtual environment has to be activated before running certain scripts.

Sign the Guestbook | Leave a comment

#linux #tech