cruxports/deadbeef-alarm/README.md

92 lines
4.7 KiB
Markdown

# alarm clock plugin for DeaDBeeF
## About
This plugin allows the DeaDBeeF music player to serve as an alarm clock.
Even with its comprehensive set of command-line options, DeaDBeeF is
ultimately a graphical program, in most cases completely unreachable
from the restricted environment in which crontab shell scripts are executed.
The MPRIS plugin[1] does allow some control of the media player from a crontab
script, but because a script executed by cron usually cannot find the dbus session bus
address in its environment, this variable must be hard-coded in the
shell script you intend to use for activating DeaDBeeF. (For a clumsy way to
automate the hard-coding of session bus address, you might add some sed commands
to your window manager's autostart script, overwriting a definition line in the
*activate-DeaDBeeF* script.) Then having surmounting this
obstacle, you'll discover that the MPRIS plugin implements only one method for
selecting a particular file for playback: OpenUri. Even if xdg-mime could be
persuaded that the file extension m3u indicates a filetype audio/x-mpegurl rather
than text/plain (so that the OpenUri argument is not immediately rejected upon
receipt of the dbus message), the MPRIS plugin only implements OpenUri using
the method `deadbeef->plt_add_file2`, while a playlist would require
`deadbeef->plt_load2`. So to assemble an entire playlist using the methods available
in the MPRIS plugin, you would have to parse the metadata of each song to determine
how long the parent process should sleep between successive calls of OpenUri.
**TLDR**: working around the limitations of crontab and MPRIS is more
trouble than building a specialized plugin for alarm clock functionality.
To close the gap between DeaDBeeF and its console-interface counterparts
(moc, mpd, cmus -- all of which *can* be controlled by scripts in a crontab),
this plugin translates the essential components of the audacious alarm
plugin[2] into the DeaDBeeF idiom. The configuration dialog lets you choose
which days of the week the alarm goes off, what time of day, and which
playlist you want loaded. Leaving the playlist field empty (or selecting
an invalid file) will just start playback at the beginning of the current
list when the alarm goes off.
1. https://github.com/Serranya/deadbeef-mpris2-plugin
2. https://github.com/audacious-media-player/audacious-plugins/tree/master/src/alarm
## What is missing
The following features were present in the audacious alarm plugin, but
have not been implemented here.
- Volume fading from quiet to loud after a fixed time interval. If you need that kind of
control, all the underlying audio stacks (ALSA, OSS, Pipewire, Pulseaudio, sndio) offer
command-line mixer tools that work fine when executed within crontab scripts, and you
can just leave the DeaDBeeF volume slider at its highest level.
- Stopping the playback after a specified time interval.
(TODO: let the plugin itself turn off repeat mode if that behaviour is
desired, simply by adding a "disable repeat mode" checkbox to the alarm
configuration dialog. It then becomes the user's responsibility to make
sure a playlist of the appropriate length is selected, so playback doesn't
continue past the transition from sleep to wakefulness.)
- Setting a different alarm time for each day of the week. Sleep
professionals recommend that you stick to a consistent bedtime and
wakeup time for optimal health. (But if you have a healthy sleep regimen in
the first place, you probably wake up at the right time without an alarm.
Omitting this feature thus makes the plugin less useful to people who
genuinely need a mechanical disruption of their established sleep-wake cycle.)
## How to install
### For CRUX users
- cd to a directory in your local ports overlay
- download the source code from this host:
`httpup sync https://git.sdf.org/jmq/cruxports/raw/branch/master/#deadbeef-alarm deadbeef-alarm`
- prt-get depinst install deadbeef-alarm
### For users of other Linux distributions
- check that all dependencies and header files are installed (DeaDBeeF
and glib)
- save the source code and the Makefile
(`https://git.sdf.org/jmq/cruxports/deadbeef-alarm/alarm.cc`
and `https://git.sdf.org/jmq/cruxports/deadbeef-alarm/Makefile`)
into a working directory.
- cd to the working directory and run make. Invoke make with
`GLIB_CXX_FLAGS="$(pkg-config --cflags glib-2.0)"` and
`GLIB_LD_FLAGS="$(pkg-config --libs glib-2.0)"` if your
distribution has installed the shared glib libraries in non-standard
locations.
- run `make install` , optionally prepending a custom setting for PREFIX
(such as $HOME/.local) or DESTDIR.
## How to contribute
Patches are welcome. See the header of the accompanying Pkgfile for
contact information.