Module i3status_rs::blocks::calendar
source · Expand description
Calendar
This block displays upcoming calendar events retrieved from a CalDav ICalendar server.
§Configuration
Key | Values | Default |
---|---|---|
next_event_format | A 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_format | A string to customize the output of this block when an event is ongoing. | " $icon $summary (ends at $end.datetime(f:‘%H:%M’)) " |
no_events_format | A string to customize the output of this block when there are no events | " $icon " |
redirect_format | A string to customize the output of this block when the authorization is asked | " $icon Check your web browser " |
fetch_interval | Fetch events interval in seconds | 60 |
alternate_events_interval | Alternate overlapping events interval in seconds | 10 |
events_within_hours | Number of hours to look for events in the future | 48 |
source | Array of sources to pull calendars from | [] |
warning_threshold | Warning threshold in seconds for the upcoming event | 300 |
browser_cmd | Command to open event details in a browser. The block passes the HTML link as an argument | "xdg-open" |
§Source Configuration
Key | Values | Default |
---|---|---|
url | CalDav calendar server URL | N/A |
auth | Authentication configuration (unauthenticated, basic, or oauth2) | unauthenticated |
calendars | List of calendar names to monitor. If empty, all calendars will be fetched. | [] |
Note: Currently only one source is supported
Action | Description | Default button |
---|---|---|
open_link | Opens the HTML link of the event | Left |
§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
:
- Go to the Google Cloud Console: Navigate to the Google Cloud Console.
- 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”.
- 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”.
- Set Up OAuth Consent Screen: Go to “APIs & Services” > “OAuth consent screen”. Fill out the required information and save.
- 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
andclient_secret
.
- 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