Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for custom location #145

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ terminal = {icon = " ", name = "term", color = "(RD)"}
shell = {icon = " ", name = "shell", color = "(MA)"}
# packages = {icon = " ", name = "packages", color = "(RD)"} # WARNING: Resource Intensive
# weather = {icon = " ", name = "weather", color = "(BE)"} # Requires curl and an emoji font. | WARNING: Resource Intensive
# The following stats do not work on MacOS and the BSDs.
# gpu = {icon = "󱔐 ", name = "gpu", color = "(MA)"} # WARNING: Resource Intensive
# cpu = {icon = " ", name = "cpu", color = "(RD)"}
# battery = {icon = " ", name = "battery", color = "(GN)"}
# The following stats do not work on MacOS and the BSDs.
# disk_0 = {icon = " ", name = "disk", color = "(GN)"}
# memory = {icon = " ", name = "memory", color = "(YW)"}
# battery = {icon = " ", name = "battery", color = "(GN)"}
sep_color = "SEPARATOR"
colors = {icon = " ", name = "colors", color = "!DT!", symbol = ""}

Expand All @@ -34,6 +34,7 @@ colors = {icon = " ", name = "colors", color = "!DT!", symbol = ""}
borderstyle = "line"
layout = "Inline" # [Inline, ArtOnTop, StatsOnTop]
stats_margin_top = 0
location = "" # Used for fetching weather; leave empty to use the location of your IP; check https://wttr.in/:help for supported location types

[misc.figletLogos] # Requires Figlet.
enable = false
Expand Down
1 change: 1 addition & 0 deletions scripts/test_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ colors = {icon = "> ", name = "colors", color = "!DT!", symbol = "#"}
borderstyle = "doubleline"
layout = "Inline"
stats_margin_top = 0
location = "San Francisco"

[misc.figletLogos]
enable = false
Expand Down
2 changes: 1 addition & 1 deletion src/catnaplib/platform/fetch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ proc fetchSystemInfo*(config: Config, distroId: string = "nil"): FetchInfo =
result.list["cpu"] = proc(): string = return probe.getCpu()
result.list["gpu"] = proc(): string = return probe.getGpu()
result.list["packages"] = proc(): string = return probe.getPackages()
result.list["weather"] = proc(): string = return probe.getWeather()
result.list["weather"] = proc(): string = return probe.getWeather(config.misc["location"].getStr())
if defined(linux):
# Add a disk stat for all mounts
let mounts: seq[string] = probe.getMounts()
Expand Down
4 changes: 2 additions & 2 deletions src/catnaplib/platform/probe.nim
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ proc getGpu*(): string =

writeCache(cacheFile, result, initDuration(days=1))

proc getWeather*(): string =
proc getWeather*(location: string): string =
# Returns current weather
let cacheFile = "weather".toCachePath

Expand All @@ -360,7 +360,7 @@ proc getWeather*(): string =
return

let tmpFile = "weather.txt".toTmpPath
if execCmd("curl -s wttr.in/?format=3 > " & tmpFile) != 0:
if execCmd("curl -s wttr.in/" & location & "?format=3 > " & tmpFile) != 0:
logError("Failed to fetch weather!")

result = readFile(tmpFile).strip()
Expand Down