[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: simple talking clock / reminder for when monitor is off and it is dark



On Mon, Mar 21, 2022 at 01:21:19PM -0300, Chris Mitchell wrote:
> Personally, I would use a custom systemd timer unit for this. Systemd
> is already running most of your system, and it offers a scheduling
> syntax that is (AFAIK) more flexible than cron's, and (IMHO) much
> easier to read. For example "Every day, once an hour, on the hour, but
> only between midnight and 07:00 (inclusive)" would be:
>   OnCalendar=00..07:00

In crontab(5), that would be:

0 0-7 * * * /your/command

I'm not familiar with systemd timers, so maybe what you say is true,
about them being more flexible, but in this specific example, crontab
is perfectly capable of doing the job.

The biggest thing to be aware of with crontab/at jobs, and I would
presume with systemd timer jobs as well, is that the commands are
run in a minimalist environment inherited from the cron daemon (or,
I assume, from systemd).  Some of the things you're accustomed to having
in your interactive environment won't be available.  Jobs won't run with
a controlling terminal, nor with an X $DISPLAY variable.  Make sure
you write your scripts/commands with those limitations in mind.

For the OP's question, what's really needed is access to the sound system.
I'm not sure what happens if a job fires after you've booted but before
you've ever logged in, or after you've logged in and then logged out.  Do
you still have access to the sound system without an active login session?
These are the kinds of things you'd either need to test, or research.


Reply to: