I am dropping a patch file here to use colorized icons instead.
diff --git a/src/extension.ts b/src/extension.ts
index c42d7cf..feeaf1b 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -39,6 +39,7 @@ import { showWelcome, showManualConfig } from "./welcome.js";
import { setFirstTimeConfig } from "./autoConfig.js";
import { displayDetail } from "./details.js";
import { theme, themeInitAll, themeRemoveAll } from "./theme.js";
+import { getWeatherGIcon } from "./icons.js";
import { AutoConfigFailError } from "./errors.js";
const FAIL_RETRIES : number = 10;
@@ -398,8 +399,11 @@ export default class SimpleWeatherExtension extends Extension {
}
if(this.#panelIcon) {
- const suffix = this.#config!.getSymbolicIcons() ? "-symbolic" : "";
- this.#panelIcon.icon_name = w.gIconName + suffix;
+ this.#panelIcon.gicon = getWeatherGIcon(w.gIconName, this.metadata.path, {
+ symbolic: this.#config!.getSymbolicIcons(),
+ packaged: this.#config!.getAlwaysPackagedIcons(),
+ size: "small"
+ });
}
const showSunset = w.sunset < w.sunrise;
diff --git a/src/icons.ts b/src/icons.ts
index 0f70921..80fb8a6 100644
--- a/src/icons.ts
+++ b/src/icons.ts
@@ -15,6 +15,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+import Gio from "gi://Gio";
+
export const Icons = {
Clear: "clear",
Cloudy: "few-clouds",
@@ -32,6 +34,32 @@ export const Icons = {
Tornado: "tornado"
};
+const HICOLOR_ICON_BASES = new Set([
+ "weather-clear",
+ "weather-clear-night",
+ "weather-few-clouds",
+ "weather-few-clouds-night",
+ "weather-fog",
+ "weather-overcast",
+ "weather-showers",
+ "weather-showers-scattered",
+ "weather-snow",
+ "weather-storm",
+ "weather-tornado",
+ "weather-windy"
+]);
+
+const HICOLOR_FALLBACKS : Record<string, string> = {
+ "weather-freezing-rain": "weather-showers",
+ "weather-freezing-storm": "weather-storm"
+};
+
+interface WeatherIconOptions {
+ symbolic? : boolean;
+ packaged? : boolean;
+ size? : "small" | "large";
+}
+
function iconHasNightVariant(name: string) {
return name === "clear" || name === "few-clouds";
}
@@ -43,3 +71,26 @@ export function getGIconName(name: string, isNight: boolean): string {
return fullName;
}
+function packagedIcon(extensionPath: string, name: string) : Gio.Icon {
+ const iconPath = `${extensionPath}/icons/${name}-symbolic.svg`;
+ const iconFile = Gio.File.new_for_path(iconPath);
+ return new Gio.FileIcon({ file: iconFile });
+}
+
+export function getWeatherGIcon(
+ name: string,
+ extensionPath: string,
+ opts: WeatherIconOptions = {}
+) : Gio.Icon {
+ const { symbolic = false, packaged = false, size = "large" } = opts;
+
+ if (symbolic && packaged) return packagedIcon(extensionPath, name);
+ if (symbolic) return Gio.ThemedIcon.new(`${name}-symbolic`);
+
+ const hicolorBase = HICOLOR_ICON_BASES.has(name)
+ ? name
+ : HICOLOR_FALLBACKS[name];
+
+ if (hicolorBase) return Gio.ThemedIcon.new(`${hicolorBase}-${size}`);
+ return packagedIcon(extensionPath, name);
+}
diff --git a/src/popup.ts b/src/popup.ts
index e2d6bb6..af2a8de 100644
--- a/src/popup.ts
+++ b/src/popup.ts
@@ -29,6 +29,7 @@ import { gettext as _g } from "./gettext.js";
import { Details, displayDetail } from "./details.js";
import { theme } from "./theme.js";
import { CarouselBox } from "./carouselbox.js";
+import { getWeatherGIcon } from "./icons.js";
interface ForecastCard {
card : St.BoxLayout;
@@ -398,9 +399,10 @@ export class Popup {
}
#createIcon(s : string) : Gio.Icon {
- const iconPath = `${this.#metadata.path}/icons/${s}-symbolic.svg`;
- const iconFile = Gio.File.new_for_path(iconPath);
- return new Gio.FileIcon({ file: iconFile });
+ return getWeatherGIcon(s, this.#metadata.path, {
+ packaged: this.#config.getAlwaysPackagedIcons(),
+ size: "large"
+ });
}
#displayErr(copyrightText : string | undefined = undefined) : void {
Summary:
- Add a shared weather icon resolver that can choose themed hicolor weather icons.
- Use hicolor `weather-*-small` icons in the panel and `weather-*-large` icons in the popup when symbolic icons are disabled.
- Keep packaged symbolic icons as the fallback, including for missing hicolor variants such as freezing rain/storm.
Notes:
- `weather-freezing-rain` falls back to `weather-showers`.
- `weather-freezing-storm` falls back to `weather-storm`.
Hi,
I am dropping a patch file here to use colorized icons instead.
simpleweather-hicolor-icons.patch
Documentation related to this patch:
thanks