Skip to content

Commit

Permalink
add flag to set a custom CONF_DIR (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
notdodo authored Sep 19, 2021
1 parent 7ab5860 commit ef5668a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,26 @@ Run `sudo pip3 install python-bidi google-api-python-client google-auth-httplib2
-h, --help show this help message and exit
--credentials CREDENTIALS, -c CREDENTIALS
path to your credentials.json file
--conf CONF, -cd CONF
path to the i3agenda configuration and cache folder
--cachettl CACHETTL, -ttl CACHETTL
time for cache to be kept in minutes
--update, -u when using this flag it will not load previous results from cache, it will however save new results to cache. You can use this flag to refresh all the cache forcefully
--update, -u when using this flag it will not load previous results from cache, it will however save new results to cache.
You can use this flag to refresh all the cache forcefully
--ids IDS [IDS ...], -i IDS [IDS ...]
list of calendar ids to fetch, space separated. If none is specified all calendars will be fetched
--maxres MAXRES, -r MAXRES
max number of events to query Google's API for each of your calendars. Increase this number if you have lot of events in your google calendar
max number of events to query Google's API for each of your calendars.
Increase this number if you have lot of events in your google calendar
--today, -d print only today events
--no-event-text TEXT text to display when there are no events
--hide-event-after MINUTES
minutes to show events after they start before showing the next event. If not specified, the current event will be shown until it ends
--date-format DATEFORMAT
--hide-event-after HIDE_EVENT_AFTER
minutes to show events after they start before showing the next event.
If not specified, the current event will be shown until it ends
--date-format DATE_FORMAT
the date format like %d/%m/%y. Default is %d/%m
--limchar LIMIT, -l LIMIT
limits the size of the event summary string in LIMIT characters. If not specified it shows the entire summary.
--limchar LIMCHAR, -l LIMCHAR
the max characters that the displayed event can contain
```

### Filter displayed calendars
Expand Down
3 changes: 1 addition & 2 deletions i3_agenda/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def get_credentials(credspath):
if not creds or not creds.valid:
if not os.path.exists(credspath):
print(
"""You need to download your credentials json file from the
Google API Console and pass its path to this script"""
"""You need to download your credentials json file from the Google API Console and pass its path to this script"""
)
exit(1)
if creds and creds.expired and creds.refresh_token:
Expand Down
12 changes: 7 additions & 5 deletions i3_agenda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
from __future__ import print_function

import subprocess
import config

from typing import List

from event import Event, EventEncoder, get_closest
from config import parser, button
from API import get_events
from cache_utils import load_cache, save_cache

DEFAULT_CAL_WEBPAGE = "https://calendar.google.com/calendar/r/day"

Expand All @@ -25,6 +23,9 @@ def button_action(button_code: str, closest: Event):


def load_events(args) -> List[Event]:
from API import get_events
from cache_utils import load_cache, save_cache

events = None
if not args.update:
events = load_cache(args.cachettl)
Expand All @@ -35,7 +36,8 @@ def load_events(args) -> List[Event]:


def main():
args = parser.parse_args()
args = config.parser.parse_args()
config.CONF_DIR = args.conf

events = load_events(args)

Expand All @@ -44,7 +46,7 @@ def main():
print(args.no_event_text)
return

button_action(button, closest)
button_action(config.button, closest)

print(closest.get_string(args.limchar, args.date_format))

Expand Down
7 changes: 7 additions & 0 deletions i3_agenda/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
default="",
help="path to your credentials.json file",
)
parser.add_argument(
"--conf",
"-cd",
type=str,
default=CONF_DIR,
help="path to the i3agenda configuration and cache folder",
)
parser.add_argument(
"--cachettl",
"-ttl",
Expand Down

0 comments on commit ef5668a

Please sign in to comment.