my profile picture changes twice a day

2023-11-11

word count: 354

approx reading time: 1 mins

if you follow me on fedi or on twitter you've probably seen my profile picture changing daily. this is a small explanation of what, how, and why that's happening

the what

my profile picture switches between a "day" image and a "night" image:

day image. wearing a black hoodie. the background is a forest in the daylight
day image. wearing a black hoodie. the background is a forest in the daylight

night image. wearing a white sweater. the background is a forest in the night time
night image. wearing a white sweater. the background is a forest in the night time

both of these were drawn by the awesome vai5000! you should commission her if you can c:

the how

the switching of pictures is done with a nodejs script that runs every 20 minutes through a cronjob, similar to this one:

0,20,40 * * * * cd /path/to/folder && node run.js

this script has two main jobs. first it polls the sunrise-sunset.org api to check what the sunrise and sunset times are for my current location. it then checks if the current time is less than 20 minutes after a sunrise or a sunset. if it is, it changes the profile picture by sending an api request to my fedi instance and to twitter dot com

since the script is only run every 20 minutes, the image changing might happen up to 19 minutes after the "true" sunrise/sunset happens. this is not a really a problem for me, since i don't really need absolute accuracy

my location is specified in a .env file which i manually update when i (very occasionally) travel. i am considering automating this in the near future, since i am prone to forgetting. i haven't done much research yet, but i'm thinking of using Tasker on my phone to update the location once a day, or something along these lines

if you want to run a similar setup, the whole repo is available here

the why

uhhhh idk funy it's a thing i could do and it makes my social media presence a bit more interesting and personalized so, why not? i might not have been born when the web started, but i think it's spirit is self-expression, customization, and whimsy. and i'm not gonna be able to bring it all back by myself, but i can contribute my small grain of sand

sadly some websites (tumblr, discord) dont allow me to do this easily, which is an absolute shame

separator line, for decoration