Skip to content

Commit

Permalink
add default alarm configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
sdx23 authored and geier committed Oct 30, 2023
1 parent 4d4fb9b commit 9dd6ab4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ not released yet
config file (via the new [palette] section, check the documenation)
* NEW timedelta strings can now have a leading `+`, e.g. `+1d`
* NEW Add `--json` option to output event data as JSON objects
* NEW Add default alarms configuration option

0.11.2
======
Expand Down
5 changes: 5 additions & 0 deletions khal/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ def new_from_string(collection, calendar_name, conf, info, location=None,
conf['default']['default_dayevent_duration'],
adjust_reasonably=True,
)
if alarms is None:
if info['allday']:
alarms = conf['default']['default_dayevent_alarm']
else:
alarms = conf['default']['default_event_alarm']
info.update({
'location': location,
'categories': categories,
Expand Down
6 changes: 6 additions & 0 deletions khal/settings/khal.spec
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ default_event_duration = timedelta(default='1d')
# Define the default duration for an event ('khal new' only)
default_dayevent_duration = timedelta(default='1h')

# Define the default alarm for a day-long event, e.g. '12h' ('khal new' only)
default_event_alarm = string(default='')

# Define the default alarm for an event, e.g. '10m' ('khal new' only)
default_dayevent_alarm = string(default='')

# Whether the mouse should be enabled in interactive mode ('khal interactive' and
# 'ikhal' only)
enable_mouse = boolean(default=True)
Expand Down
4 changes: 4 additions & 0 deletions tests/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def test_simple_config(self):
'timedelta': dt.timedelta(days=2),
'default_event_duration': dt.timedelta(days=1),
'default_dayevent_duration': dt.timedelta(hours=1),
'default_event_alarm': '',
'default_dayevent_alarm': '',
'show_all_days': False,
'enable_mouse': True,
}
Expand Down Expand Up @@ -105,6 +107,8 @@ def test_small(self):
'default_dayevent_duration': dt.timedelta(hours=1),
'show_all_days': False,
'enable_mouse': True,
'default_event_alarm': '',
'default_dayevent_alarm': '',
}
}
for key in comp_config:
Expand Down

0 comments on commit 9dd6ab4

Please sign in to comment.