Daily automatic image posting to Mastodon
serviceNetworkapt install mastodon-image-posterA systemd timer-driven service that posts one image per day from a configured directory to a Mastodon instance. Supports sorting by filename, file size or creation time. Tracks state to resume after restart without re-posting already sent images.
Daily automatic image posting to a Mastodon instance from a local directory.
A systemd timer triggers the service once a day. Each run picks the next image from the configured directory (sorted by name, size or creation time), uploads it to the Mastodon instance and records which file was last posted. After all images are posted it wraps around to the first one.
EXIF metadata is read from every image. When available, the date the photo was taken and the GPS location (reverse-geocoded to a street address) are appended to each post. If the image has no EXIF data, the file's modification date is used as a fallback.
Supported formats: jpg, jpeg, png, gif, webp
sudo apt install mastodon-image-poster
During installation debconf will ask for:
name, size or timehttps://mastodon.socialConfig file: /etc/mastodon-image-poster/config.ini
[mastodon]
instance_url = https://mastodon.social
access_token = YOUR_ACCESS_TOKEN_HERE
[images]
directory = /srv/images
; Sorting order: name, size, time
sort_order = name
; Optional text prepended to every post.
; EXIF date and GPS location are appended automatically when available.
status_text =
To change the posting interval edit the systemd timer override:
sudo systemctl edit mastodon-image-poster.timer
and set a custom OnCalendar= value.
sudo dpkg-reconfigure mastodon-image-poster
Any user on the same server can run their own instance posting to a different Mastodon account from a different photo folder, without touching the system service.
mkdir -p ~/.config/mastodon-image-poster
cp /usr/share/doc/mastodon-image-poster/example.ini \
~/.config/mastodon-image-poster/config.ini
$EDITOR ~/.config/mastodon-image-poster/config.ini
The script detects ~/.config/mastodon-image-poster/config.ini automatically
(XDG convention). When that file is present, state is stored in
~/.local/share/mastodon-image-poster/state.json β no root access required.
Both paths can be overridden with environment variables:
MASTODON_IMAGE_POSTER_CONFIG=/path/to/config.ini \
MASTODON_IMAGE_POSTER_STATE=/path/to/state.json \
mastodon_image_poster.py
mkdir -p ~/.config/systemd/user
~/.config/systemd/user/mastodon-image-poster.service
[Unit]
Description=Post an image to Mastodon
After=network-online.target
Wants=network-online.target mastodon-image-poster.timer
[Service]
Type=oneshot
ExecStart=/usr/bin/mastodon_image_poster.py
[Install]
WantedBy=default.target
~/.config/systemd/user/mastodon-image-poster.timer
[Unit]
Description=Post an image to Mastodon daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
systemctl --user daemon-reload
systemctl --user enable --now mastodon-image-poster.timer
systemctl --user list-timers mastodon-image-poster.timer
By default, user services stop when the user logs out. To keep the timer running even without an active session:
sudo loginctl enable-linger $USER
systemctl --user status mastodon-image-poster.timer
journalctl --user -u mastodon-image-poster.service -f
MIT β VΓtΔzslav DvoΕΓ‘k info@vitexsoftware.cz
This package may not be indexed in our database yet. Please try again later or check the package repository directly.