Module i3status_rs::blocks::calendar

source ·
Expand description

Calendar

This block displays upcoming calendar events retrieved from a CalDav ICalendar server.

§Configuration

KeyValuesDefault
next_event_formatA string to customize the output of this block when there is a next event in the calendar. See below for available placeholders." $icon $start.datetime(f:‘%a %H:%M’) $summary "
ongoing_event_formatA string to customize the output of this block when an event is ongoing." $icon $summary (ends at $end.datetime(f:‘%H:%M’)) "
no_events_formatA string to customize the output of this block when there are no events" $icon "
redirect_formatA string to customize the output of this block when the authorization is asked" $icon Check your web browser "
fetch_intervalFetch events interval in seconds60
alternate_events_intervalAlternate overlapping events interval in seconds10
events_within_hoursNumber of hours to look for events in the future48
sourceArray of sources to pull calendars from[]
warning_thresholdWarning threshold in seconds for the upcoming event300
browser_cmdCommand to open event details in a browser. The block passes the HTML link as an argument"xdg-open"

§Source Configuration

KeyValuesDefault
urlCalDav calendar server URLN/A
authAuthentication configuration (unauthenticated, basic, or oauth2)unauthenticated
calendarsList of calendar names to monitor. If empty, all calendars will be fetched.[]

Note: Currently only one source is supported

ActionDescriptionDefault button
open_linkOpens the HTML link of the eventLeft

§Examples

§Unauthenticated

[[block]]
block = "calendar"
next_event_format = " $icon $start.datetime(f:'%a %H:%M') $summary "
ongoing_event_format = " $icon $summary (ends at $end.datetime(f:'%H:%M')) "
no_events_format = " $icon no events "
fetch_interval = 30
alternate_events_interval = 10
events_within_hours = 48
warning_threshold = 600
browser_cmd = "firefox"
[[block.source]]
url = "https://caldav.example.com/calendar/"
calendars = ["user/calendar"]
[block.source.auth]
type = "unauthenticated"

§Basic Authentication

[[block]]
block = "calendar"
next_event_format = " $icon $start.datetime(f:'%a %H:%M') $summary "
ongoing_event_format = " $icon $summary (ends at $end.datetime(f:'%H:%M')) "
no_events_format = " $icon no events "
fetch_interval = 30
alternate_events_interval = 10
events_within_hours = 48
warning_threshold = 600
browser_cmd = "firefox"
[[block.source]]
url = "https://caldav.example.com/calendar/"
calendars = [ "Holidays" ]
[block.source.auth]
type = "basic"
username = "your_username"
password = "your_password"

Note: You can also configure the username and password in a separate TOML file.

~/.config/i3status-rust/example_credentials.toml

username = "my-username"
password = "my-password"

Source auth configuration with credentials_path:

[block.source.auth]
type = "basic"
credentials_path = "~/.config/i3status-rust/example_credentials.toml"

§OAuth2 Authentication (Google Calendar)

To access the CalDav API of Google, follow these steps to enable the API and obtain the client_id and client_secret:

  1. Go to the Google Cloud Console: Navigate to the Google Cloud Console.
  2. Create a New Project: If you don’t already have a project, click on the project dropdown and select “New Project”. Give your project a name and click “Create”.
  3. Enable the CalDAV API: In the project dashboard, go to the “APIs & Services” > “Library”. Search for “CalDAV API” and click on it, then click “Enable”.
  4. Set Up OAuth Consent Screen: Go to “APIs & Services” > “OAuth consent screen”. Fill out the required information and save.
  5. Create Credentials:
    • Navigate to “APIs & Services” > “Credentials”.
    • Click “Create Credentials” and select “OAuth 2.0 Client IDs”.
    • Configure the consent screen if you haven’t already.
    • Set the application type to “Web application”.
    • Add your authorized redirect URIs. For example, http://localhost:8080.
    • Click “Create” and note down the client_id and client_secret.
  6. Download the Credentials: Click on the download icon next to your OAuth 2.0 Client ID to download the JSON file containing your client ID and client secret. Use these values in your configuration.
[[block]]
block = "calendar"
next_event_format = " $icon $start.datetime(f:'%a %H:%M') $summary "
ongoing_event_format = " $icon $summary (ends at $end.datetime(f:'%H:%M')) "
no_events_format = " $icon no events "
fetch_interval = 30
alternate_events_interval = 10
events_within_hours = 48
warning_threshold = 600
browser_cmd = "firefox"
[[block.source]]
url = "https://apidata.googleusercontent.com/caldav/v2/"
calendars = ["primary"]
[block.source.auth]
type = "oauth2"
client_id = "your_client_id"
client_secret = "your_client_secret"
auth_url = "https://accounts.google.com/o/oauth2/auth"
token_url = "https://oauth2.googleapis.com/token"
auth_token = "~/.config/i3status-rust/calendar.auth_token"
redirect_port = 8080
scopes = ["https://www.googleapis.com/auth/calendar", "https://www.googleapis.com/auth/calendar.events"]

Note: You can also configure the client_id and client_secret in a separate TOML file.

~/.config/i3status-rust/google_credentials.toml

client_id = "my-client_id"
client_secret = "my-client_secret"

Source auth configuration with credentials_path:

[block.source.auth]
type = "oauth2"
credentials_path = "~/.config/i3status-rust/google_credentials.toml"
auth_url = "https://accounts.google.com/o/oauth2/auth"
token_url = "https://oauth2.googleapis.com/token"
auth_token = "~/.config/i3status-rust/calendar.auth_token"
redirect_port = 8080
scopes = ["https://www.googleapis.com/auth/calendar", "https://www.googleapis.com/auth/calendar.events"]

§Format Configuration

The format configuration is a string that can include placeholders to be replaced with dynamic content. Placeholders can be:

  • $summary: Summary of the event
  • $description: Description of the event
  • $url: Url of the event
  • $location: Location of the event
  • $start: Start time of the event
  • $end: End time of the event

§Icons Used

  • calendar

Structs§

Enums§

Functions§