Fix: Weather service now uses the proper units on startup (#975)
* Fix: Weather service now uses the proper units on startup * Fix: Screen recorder now creates the needed directory
This commit is contained in:
@@ -39,8 +39,8 @@ startRecording() {
|
|||||||
|
|
||||||
# Ensure output directory exists
|
# Ensure output directory exists
|
||||||
if [ ! -d "$outputDir" ]; then
|
if [ ! -d "$outputDir" ]; then
|
||||||
echo "Error: Output directory '$outputDir' does not exist."
|
mkdir -p "$outputDir"
|
||||||
exit 1
|
echo "Created output directory: $outputDir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate output filename and path
|
# Generate output filename and path
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
import { Gtk } from 'astal/gtk3';
|
import { Gtk } from 'astal/gtk3';
|
||||||
import { bind } from 'astal';
|
import { bind } from 'astal';
|
||||||
import WeatherService from 'src/services/weather';
|
import WeatherService from 'src/services/weather';
|
||||||
import options from 'src/configuration';
|
|
||||||
import { toTitleCase } from 'src/lib/string/formatters';
|
import { toTitleCase } from 'src/lib/string/formatters';
|
||||||
|
|
||||||
const { unit } = options.menus.clock.weather;
|
|
||||||
const weatherService = WeatherService.getInstance();
|
const weatherService = WeatherService.getInstance();
|
||||||
|
|
||||||
unit.subscribe((unitType) => (weatherService.unit = unitType));
|
|
||||||
|
|
||||||
const WeatherStatus = (): JSX.Element => {
|
const WeatherStatus = (): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<box halign={Gtk.Align.CENTER}>
|
<box halign={Gtk.Align.CENTER}>
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { AstalIO, bind, interval, Variable } from 'astal';
|
|||||||
import { getWeatherProvider } from 'src/services/weather/adapters/registry';
|
import { getWeatherProvider } from 'src/services/weather/adapters/registry';
|
||||||
import { WeatherApiKeyManager } from './keyManager';
|
import { WeatherApiKeyManager } from './keyManager';
|
||||||
import options from 'src/configuration';
|
import options from 'src/configuration';
|
||||||
import { Opt } from 'src/lib/options';
|
|
||||||
import { httpClient } from 'src/lib/httpClient';
|
import { httpClient } from 'src/lib/httpClient';
|
||||||
import { GaugeIcon, Percentage, Weather, WeatherIcon } from './types';
|
import { GaugeIcon, Percentage, Weather, WeatherIcon } from './types';
|
||||||
import { DEFAULT_WEATHER } from './default';
|
import { DEFAULT_WEATHER } from './default';
|
||||||
import { WeatherProvider } from './adapters/types';
|
import { WeatherProvider } from './adapters/types';
|
||||||
import { TemperatureConverter } from 'src/lib/units/temperature';
|
import { TemperatureConverter } from 'src/lib/units/temperature';
|
||||||
import { SpeedConverter } from 'src/lib/units/speed';
|
import { SpeedConverter } from 'src/lib/units/speed';
|
||||||
import { UnitType } from 'src/lib/units/temperature/types';
|
|
||||||
|
const { interval: weatherInterval, location, unit } = options.menus.clock.weather;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for fetching and managing weather data from various providers
|
* Service for fetching and managing weather data from various providers
|
||||||
@@ -19,11 +19,11 @@ export default class WeatherService {
|
|||||||
|
|
||||||
private _currentProvider = 'weatherapi';
|
private _currentProvider = 'weatherapi';
|
||||||
|
|
||||||
private readonly _location: Opt<string>;
|
private readonly _location = location;
|
||||||
|
private readonly _intervalFrequency = weatherInterval;
|
||||||
|
private readonly _unitType = unit;
|
||||||
|
|
||||||
private readonly _intervalFrequency: Opt<number>;
|
|
||||||
private _interval: null | AstalIO.Time = null;
|
private _interval: null | AstalIO.Time = null;
|
||||||
private _unitType: Variable<UnitType> = Variable('imperial');
|
|
||||||
|
|
||||||
private _weatherData: Variable<Weather> = Variable(DEFAULT_WEATHER);
|
private _weatherData: Variable<Weather> = Variable(DEFAULT_WEATHER);
|
||||||
private _temperature: Variable<string> = Variable(this._getTemperature());
|
private _temperature: Variable<string> = Variable(this._getTemperature());
|
||||||
@@ -33,11 +33,6 @@ export default class WeatherService {
|
|||||||
private _gaugeIcon: Variable<GaugeIcon> = Variable(this._getGaugeIcon());
|
private _gaugeIcon: Variable<GaugeIcon> = Variable(this._getGaugeIcon());
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
const { interval, location } = options.menus.clock.weather;
|
|
||||||
|
|
||||||
this._intervalFrequency = interval;
|
|
||||||
this._location = location;
|
|
||||||
|
|
||||||
this._initializeConfigTracker();
|
this._initializeConfigTracker();
|
||||||
this._initializeWeatherTracker();
|
this._initializeWeatherTracker();
|
||||||
}
|
}
|
||||||
@@ -128,24 +123,6 @@ export default class WeatherService {
|
|||||||
return this._gaugeIcon;
|
return this._gaugeIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current temperature unit type
|
|
||||||
*
|
|
||||||
* @returns Current unit type ('imperial' or 'metric')
|
|
||||||
*/
|
|
||||||
public get unit(): UnitType {
|
|
||||||
return this._unitType.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the temperature unit type
|
|
||||||
*
|
|
||||||
* @param unitType - New unit type ('imperial' or 'metric')
|
|
||||||
*/
|
|
||||||
public set unit(unitType: UnitType) {
|
|
||||||
this._unitType.set(unitType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the temperature from the weather data in the specified unit.
|
* Gets the temperature from the weather data in the specified unit.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user