Remove global service declarations and change to declarations upon usage. (#761)
* Remove global service declarations and change to declarations upon usage. * Only load cava service if cava is enabled.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { batteryService } from 'src/lib/constants/services.js';
|
||||
import AstalBattery from 'gi://AstalBattery?version=0.1';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
import { openMenu } from '../../utils/menu';
|
||||
import options from 'src/options';
|
||||
@@ -6,10 +6,10 @@ import { BarBoxChild } from 'src/lib/types/bar.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/utils/helpers.js';
|
||||
import Variable from 'astal/variable';
|
||||
import { bind } from 'astal';
|
||||
import AstalBattery from 'gi://AstalBattery?version=0.1';
|
||||
import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers';
|
||||
import { getBatteryIcon } from './helpers';
|
||||
|
||||
const batteryService = AstalBattery.get_default();
|
||||
const { label: show_label, rightClick, middleClick, scrollUp, scrollDown, hideLabelWhenFull } = options.bar.battery;
|
||||
|
||||
const BatteryLabel = (): BarBoxChild => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { bluetoothService } from 'src/lib/constants/services.js';
|
||||
import options from 'src/options.js';
|
||||
import { openMenu } from '../../utils/menu.js';
|
||||
import { BarBoxChild } from 'src/lib/types/bar.js';
|
||||
@@ -8,6 +7,8 @@ import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/l
|
||||
import AstalBluetooth from 'gi://AstalBluetooth?version=0.1';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
|
||||
const bluetoothService = AstalBluetooth.get_default();
|
||||
|
||||
const { rightClick, middleClick, scrollDown, scrollUp } = options.bar.bluetooth;
|
||||
|
||||
const Bluetooth = (): BarBoxChild => {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { bind, Variable } from 'astal';
|
||||
import { cavaService, mprisService } from 'src/lib/constants/services';
|
||||
import AstalCava from 'gi://AstalCava?version=0.1';
|
||||
import AstalMpris from 'gi://AstalMpris?version=0.1';
|
||||
import options from 'src/options';
|
||||
|
||||
const mprisService = AstalMpris.get_default();
|
||||
const {
|
||||
showActiveOnly,
|
||||
bars,
|
||||
@@ -20,8 +22,10 @@ const {
|
||||
*
|
||||
* @param isVis - A variable that holds the visibility status.
|
||||
*/
|
||||
export function initVisibilityTracker(isVis: Variable<boolean>): void {
|
||||
Variable.derive([bind(showActiveOnly), bind(mprisService, 'players')], (showActive, players) => {
|
||||
export function initVisibilityTracker(isVis: Variable<boolean>): Variable<void> {
|
||||
const cavaService = AstalCava.get_default();
|
||||
|
||||
return Variable.derive([bind(showActiveOnly), bind(mprisService, 'players')], (showActive, players) => {
|
||||
isVis.set(cavaService !== null && (!showActive || players?.length > 0));
|
||||
});
|
||||
}
|
||||
@@ -29,14 +33,14 @@ export function initVisibilityTracker(isVis: Variable<boolean>): void {
|
||||
/**
|
||||
* Initializes a settings tracker that updates the CAVA service settings based on the provided options.
|
||||
*/
|
||||
export function initSettingsTracker(): void {
|
||||
const cava = cavaService;
|
||||
export function initSettingsTracker(): Variable<void> | undefined {
|
||||
const cava = AstalCava.get_default();
|
||||
|
||||
if (!cava) {
|
||||
return;
|
||||
}
|
||||
|
||||
Variable.derive(
|
||||
return Variable.derive(
|
||||
[
|
||||
bind(bars),
|
||||
bind(channels),
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Variable, bind } from 'astal';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
import { cavaService } from 'src/lib/constants/services';
|
||||
import { BarBoxChild } from 'src/lib/types/bar';
|
||||
import { Module } from '../../shared/Module';
|
||||
import { inputHandler } from '../../utils/helpers';
|
||||
import options from 'src/options';
|
||||
import { initSettingsTracker, initVisibilityTracker } from './helpers';
|
||||
import AstalCava from 'gi://AstalCava?version=0.1';
|
||||
|
||||
const {
|
||||
icon,
|
||||
@@ -22,12 +22,13 @@ const {
|
||||
|
||||
const isVis = Variable(!showActiveOnly.get());
|
||||
|
||||
initVisibilityTracker(isVis);
|
||||
initSettingsTracker();
|
||||
|
||||
export const Cava = (): BarBoxChild => {
|
||||
let labelBinding: Variable<string> = Variable('');
|
||||
|
||||
const visTracker = initVisibilityTracker(isVis);
|
||||
const settingsTracker = initSettingsTracker();
|
||||
const cavaService = AstalCava.get_default();
|
||||
|
||||
if (cavaService) {
|
||||
labelBinding = Variable.derive(
|
||||
[bind(cavaService, 'values'), bind(spaceCharacter), bind(barCharacters)],
|
||||
@@ -71,6 +72,8 @@ export const Cava = (): BarBoxChild => {
|
||||
},
|
||||
onDestroy: () => {
|
||||
labelBinding.drop();
|
||||
visTracker.drop();
|
||||
settingsTracker?.drop();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import options from 'src/options';
|
||||
import { Module } from '../../shared/Module';
|
||||
import { inputHandler } from 'src/components/bar/utils/helpers';
|
||||
@@ -7,7 +6,9 @@ import { BarBoxChild } from 'src/lib/types/bar';
|
||||
import { bind } from 'astal';
|
||||
import { useHook } from 'src/lib/shared/hookHandler';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
const { label, labelType, icon, leftClick, rightClick, middleClick, scrollUp, scrollDown } =
|
||||
options.bar.customModules.kbLayout;
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@ import { openMenu } from '../../utils/menu.js';
|
||||
import options from 'src/options.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/utils/helpers.js';
|
||||
import { generateMediaLabel } from './helpers/index.js';
|
||||
import { mprisService } from 'src/lib/constants/services.js';
|
||||
import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers.js';
|
||||
import { bind, Variable } from 'astal';
|
||||
import { BarBoxChild } from 'src/lib/types/bar.js';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
import { activePlayer, mediaAlbum, mediaArtist, mediaTitle } from 'src/globals/media.js';
|
||||
import AstalMpris from 'gi://AstalMpris?version=0.1';
|
||||
|
||||
const mprisService = AstalMpris.get_default();
|
||||
const {
|
||||
truncation,
|
||||
truncation_size,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { networkService } from 'src/lib/constants/services';
|
||||
import options from 'src/options';
|
||||
import { Module } from '../../shared/Module';
|
||||
import { inputHandler } from 'src/components/bar/utils/helpers';
|
||||
@@ -12,6 +11,7 @@ import { bind, Variable } from 'astal';
|
||||
import AstalNetwork from 'gi://AstalNetwork?version=0.1';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
|
||||
const networkService = AstalNetwork.get_default();
|
||||
const {
|
||||
label,
|
||||
labelType,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import AstalNetwork from 'gi://AstalNetwork?version=0.1';
|
||||
import { bind, Variable } from 'astal';
|
||||
import { networkService } from 'src/lib/constants/services';
|
||||
|
||||
export const wiredIcon: Variable<string> = Variable('');
|
||||
export const wirelessIcon: Variable<string> = Variable('');
|
||||
|
||||
const networkService = AstalNetwork.get_default();
|
||||
|
||||
let wiredIconBinding: Variable<void> | undefined;
|
||||
let wirelessIconBinding: Variable<void> | undefined;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { networkService } from 'src/lib/constants/services.js';
|
||||
import options from 'src/options';
|
||||
import { openMenu } from '../../utils/menu';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/utils/helpers.js';
|
||||
@@ -9,6 +8,7 @@ import AstalNetwork from 'gi://AstalNetwork?version=0.1';
|
||||
import { BarBoxChild } from 'src/lib/types/bar.js';
|
||||
import { formatWifiInfo, wiredIcon, wirelessIcon } from './helpers';
|
||||
|
||||
const networkService = AstalNetwork.get_default();
|
||||
const { label, truncation, truncation_size, rightClick, middleClick, scrollDown, scrollUp, showWifiInfo } =
|
||||
options.bar.network;
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import { BarBoxChild } from 'src/lib/types/bar.js';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/utils/helpers.js';
|
||||
import { bind, Variable } from 'astal';
|
||||
import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers';
|
||||
import { notifdService } from 'src/lib/constants/services';
|
||||
|
||||
const notifdService = AstalNotifd.get_default();
|
||||
const { show_total, rightClick, middleClick, scrollUp, scrollDown, hideCountWhenZero } = options.bar.notifications;
|
||||
const { ignore } = options.notifications;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { Variable } from 'astal';
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
|
||||
/**
|
||||
* Determines if a submap is enabled based on the provided submap name.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import options from 'src/options';
|
||||
import { Module } from '../../shared/Module';
|
||||
import { inputHandler } from 'src/components/bar/utils/helpers';
|
||||
@@ -7,7 +6,9 @@ import { capitalizeFirstLetter } from 'src/lib/utils';
|
||||
import { getInitialSubmap, isSubmapEnabled } from './helpers';
|
||||
import { bind, Variable } from 'astal';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
const {
|
||||
label,
|
||||
showSubmapName,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { audioService } from 'src/lib/constants/services.js';
|
||||
import { openMenu } from '../../utils/menu.js';
|
||||
import options from 'src/options';
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/utils/helpers.js';
|
||||
@@ -7,6 +6,10 @@ import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/l
|
||||
import { getIcon } from './helpers/index.js';
|
||||
import { BarBoxChild } from 'src/lib/types/bar.js';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
import AstalWp from 'gi://AstalWp?version=0.1';
|
||||
|
||||
const wireplumber = AstalWp.get_default() as AstalWp.Wp;
|
||||
const audioService = wireplumber?.audio;
|
||||
|
||||
const { rightClick, middleClick, scrollUp, scrollDown } = options.bar.volume;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import options from 'src/options';
|
||||
import { capitalizeFirstLetter } from 'src/lib/utils';
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import { bind, Variable } from 'astal';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
export const clientTitle = Variable('');
|
||||
let clientBinding: Variable<void> | undefined;
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/utils/helpers';
|
||||
import { BarBoxChild } from 'src/lib/types/bar';
|
||||
import options from 'src/options';
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers';
|
||||
import { bind, Variable } from 'astal';
|
||||
import { clientTitle, getTitle, getWindowMatch, truncateTitle } from './helpers/title';
|
||||
import { Astal } from 'astal/gtk3';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
const { leftClick, rightClick, middleClick, scrollDown, scrollUp } = options.bar.windowtitle;
|
||||
|
||||
const ClientTitle = (): BarBoxChild => {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Variable } from 'astal';
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import { MonitorMap, WorkspaceMonitorMap, WorkspaceRule } from 'src/lib/types/workspace';
|
||||
import { range } from 'src/lib/utils';
|
||||
import options from 'src/options';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
const { workspaces, reverse_scroll, ignored } = options.bar.workspaces;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
import { defaultApplicationIcons } from 'src/lib/constants/workspaces';
|
||||
import { AppIconOptions, WorkspaceIconMap } from 'src/lib/types/workspace';
|
||||
import { isValidGjsColor } from 'src/lib/utils';
|
||||
import options from 'src/options';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
const { monochrome, background } = options.theme.bar.buttons;
|
||||
const { background: wsBackground, active } = options.theme.bar.buttons.workspaces;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import options from 'src/options';
|
||||
import { forceUpdater, getWorkspacesToRender, initWorkspaceEvents, workspaceRules } from './helpers';
|
||||
import { getAppIcon, getWsColor, renderClassnames, renderLabel } from './helpers/utils';
|
||||
@@ -8,6 +7,7 @@ import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
import { Gtk } from 'astal/gtk3';
|
||||
import { isPrimaryClick } from 'src/lib/utils';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
const {
|
||||
workspaces,
|
||||
monitorSpecific,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { hyprlandService } from 'src/lib/constants/services';
|
||||
import { Gdk } from 'astal/gtk3';
|
||||
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
|
||||
import { BarLayout, BarLayouts } from 'src/lib/types/options';
|
||||
|
||||
const hyprlandService = AstalHyprland.get_default();
|
||||
|
||||
type GdkMonitors = {
|
||||
[key: string]: {
|
||||
key: string;
|
||||
|
||||
Reference in New Issue
Block a user