I want to set up my system to run Thunderbird (which needs x11) at the first login every day (so if I reboot on the same day, it wouldn't run). How do I go about setting this up?
The easiest way to start Thunderbird for me would be with .xinitrc
but I'm not aware of a clean way to restrict it to only running once per day.
The way I could do this is to compare today's date to the last boot time (before this one), but I'm not aware of a standarized way to this, so I'm asking this question instead to avoid the XY Problem.
I didn't end up finding an idiomatic way to get the last boot date so I decided to store them in a custom file instead by using /etc/rc.local
(which is executed at startup on my system) like so:
# Save boot time
date +%s >> /var/log/bootdate
I can then use this file within .xinitrc
to start Thunderbird only if the day of the last boot is not today (i.e. this is the first boot of the day):
lastboot="$(date +%D -d@"$(tail -2 </var/log/bootdate | head -1)")"
today="$(date +%D)"
if [ "$today" != "$lastboot" ]; then
# Run given programs only on the first boot of the day
thunderbird &
fi