From faa0bf7cd5a3de30e09e1c5a76cdbf626ff0970a Mon Sep 17 00:00:00 2001 From: koffeejava Date: Thu, 12 Mar 2026 19:14:04 -0600 Subject: [PATCH] added support for comments in disp.toml --- disp-configs/customary.toml | 9 +++++++++ src/wfetch.cr | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 disp-configs/customary.toml diff --git a/disp-configs/customary.toml b/disp-configs/customary.toml new file mode 100644 index 0000000..86f911a --- /dev/null +++ b/disp-configs/customary.toml @@ -0,0 +1,9 @@ +# This is for customary units + +1 = "{icon}" +2 = "Live Temperature: {temp_f}°" +3 = "Feels like: {feels_temp_f}°" +4 = "Wind Speed: {wind_mph} MPH" +5 = "Humidity: {humidity}%" +6 = "Pressure: {pressure_in}" +7 = "Description: {orange}{bold}{description}{reset}" diff --git a/src/wfetch.cr b/src/wfetch.cr index 0b5f92c..0af8c06 100644 --- a/src/wfetch.cr +++ b/src/wfetch.cr @@ -82,10 +82,14 @@ module Wfetch repeat = 1 File.each_line("/home/koffeejava/.local/share/Wfetch/disp.toml") do |line| - if disp["#{repeat}"].to_s == "{icon}" - icon(id) + entry = disp["#{repeat}"]? # Use []? to avoid KeyError + + if entry + if entry.to_s == "{icon}" + icon(id) + end + puts entry.to_s.gsub("{temp_f}", temp).gsub("{temp_c}", tempm).gsub("{feels_temp_f}", fftemp).gsub("{feels_temp_c}", fctemp).gsub("{wind_mph}", cwind).gsub("{wind_kph}", mwind).gsub("{humidity}", humidity).gsub("{pressure_in}", pressin).gsub("{description}", desc).gsub("{orange}", "\e[38;5;214m").gsub("{blue}", "\e[38;5;33m").gsub("{bold}", "\033[1m").gsub("{reset}", "\e[0m").gsub("{icon}", nil) end - puts disp["#{repeat}"].to_s.gsub("{temp_f}", temp).gsub("{temp_c}", tempm).gsub("{feels_temp_f}", fftemp).gsub("{feels_temp_c}", fctemp).gsub("{wind_mph}", cwind).gsub("{wind_kph}", mwind).gsub("{humidity}", humidity).gsub("{pressure_in}", pressin).gsub("{description}", desc).gsub("{orange}", "\e[38;5;214m").gsub("{blue}", "\e[38;5;33m").gsub("{bold}", "\033[1m").gsub("{reset}", "\e[0m").gsub("{icon}", nil) repeat += 1 end