alarm-clock-applet / alarm-clock

Alarm Clock is a fully-featured alarm clock for use with an AppIndicator implementation.
https://alarm-clock-applet.github.io
GNU General Public License v2.0
121 stars 31 forks source link

Feature request: allow setting a timer from the command line #227

Open thomasvs opened 5 months ago

thomasvs commented 5 months ago

I have a script to start "flow mode" on my machine and would like to have a 90 minute timer started from this script using a cli.

tatokis commented 5 months ago

For now, I came up with a really hacky solution:

First you need to find which alarm-X corresponds to the timer you want to enable. You do this by running something along the lines of dconf dump /io/github/alarm-clock-applet/ | grep -B 4 message and then looking at the [alarm-X] header.

Then, for example, for alarm-4 you can do in your script:

alarm_num=4

# Get duration of timer
alarm_time=$(gsettings get "io.github.alarm-clock-applet.alarm:/io/github/alarm-clock-applet/alarm-${alarm_num}/" time | sed 's@int64 @@')

# Schedule it
alarm_now=$(date +%s)
gsettings set "io.github.alarm-clock-applet.alarm:/io/github/alarm-clock-applet/alarm-${alarm_num}/" timestamp "$(($alarm_time + $alarm_now))"

# Enable it
gsettings set "io.github.alarm-clock-applet.alarm:/io/github/alarm-clock-applet/alarm-${alarm_num}/" active true

I will look into adding a command line option in the future that can do this in a proper way.