oh-my-posh/docs/docs/segment-strava.mdx

93 lines
3.7 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.
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 }}"
],
"properties": {
"access_token":"11111111111111111",
"refresh_token":"1111111111111111",
"http_timeout": 1500,
2022-01-10 13:14:31 -08:00
"template": "{{.Name}} {{.Ago}} {{.Icon}}"
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
- template: `string` - a go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the properties below.
See the example above. Make sure your NerdFont has the glyph you want or search for one at nerdfonts.com
- 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`
## Template Properties
The properties below are availible for use in your template
- `.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
- `.Icon`: `string` - Activity based icon
2021-12-29 23:57:27 -08:00
Now, go out and have a fun ride or run!
[go-text-template]: https://golang.org/pkg/text/template/
[sprig]: https://masterminds.github.io/sprig/
[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