Skip to content

Changed weather module location. #871

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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -694,4 +694,4 @@ in

wayland.windowManager.hyprland.settings.exec-once = mkIf cfg.hyprland.enable [ "${package}/bin/hyprpanel" ];
};
}
}
2 changes: 1 addition & 1 deletion scripts/screen_record.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ status)
echo "Usage: $0 {start [screen <monitor_name> | region] <output_directory> | stop | status}"
exit 1
;;
esac
esac
18 changes: 18 additions & 0 deletions src/components/bar/settings/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,24 @@ export const CustomModuleSettings = (): JSX.Element => {
title="Button Border"
type="boolean"
/>
<Option
opt={options.bar.customModules.weather.location}
title="Location"
subtitle="Zip Code, Postal Code, City, etc."
type="string"
/>
<Option
opt={options.bar.customModules.weather.key}
title="Weather API Key"
subtitle="API Key or path to JSON file containing 'weather_api_key'"
type="string"
/>
<Option
opt={options.bar.customModules.weather.interval}
title="Weather Fetching Interval (ms)"
subtitle="May require AGS restart."
type="number"
/>
<Option opt={options.bar.customModules.weather.label} title="Show Label" type="boolean" />
<Option
opt={options.bar.customModules.weather.unit}
Expand Down
23 changes: 9 additions & 14 deletions src/components/menus/calendar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import DropdownMenu from '../shared/dropdown/index.js';
import { TimeWidget } from './time/index';
import { CalendarWidget } from './CalendarWidget.js';
import { WeatherWidget } from './weather/index';
import options from 'src/options';
import { bind } from 'astal';
import { RevealerTransitionMap } from 'src/lib/constants/options.js';

const { transition } = options.menus;
const { enabled: weatherEnabled } = options.menus.clock.weather;

export default (): JSX.Element => {
return (
Expand All @@ -16,19 +14,16 @@ export default (): JSX.Element => {
transition={bind(transition).as((transition) => RevealerTransitionMap[transition])}
>
<box css={'padding: 1px; margin: -1px;'}>
{bind(weatherEnabled).as((isWeatherEnabled) => {
return (
<box className={'calendar-menu-content'} vexpand={false}>
<box className={'calendar-content-container'} vertical>
<box className={'calendar-content-items'} vertical>
<TimeWidget />
<CalendarWidget />
<WeatherWidget isEnabled={isWeatherEnabled} />
</box>
</box>
return (
<box className={'calendar-menu-content'} vexpand={false}>
<box className={'calendar-content-container'} vertical>
<box className={'calendar-content-items'} vertical>
<TimeWidget />
<CalendarWidget />
</box>
);
})}
</box>
</box>
); )
</box>
</DropdownMenu>
);
Expand Down
31 changes: 0 additions & 31 deletions src/components/menus/calendar/weather/index.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions src/components/menus/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import CalendarMenu from './calendar/index.js';
import EnergyMenu from './energy/index.js';
import DashboardMenu from './dashboard/index.js';
import PowerDropdown from './powerDropdown/index.js';
import weatherdropdown from './weatherdropdown/index.js';

export const DropdownMenus = [
AudioMenu,
Expand All @@ -20,6 +21,7 @@ export const DropdownMenus = [
EnergyMenu,
DashboardMenu,
PowerDropdown,
weatherdropdown,
];

export const StandardWindows = [PowerMenu, Verification];
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { globalWeatherVar } from 'src/globals/weather';
import { getNextEpoch } from '../helpers';
import { bind, Variable } from 'astal';

const { unit } = options.menus.clock.weather;
const { unit } = options.bar.customModules.weather;

export const HourlyTemp = ({ hoursFromNow }: HourlyTempProps): JSX.Element => {
const weatherBinding = Variable.derive([bind(globalWeatherVar), bind(unit)], (weather, unitType) => {
Expand Down
32 changes: 32 additions & 0 deletions src/components/menus/weatherdropdown/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { TodayIcon } from './icon/index.js';
import { TodayStats } from './stats/index.js';
import { TodayTemperature } from './temperature/index.js';
import { HourlyTemperature } from './hourly/index.js';
import Separator from 'src/components/shared/Separator.js';
import { bind } from 'astal';
import { RevealerTransitionMap } from 'src/lib/constants/options.js';
import DropdownMenu from '../shared/dropdown/index.js';
import options from 'src/options.js';

export default (): JSX.Element => {
return (
<DropdownMenu
name="weatherdropdownmenu"
transition={bind(options.menus.transition).as((transition) => RevealerTransitionMap[transition])}
>
<box className={'calendar-menu-item-container weather'}>
<box className={'weather-container-box'}>
<box vertical hexpand>
<box className={'calendar-menu-weather today'} hexpand>
<TodayIcon />
<TodayTemperature />
<TodayStats />
</box>
<Separator className={'menu-separator weather'} />
<HourlyTemperature />
</box>
</box>
</box>
</DropdownMenu>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getRainChance } from 'src/globals/weather';
import { Gtk } from 'astal/gtk3';
import { bind, Variable } from 'astal';

const { unit } = options.menus.clock.weather;
const { unit } = options.bar.customModules.weather;

export const TodayStats = (): JSX.Element => {
const temperatureBinding = Variable.derive([bind(globalWeatherVar), bind(unit)], getTemperature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { globalWeatherVar } from 'src/globals/weather';
import { getTemperature, getWeatherIcon } from 'src/globals/weather';
import { Gtk } from 'astal/gtk3';
import { bind, Variable } from 'astal';
const { unit } = options.menus.clock.weather;
const { unit } = options.bar.customModules.weather;

const WeatherStatus = (): JSX.Element => {
return (
Expand Down
27 changes: 0 additions & 27 deletions src/components/settings/pages/config/menus/clock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,6 @@ export const ClockMenuSettings = (): JSX.Element => {
<Header title="Time" />
<Option opt={options.menus.clock.time.military} title="Use 24hr time" type="boolean" />
<Option opt={options.menus.clock.time.hideSeconds} title="Hide seconds" type="boolean" />

<Header title="Weather" />
<Option opt={options.menus.clock.weather.enabled} title="Enabled" type="boolean" />
<Option
opt={options.menus.clock.weather.location}
title="Location"
subtitle="Zip Code, Postal Code, City, etc."
type="string"
/>
<Option
opt={options.menus.clock.weather.key}
title="Weather API Key"
subtitle="API Key or path to JSON file containing 'weather_api_key'"
type="string"
/>
<Option
opt={options.menus.clock.weather.unit}
title="Units"
type="enum"
enums={['imperial', 'metric']}
/>
<Option
opt={options.menus.clock.weather.interval}
title="Weather Fetching Interval (ms)"
subtitle="May require AGS restart."
type="number"
/>
</box>
</scrollable>
);
Expand Down
2 changes: 1 addition & 1 deletion src/globals/weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AstalIO, bind, execAsync, interval, Variable } from 'astal';

const { EXISTS, IS_REGULAR } = GLib.FileTest;

const { key, interval: weatherInterval, location } = options.menus.clock.weather;
const { key, interval: weatherInterval, location } = options.bar.customModules.weather;

export const globalWeatherVar = Variable<Weather>(DEFAULT_WEATHER);

Expand Down
12 changes: 4 additions & 8 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,10 @@ const options = mkOptions({
weather: {
label: opt(true),
unit: opt<UnitType>('imperial'),
leftClick: opt(''),
interval: opt(60000),
location: opt('Los Angeles'),
key: opt<string>(''),
leftClick: opt('menu:weatherdropdown'),
rightClick: opt(''),
middleClick: opt(''),
scrollUp: opt(''),
Expand Down Expand Up @@ -1362,13 +1365,6 @@ const options = mkOptions({
military: opt(false),
hideSeconds: opt(false),
},
weather: {
enabled: opt(true),
interval: opt(60000),
unit: opt<UnitType>('imperial'),
location: opt('Los Angeles'),
key: opt<string>(''),
},
},
},

Expand Down