Skip to content

Commit

Permalink
Rename: timer -> event listener, period -> event
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobGM committed Feb 17, 2018
1 parent 34f2da0 commit 8059a18
Show file tree
Hide file tree
Showing 20 changed files with 701 additions and 663 deletions.
26 changes: 14 additions & 12 deletions astrality/astrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ def main(logging_level: str = 'INFO', test: bool = False):

# How to quit this process
def exit_handler(signal=None, frame=None) -> None:
"""Cleanup all temporary files and run module exit handlers."""
"""
Cleanup all temporary files and run module exit handlers.
# The temp directory is left alone, for two reasons:
# 1: An empty directory uses neglible disk space.
# 2: If this process is interrupted by another Astrality instance,
# we might experience race conditions when the exit handler deletes
# the temporary directory *after* the new Astrality instance creates it.
The temp directory is left alone, for two reasons:
1: An empty directory uses neglible disk space.
2: If this process is interrupted by another Astrality instance,
we might experience race conditions when the exit handler deletes
the temporary directory *after* the new Astrality instance creates it.
"""

logger.critical('Astrality was interrupted')
logger.info('Cleaning up temporary files before exiting...')
Expand Down Expand Up @@ -79,21 +81,21 @@ def exit_handler(signal=None, frame=None) -> None:

while True:
if module_manager.has_unfinished_tasks():
# TODO: Log which new period which has been detected
logger.info('New timer period detected.')
# TODO: Log which new event which has been detected
logger.info('New event detected.')
module_manager.finish_tasks()
logger.info(f'Period change routine finished.')
logger.info(f'Event change routine finished.')

if test:
logger.debug('Main loop interupted since argument test=True.')
return
else:
logger.info(
f'Waiting {module_manager.time_until_next_period()} '
'until next period change and ensuing update.'
f'Waiting {module_manager.time_until_next_event()} '
'until next event change and ensuing update.'
)
time.sleep(
module_manager.time_until_next_period().total_seconds()
module_manager.time_until_next_event().total_seconds()
)

except KeyboardInterrupt: # pragma: no cover
Expand Down
22 changes: 11 additions & 11 deletions astrality/config/astrality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ module/solar_wallpaper:
# enable the module. Here, we check if `feh` is installed.
requires: command -v feh

timer:
# The solar timer provides the following periods:
event_listener:
# The solar event listener provides the following events:
# sunrise, morning, afternoon, sunset, and night.
type: solar

Expand All @@ -37,23 +37,23 @@ module/solar_wallpaper:
longitude: 10.421906
elevation: 0

# You can force a timer to always return the same period for debugging.
# You can force a event listener to always return the same event for debugging.
# For example, if you want to check if all your periodic color schemes
# fit your the respective periodic wallpapers, without waiting for sunset,
# etc..
# force_period: sunrise
# force_event: sunrise

on_startup:
# Execute all actions specified in `on_period_change` on Astrality startup
trigger: on_period_change
# Execute all actions specified in `on_event` on Astrality startup
trigger: on_event

on_period_change:
# Import the context section named the same as the current period,
on_event:
# Import the context section named the same as the current event,
# e.g. `night`, into the global context section named `colors`,
# from the file: wallpaper_themes/default/colors.yaml.
import_context:
- from_path: modules/solar_wallpaper/solar_colors.yaml
from_section: '{period}'
from_section: '{event}'
to_section: colors

# Compile the templates specified in the conky module, as their
Expand All @@ -63,9 +63,9 @@ module/solar_wallpaper:
- conky.performance

# Run shell command to change the desktop wallpaper named the same
# as the current period.
# as the current event.
run:
- feh --bg-fill modules/solar_wallpaper/{period}.*
- feh --bg-fill modules/solar_wallpaper/{event}.*


module/conky:
Expand Down

0 comments on commit 8059a18

Please sign in to comment.