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:
Jas Singh
2025-02-06 02:15:20 -08:00
committed by GitHub
parent 537a9653ed
commit 6b846b9709
68 changed files with 206 additions and 118 deletions

View File

@@ -1,10 +1,10 @@
import { bind, Variable } from 'astal';
import { hyprlandService } from '../constants/services';
import { App } from 'astal/gtk3';
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
import { forceUpdater } from 'src/components/bar/modules/workspaces/helpers';
import options from 'src/options';
const hyprlandService = AstalHyprland.get_default();
const { autoHide } = options.bar;
const focusedClient = (focusedClient: AstalHyprland.Client): void => {

View File

@@ -1,7 +1,9 @@
import { batteryService } from '../constants/services';
import AstalBattery from 'gi://AstalBattery?version=0.1';
import icons from '../icons/icons';
import { Notify } from '../utils';
const batteryService = AstalBattery.get_default();
export function warnOnLowBattery(): void {
let sentLowNotification = false;
let sentHalfLowNotification = false;

View File

@@ -1,4 +1,6 @@
import { hyprlandService } from '../constants/services';
import AstalHyprland from 'gi://AstalHyprland?version=0.1';
const hyprlandService = AstalHyprland.get_default();
const floatSettingsDialog = (): void => {
hyprlandService.message(`keyword windowrulev2 float, title:^(hyprpanel-settings)$`);

View File

@@ -1,37 +0,0 @@
/**
* NOTE: This approach is not recommended if the program is going to be
* running as a client.
* ---------------------------------------
* Hyprpanel will not be, so this is fine.
* ---------------------------------------
*/
import Hyprland from 'gi://AstalHyprland';
export const hyprlandService = Hyprland.get_default();
import AstalMpris from 'gi://AstalMpris?version=0.1';
export const mprisService = AstalMpris.get_default();
import AstalWp from 'gi://AstalWp?version=0.1';
const wireplumber = AstalWp.get_default() as AstalWp.Wp;
export const audioService = wireplumber.audio;
import AstalNetwork from 'gi://AstalNetwork?version=0.1';
export const networkService = AstalNetwork.get_default();
import AstalBluetooth from 'gi://AstalBluetooth?version=0.1';
export const bluetoothService = AstalBluetooth.get_default();
import AstalBattery from 'gi://AstalBattery?version=0.1';
export const batteryService = AstalBattery.get_default();
import AstalNotifd from 'gi://AstalNotifd?version=0.1';
export const notifdService = AstalNotifd.get_default();
import Brightness from 'src/services/Brightness';
export const brightnessService = Brightness.get_default();
import AstalPowerProfiles from 'gi://AstalPowerProfiles?version=0.1';
export const powerProfilesService = AstalPowerProfiles.get_default();
import AstalCava from 'gi://AstalCava';
export const cavaService = AstalCava.get_default();

View File

@@ -1,5 +1,6 @@
import AstalMpris from 'gi://AstalMpris?version=0.1';
import { mprisService } from '../constants/services';
const mprisService = AstalMpris.get_default();
export const getCurrentPlayer = (
activePlayer: AstalMpris.Player = mprisService.get_players()[0],