* Eslint updates * linter fixes * Type fixes * More type fixes * Fix isvis * More type fixes * Type Fixes * Consolidate logic to manage options * Linter fixes * Package lock update * Update configs * Version checker * Debug pipeline * Package lock update * Update ci * Strict check * Revert ci * Eslint * Remove rule since it causes issues in CI * Actual matugen fix
21 lines
605 B
TypeScript
21 lines
605 B
TypeScript
import { bind, Variable } from 'astal';
|
|
import AstalNetwork from 'gi://AstalNetwork?version=0.1';
|
|
|
|
const networkService = AstalNetwork.get_default();
|
|
|
|
export const isWifiEnabled: Variable<boolean> = Variable(false);
|
|
let wifiEnabledBinding: Variable<void> | undefined;
|
|
|
|
Variable.derive([bind(networkService, 'wifi')], () => {
|
|
wifiEnabledBinding?.drop();
|
|
wifiEnabledBinding = undefined;
|
|
|
|
if (networkService.wifi === null) {
|
|
return;
|
|
}
|
|
|
|
wifiEnabledBinding = Variable.derive([bind(networkService.wifi, 'enabled')], (isEnabled) => {
|
|
isWifiEnabled.set(isEnabled);
|
|
});
|
|
});
|