Added custom configs.

This commit is contained in:
2026-09-18 18:42:29 -05:00
parent 8193c75f38
commit 64e06d111c
10 changed files with 270 additions and 2 deletions
+33
View File
@@ -0,0 +1,33 @@
- type: custom-api
title: 🎵 Lastest Scrobbles
cache: 60s
url: http://ws.audioscrobbler.com/2.0/
parameters:
method: user.getRecentTracks
user: ${LASTFM_USERNAME}
api_key: ${LASTFM_API_KEY}
format: json
limit: 10
template: |
<ul class="list list-gap-10 collapsible-container" data-collapse-after="5">
{{ range .JSON.Array "recenttracks.track" }}
<li class="flex items-center gap-10">
<div style="border-radius: 5px; min-width: 5rem; max-width: 5rem; overflow: hidden;" class="card">
<object data={{ .String "image.2.#text" }} type="image/png">
<img src="https://lastfm.freetls.fastly.net/i/u/174s/2a96cbd8b46e442fc41c2b86b821562f.png" alt="Fallback">
</object>
</div>
<div class="flex-1">
<p class="color-primary size-h5">{{ .String "artist.#text" }}</p>
<p class="size-h5">{{ .String "name" }}</p>
<p class="size-h6">
{{ if .String "@attr.nowplaying" }}
<span class="color-positive">Now playing</span>
{{ else }}
<span class="color-subdue" {{ .String "date.#text" | parseRelativeTime "02 Jan 2006, 15:04" }}></span>
{{ end }}
</p>
</div>
</li>
{{ end }}
</ul>
+6
View File
@@ -0,0 +1,6 @@
- type: custom-api
title: 💡 Random Fact
cache: 1h
url: https://uselessfacts.jsph.pl/api/v2/facts/random
template: |
<p class="size-h4 color-paragraph">{{ .JSON.String "text" }}</p>
+56
View File
@@ -0,0 +1,56 @@
- type: custom-api
title: 🎮 Steam Friends
cache: 1m
url: https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${STEAM_API_KEY}&steamids=${STEAM_FRIENDS}
template: |
<ul class="list list-gap-10 collapsible-container" data-collapse-after="5">
{{ $players := .JSON.Array "response.players" }}
{{ if gt (len $players) 0 }}
{{ range $players }}
{{ $status := .Int "personastate" }}
{{ $colorClass := "color-subdue" }}
{{ $statusText := "Offline" }}
{{ if eq $status 1 }}
{{ $colorClass = "color-positive" }}
{{ $statusText = "Online" }}
{{ else if eq $status 2 }}
{{ $colorClass = "color-highlight" }}
{{ $statusText = "Busy" }}
{{ else if eq $status 3 }}
{{ $colorClass = "color-primary" }}
{{ $statusText = "Away" }}
{{ else if eq $status 4 }}
{{ $colorClass = "color-primary" }}
{{ $statusText = "Snooze" }}
{{ else if eq $status 5 }}
{{ $colorClass = "color-primary" }}
{{ $statusText = "Looking to Trade" }}
{{ else if eq $status 6 }}
{{ $colorClass = "color-primary" }}
{{ $statusText = "Looking to Play" }}
{{ end }}
<li class="flex gap-10 items-start thumbnail-parent">
<a href="{{ .String "profileurl" }}" style="width: 4.4rem;height: 4.4rem;border: 2px solid var(--color-text-subdue);padding: 2px;border-radius: 50%;position: relative;flex-shrink: 0;">
<img class="thumbnail" style="aspect-ratio: 1; border-radius: 50%;" src="{{ .String "avatarmedium" }}" alt="Avatar" loading="lazy">
</a>
<div class="items-start">
<a href="{{.String "profileurl"}}" title="{{.String "personname"}}" class="size-h3 block">{{ .String "personaname" }}</a>
<span class="{{ $colorClass }}">
{{ if .Exists "gameextrainfo" }}
{{ .String "gameextrainfo" }}
{{ else }}
{{ $statusText }}
{{ if eq $status 0 }}
{{ if .Exists "lastlogoff" }}
for <span data-dynamic-relative-time="{{ .Int "lastlogoff" }}"></span>
{{ end }}
{{ end }}
{{ end }}
</span>
</div>
</li>
{{ end }}
{{ else }}
<p class="color-negative">No player data found.</p>
{{ end }}
</ul>
@@ -0,0 +1,46 @@
- type: custom-api
title: 🎮 Recently Played Games
cache: 1h
url: http://api.steampowered.com/IPlayerService/GetRecentlyPlayedGames/v0001/?key=${STEAM_API_KEY}&steamid=${STEAM_USERID}&format=json
template: |
<div>
{{ if eq .Response.StatusCode 200 }}
{{ $games := .JSON.Array "response.games" }}
{{ if gt (len $games) 0 }}
<ul class="list list-gap-10 collapsible-container" data-collapse-after="5">
{{ range $games }}
<li style="display: flex; align-items: center;">
<a href="https://store.steampowered.com/app/{{ .Int "appid" }}" target="_blank">
<img
src="http://media.steampowered.com/steamcommunity/public/images/apps/{{ .Int "appid" }}/{{ .String "img_icon_url" }}.jpg"
alt="{{ .String "name" }}"
style="width: 32px; border-radius: var(--border-radius); margin-right: 10px;">
</a>
<div>
<a
href="https://store.steampowered.com/app/{{ .Int "appid" }}"
class="size-base color-primary"
target="_blank"
>
{{ .String "name" }}
</a>
<br>
<span class="size-h5 color-subdue">
Last 2 weeks:
{{ if gt (toFloat (.Int "playtime_2weeks")) 60.0 }}
{{ printf "%.2f hrs" (div (toFloat (.Int "playtime_2weeks")) 60.0) }}
{{ else }}
{{ .Int "playtime_2weeks" }} mins
{{ end }}
</span>
</div>
</li>
{{ end }}
</ul>
{{ else }}
<p class="color-negative">No recently played games found.</p>
{{ end }}
{{ else }}
<p class="color-negative">An unexpected error occurred. Please try again later.</p>
{{ end }}
</div>
+60
View File
@@ -0,0 +1,60 @@
- type: custom-api
title: ☀️ Sunrise & Sunset
body-type: string
cache: 12h
options:
location: Quito, Ecuador
template: |
{{ $timeLayout := "3:04 PM" }}
{{/* Step 1: geocode the location */}}
{{ $loc := replaceAll " " "%20" (.Options.StringOr "location" "") }}
{{ $geoUrl := printf "https://geocoding-api.open-meteo.com/v1/search?name=%s&count=1&language=en&format=json" $loc }}
{{ $geo := newRequest $geoUrl | getResponse }}
{{ $results := $geo.JSON.Array "results" }}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
{{ if eq (len $results) 0 }}
<p class="color-paragraph">Location "{{ .Options.StringOr "location" "" }}" not found.</p>
{{ else }}
{{ $lat := $geo.JSON.String "results.0.latitude" }}
{{ $lon := $geo.JSON.String "results.0.longitude" }}
{{/* Step 2: today's sunrise/sunset/daylight from Open-Meteo */}}
{{ $fcUrl := printf "https://api.open-meteo.com/v1/forecast?latitude=%s&longitude=%s&daily=sunrise,sunset,daylight_duration&forecast_days=1&timezone=auto" $lat $lon }}
{{ $fc := newRequest $fcUrl | getResponse }}
{{ $sunriseRaw := $fc.JSON.String "daily.sunrise.0" }}
{{ $sunsetRaw := $fc.JSON.String "daily.sunset.0" }}
{{ $daylight := $fc.JSON.Int "daily.daylight_duration.0" }}
{{ if or (eq $sunriseRaw "") (eq $sunsetRaw "") }}
<p class="color-paragraph"><i class="fas fa-circle-exclamation"></i> No sunrise/sunset today (polar region).</p>
{{ else }}
{{ $sunrise := $sunriseRaw | parseTime "2006-01-02T15:04" }}
{{ $sunset := $sunsetRaw | parseTime "2006-01-02T15:04" }}
{{ $hours := div $daylight 3600 }}
{{ $mins := div (mod $daylight 3600) 60 }}
<div style="display:flex; justify-content:space-around; align-items:center; padding:0.5rem 0;">
<div style="text-align:center;">
<i class="fas fa-arrow-up" style="color: var(--color-positive); font-size: 14px; margin-right: 0.25rem;"></i>
<i class="fas fa-sun" style="color: var(--color-text-highlight); font-size: 28px;"></i>
<p class="size-h3 color-text-highlight">{{ $sunrise.Format $timeLayout }}</p>
<p class="size-h6 color-paragraph">Sunrise</p>
</div>
<div style="text-align:center;">
<i class="fas fa-clock" style="color: var(--color-paragraph); font-size: 22px;"></i>
<p class="size-h3 color-text-highlight">{{ $hours }}h {{ $mins }}m</p>
<p class="size-h6 color-paragraph">Daylight</p>
</div>
<div style="text-align:center;">
<i class="fas fa-arrow-down" style="color: var(--color-negative); font-size: 14px; margin-right: 0.25rem;"></i>
<i class="fas fa-moon" style="color: var(--color-text-highlight); font-size: 28px;"></i>
<p class="size-h3 color-text-highlight">{{ $sunset.Format $timeLayout }}</p>
<p class="size-h6 color-paragraph">Sunset</p>
</div>
</div>
{{ end }}
{{ end }}
@@ -0,0 +1,49 @@
- type: custom-api
title: 💡 On This Day
cache: 6h
url: https://api.github.com/rate_limit
template: |
{{/* Top-level URL is a cheap dummy JSON; the real work is done inside the template via newRequest so we can compute today's date. Wikipedia's REST API requires a descriptive User-Agent per their policy (https://meta.wikimedia.org/wiki/User-Agent_policy) — an unset UA returns 403. */}}
{{ $month := now | formatTime "01" }}
{{ $day := now | formatTime "02" }}
{{ $url := concat "https://en.wikipedia.org/api/rest_v1/feed/onthisday/events/" $month "/" $day }}
{{
$resp := newRequest $url
| withHeader "Accept" "application/json"
| withHeader "User-Agent" "glance-dashboard/1.0 (+https://github.com/glanceapp/glance)"
| getResponse
}}
{{ if ne $resp.Response.StatusCode 200 }}
<p class="color-negative">Failed to load Wikipedia events ({{ $resp.Response.Status }})</p>
{{ else }}
{{ $events := $resp.JSON.Array "events" }}
{{ if eq (len $events) 0 }}
<p class="color-subdue">No events found for today.</p>
{{ else }}
<ul class="list list-gap-14 collapsible-container" data-collapse-after="5">
{{ range $events }}
{{ $year := .Int "year" }}
{{ $text := .String "text" }}
{{ $pages := .Array "pages" }}
{{ $link := "" }}
{{ if gt (len $pages) 0 }}
{{ $firstPage := index $pages 0 }}
{{ $link = $firstPage.String "content_urls.desktop.page" }}
{{ end }}
<li>
<div class="flex items-baseline" style="gap: 0.6rem;">
<span class="color-primary size-h4" style="flex: 0 0 auto; min-width: 3rem;">{{ $year }}</span>
<span class="size-h5" style="flex: 1 1 auto;">
{{ if ne $link "" }}
<a href="{{ $link }}" target="_blank" rel="noreferrer" class="color-highlight">{{ $text }}</a>
{{ else }}
{{ $text }}
{{ end }}
</span>
</div>
</li>
{{ end }}
</ul>
{{ end }}
{{ end }}
+7
View File
@@ -0,0 +1,7 @@
- type: custom-api
title: 💥 xkcd
cache: 2m
url: https://xkcd.com/info.0.json
template: |
<center>{{ .JSON.String "title" }}</center>
<img src="{{ .JSON.String "img" }}"></img>