oh-my-posh/website/docs/segments/strava.mdx

107 lines
3.9 KiB
Plaintext
Raw Normal View History

2021-12-29 23:57:27 -08:00
---
id: strava
title: Strava
sidebar_label: Strava
---
import StravaConnect from '/img/strava_connect.svg';
## What
2022-01-10 13:14:31 -08:00
[Strava][strava] ia a popular activity tracker for bike, run or any other training.
To keep up with your training goals it is important to be reminded about it.
An Oh My Posh Strava segment shows your last activity,
and can also indicate by a color if it is time to get away from your computer and get active.
2021-12-29 23:57:27 -08:00
## Accessing your Strava data
To allow Oh My Posh access your Strava data you need to grant access to read your public activities.
This will give you an access and a refresh token. Paste the tokens into your Strava segment configuration.
2021-12-29 23:57:27 -08:00
Click the following link to connect with Strava:
<a href="https://www.strava.com/oauth/authorize?client_id=76033&response_type=code&redirect_uri=https://ohmyposh.dev/api/auth&approval_prompt=force&scope=read,activity:read&state=strava">
<StravaConnect/>
</a>
## Sample Configuration
This configuration sets the background green if you have an activity the last two days,
2022-01-10 13:14:31 -08:00
orange if you have one last 5 days, and red otherwise. The `foreground_templates` example below could be set to just a single color,
2021-12-29 23:57:27 -08:00
if that color is visible against any of your backgrounds.
```json
{
"type": "strava",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#000000",
"background_templates": [
"{{ if gt .Hours 100 }}#dc3545{{ end }}",
"{{ if and (lt .Hours 100) (gt .Hours 50) }}#ffc107{{ end }}",
"{{ if lt .Hours 50 }}#28a745{{ end }}"
],
"foreground_templates": [
"{{ if gt .Hours 100 }}#FFFFFF{{ end }}",
"{{ if and (lt .Hours 100) (gt .Hours 50) }}#343a40{{ end }}",
"{{ if lt .Hours 50 }}#FFFFFF{{ end }}"
],
2022-03-27 01:12:47 -07:00
"template": "{{.Name}} {{.Ago}} {{.Icon}}",
2021-12-29 23:57:27 -08:00
"properties": {
"access_token":"11111111111111111",
"refresh_token":"1111111111111111",
2022-03-27 01:12:47 -07:00
"http_timeout": 1500
2021-12-29 23:57:27 -08:00
}
}
```
## Properties
- access_token: `string` - token from Strava login, see login link in section above. It has the following format: `1111111111111111111111111`
- refresh_token: `string` - token from Strava login, see login link in section above. It has the following format: `1111111111111111111111111`
2022-01-10 13:14:31 -08:00
- expires_in: `int` - the default timeout of the token from the Strava login
2021-12-29 23:57:27 -08:00
- http_timeout: `int` - how long do you want to wait before you want to see your prompt more than your strava data? - defaults to 500ms
- CacheTimeout: `int` in minutes - How long do you want your numbers cached? - defaults to 5 min
- RideIcon - defaults to `\uf5a2`
- RunIcon - defaults to `\ufc0c`
- SkiingIcon - defaults to `\ue213`
- WorkOutIcon - defaults to `\ue213`
- UnknownActivityIcon - defaults to `\ue213`
2022-02-01 03:10:46 -08:00
## Template ([info][templates])
:::note default template
``` template
{{ if .Error }}{{ .Error }}{{ else }}{{ .Ago }}{{ end }}
```
:::
### Properties
2021-12-29 23:57:27 -08:00
The properties below are available for use in your template
2021-12-29 23:57:27 -08:00
- `.ID`: `time` - The id of the entry
2021-12-29 23:57:27 -08:00
- `.DateString`: `time` - The timestamp of the entry
- `.Type`: `string` - Activity types as used in strava
- `.UtcOffset`: `int` - The UTC offset
- `.Hours`: `int` - Number of hours since last activity
- `.Name`: `string` - The name of the activity
- `.Duration`: `float64` - Total duration in seconds
2022-01-10 13:14:31 -08:00
- `.Distance`: `float64` - Total distance in meters
- `.DeviceWatts`: `bool` - Device has watts
- `.AverageWatts`: `float64` - Average watts
- `.WeightedAverageWatts`:`float64` - Weighted average watts
- `.AverageHeartRate`:`float64` - Average heart rate
- `.MaxHeartRate`: `float64` - Max heart rate
- `.KudosCount`: `int` - Kudos count
2022-01-10 13:14:31 -08:00
- `.Icon`: `string` - Activity based icon
2021-12-29 23:57:27 -08:00
Now, go out and have a fun ride or run!
2022-04-20 09:43:59 -07:00
[templates]: /docs/configuration/templates
2021-12-29 23:57:27 -08:00
[strava]: http://www.strava.com/
[strava-connect]: https://www.strava.com/oauth/authorize?client_id=76033&response_type=code&redirect_uri=https://ohmyposh.dev/api/auth&approval_prompt=force&scope=read,activity:read