Fixed the auto-hide functionality for the media bar module. (#588)
This commit is contained in:
@@ -14,15 +14,15 @@ import { activePlayer, mediaAlbum, mediaArtist, mediaTitle } from 'src/globals/m
|
||||
const { truncation, truncation_size, show_label, show_active_only, rightClick, middleClick, format } =
|
||||
options.bar.media;
|
||||
|
||||
const Media = (): BarBoxChild => {
|
||||
activePlayer.set(mprisService.get_players()[0]);
|
||||
|
||||
const isVis = Variable(!show_active_only.get());
|
||||
|
||||
show_active_only.subscribe(() => {
|
||||
isVis.set(!show_active_only.get() || mprisService.get_players().length > 0);
|
||||
Variable.derive([bind(show_active_only), bind(mprisService, 'players')], (showActive, players) => {
|
||||
isVis.set(!showActive || players?.length > 0);
|
||||
});
|
||||
|
||||
const Media = (): BarBoxChild => {
|
||||
activePlayer.set(mprisService.get_players()[0]);
|
||||
|
||||
const songIcon = Variable('');
|
||||
|
||||
const mediaLabel = Variable.derive(
|
||||
@@ -55,7 +55,6 @@ const Media = (): BarBoxChild => {
|
||||
<box
|
||||
className={componentClassName()}
|
||||
onDestroy={() => {
|
||||
isVis.drop();
|
||||
songIcon.drop();
|
||||
mediaLabel.drop();
|
||||
componentClassName.drop();
|
||||
|
||||
@@ -5,8 +5,8 @@ import { networkService } from 'src/lib/constants/services';
|
||||
export const wiredIcon: Variable<string> = Variable('');
|
||||
export const wirelessIcon: Variable<string> = Variable('');
|
||||
|
||||
let wiredIconBinding: Variable<void>;
|
||||
let wirelessIconBinding: Variable<void>;
|
||||
let wiredIconBinding: Variable<void> | undefined;
|
||||
let wirelessIconBinding: Variable<void> | undefined;
|
||||
|
||||
/**
|
||||
* Handles the wired network icon binding.
|
||||
@@ -15,10 +15,8 @@ let wirelessIconBinding: Variable<void>;
|
||||
* then checks if the wired network service is available. If available, it binds the icon name to the `wiredIcon` variable.
|
||||
*/
|
||||
const handleWiredIcon = (): void => {
|
||||
if (wiredIconBinding) {
|
||||
wiredIconBinding();
|
||||
wiredIconBinding.drop();
|
||||
}
|
||||
wiredIconBinding?.drop();
|
||||
wiredIconBinding = undefined;
|
||||
|
||||
if (!networkService.wired) {
|
||||
return;
|
||||
@@ -36,10 +34,8 @@ const handleWiredIcon = (): void => {
|
||||
* then checks if the wireless network service is available. If available, it binds the icon name to the `wirelessIcon` variable.
|
||||
*/
|
||||
const handleWirelessIcon = (): void => {
|
||||
if (wirelessIconBinding) {
|
||||
wirelessIconBinding();
|
||||
wirelessIconBinding.drop();
|
||||
}
|
||||
wirelessIconBinding?.drop();
|
||||
wirelessIconBinding = undefined;
|
||||
|
||||
if (!networkService.wifi) {
|
||||
return;
|
||||
|
||||
@@ -2,13 +2,11 @@ import { bind, Variable } from 'astal';
|
||||
import { bluetoothService } from 'src/lib/constants/services';
|
||||
|
||||
export const isDiscovering: Variable<boolean> = Variable(false);
|
||||
let discoveringBinding: Variable<void>;
|
||||
let discoveringBinding: Variable<void> | undefined;
|
||||
|
||||
Variable.derive([bind(bluetoothService, 'adapter')], () => {
|
||||
if (discoveringBinding) {
|
||||
discoveringBinding();
|
||||
discoveringBinding.drop();
|
||||
}
|
||||
discoveringBinding?.drop();
|
||||
discoveringBinding = undefined;
|
||||
|
||||
if (!bluetoothService.adapter) {
|
||||
return;
|
||||
|
||||
@@ -2,13 +2,11 @@ import { bind, Variable } from 'astal';
|
||||
import { networkService } from 'src/lib/constants/services';
|
||||
|
||||
export const isWifiEnabled: Variable<boolean> = Variable(false);
|
||||
let wifiEnabledBinding: Variable<void>;
|
||||
let wifiEnabledBinding: Variable<void> | undefined;
|
||||
|
||||
Variable.derive([bind(networkService, 'wifi')], () => {
|
||||
if (wifiEnabledBinding) {
|
||||
wifiEnabledBinding();
|
||||
wifiEnabledBinding.drop();
|
||||
}
|
||||
wifiEnabledBinding?.drop();
|
||||
wifiEnabledBinding = undefined;
|
||||
|
||||
if (!networkService.wifi) {
|
||||
return;
|
||||
|
||||
@@ -13,10 +13,10 @@ export const wiredSpeed: Variable<number> = Variable(0);
|
||||
/*******************************************
|
||||
* Bindings *
|
||||
*******************************************/
|
||||
let wiredStateBinding: Variable<void>;
|
||||
let wiredInternetBinding: Variable<void>;
|
||||
let wiredIconBinding: Variable<void>;
|
||||
let wiredSpeedBinding: Variable<void>;
|
||||
let wiredStateBinding: Variable<void> | undefined;
|
||||
let wiredInternetBinding: Variable<void> | undefined;
|
||||
let wiredIconBinding: Variable<void> | undefined;
|
||||
let wiredSpeedBinding: Variable<void> | undefined;
|
||||
|
||||
/**
|
||||
* Retrieves the current state of the wired network.
|
||||
@@ -25,10 +25,8 @@ let wiredSpeedBinding: Variable<void>;
|
||||
* If the wired network service is available, it updates the `wiredState` variable with the current state.
|
||||
*/
|
||||
const getWiredState = (): void => {
|
||||
if (wiredStateBinding) {
|
||||
wiredStateBinding();
|
||||
wiredStateBinding.drop();
|
||||
}
|
||||
wiredStateBinding?.drop();
|
||||
wiredStateBinding = undefined;
|
||||
|
||||
if (!networkService.wired) {
|
||||
wiredState.set(AstalNetwork.DeviceState.UNAVAILABLE);
|
||||
@@ -47,10 +45,8 @@ const getWiredState = (): void => {
|
||||
* If the wired network service is available, it updates the `wiredInternet` variable with the current internet status.
|
||||
*/
|
||||
const getWiredInternet = (): void => {
|
||||
if (wiredInternetBinding) {
|
||||
wiredInternetBinding();
|
||||
wiredInternetBinding.drop();
|
||||
}
|
||||
wiredInternetBinding?.drop();
|
||||
wiredInternetBinding = undefined;
|
||||
|
||||
if (!networkService.wired) {
|
||||
return;
|
||||
@@ -68,10 +64,8 @@ const getWiredInternet = (): void => {
|
||||
* If the wired network service is available, it updates the `wiredIcon` variable with the current icon name.
|
||||
*/
|
||||
const getWiredIcon = (): void => {
|
||||
if (wiredIconBinding) {
|
||||
wiredIconBinding();
|
||||
wiredIconBinding.drop();
|
||||
}
|
||||
wiredIconBinding?.drop();
|
||||
wiredIconBinding = undefined;
|
||||
|
||||
if (!networkService.wired) {
|
||||
wiredIcon.set('network-wired-symbolic');
|
||||
@@ -90,10 +84,8 @@ const getWiredIcon = (): void => {
|
||||
* If the wired network service is available, it updates the `wiredSpeed` variable with the current speed.
|
||||
*/
|
||||
const getWiredSpeed = (): void => {
|
||||
if (wiredSpeedBinding) {
|
||||
wiredSpeedBinding();
|
||||
wiredSpeedBinding.drop();
|
||||
}
|
||||
wiredSpeedBinding?.drop();
|
||||
wiredSpeedBinding = undefined;
|
||||
|
||||
if (!networkService.wired) {
|
||||
return;
|
||||
@@ -110,10 +102,3 @@ Variable.derive([bind(networkService, 'wired')], () => {
|
||||
getWiredIcon();
|
||||
getWiredSpeed();
|
||||
});
|
||||
|
||||
Variable.derive([bind(networkService, 'wired')], () => {
|
||||
getWiredState();
|
||||
getWiredInternet();
|
||||
getWiredIcon();
|
||||
getWiredSpeed();
|
||||
});
|
||||
|
||||
@@ -2,13 +2,11 @@ import { bind, Variable } from 'astal';
|
||||
import { networkService } from 'src/lib/constants/services';
|
||||
|
||||
export const isScanning: Variable<boolean> = Variable(false);
|
||||
let scanningBinding: Variable<void>;
|
||||
let scanningBinding: Variable<void> | undefined;
|
||||
|
||||
Variable.derive([bind(networkService, 'wifi')], () => {
|
||||
if (scanningBinding) {
|
||||
scanningBinding();
|
||||
scanningBinding.drop();
|
||||
}
|
||||
scanningBinding?.drop();
|
||||
scanningBinding = undefined;
|
||||
|
||||
if (!networkService.wifi) {
|
||||
return;
|
||||
|
||||
@@ -8,8 +8,8 @@ import { isPrimaryClick, Notify } from 'src/lib/utils';
|
||||
export const isWifiEnabled: Variable<boolean> = Variable(false);
|
||||
export const wifiAccessPoints: Variable<AstalNetwork.AccessPoint[]> = Variable([]);
|
||||
|
||||
let wifiEnabledBinding: Variable<void>;
|
||||
let accessPointBinding: Variable<void>;
|
||||
let wifiEnabledBinding: Variable<void> | undefined;
|
||||
let accessPointBinding: Variable<void> | undefined;
|
||||
|
||||
export const staging = Variable<AstalNetwork.AccessPoint | undefined>(undefined);
|
||||
export const connecting = Variable<string>('');
|
||||
@@ -21,10 +21,8 @@ export const connecting = Variable<string>('');
|
||||
* If the WiFi service is available, it updates the `isWifiEnabled` variable based on the enabled state.
|
||||
*/
|
||||
const wifiEnabled = (): void => {
|
||||
if (wifiEnabledBinding) {
|
||||
wifiEnabledBinding();
|
||||
wifiEnabledBinding.drop();
|
||||
}
|
||||
wifiEnabledBinding?.drop();
|
||||
wifiEnabledBinding = undefined;
|
||||
|
||||
if (!networkService.wifi) {
|
||||
return;
|
||||
@@ -42,10 +40,8 @@ const wifiEnabled = (): void => {
|
||||
* If the WiFi service is available, it updates the `wifiAccessPoints` variable with the list of access points.
|
||||
*/
|
||||
const accessPoints = (): void => {
|
||||
if (accessPointBinding) {
|
||||
accessPointBinding();
|
||||
accessPointBinding.drop();
|
||||
}
|
||||
accessPointBinding?.drop();
|
||||
accessPointBinding = undefined;
|
||||
|
||||
if (!networkService.wifi) {
|
||||
return;
|
||||
|
||||
@@ -44,27 +44,25 @@ export const mediaAlbum = Variable('-----');
|
||||
export const mediaArtist = Variable('-----');
|
||||
export const mediaArtUrl = Variable('');
|
||||
|
||||
let positionUnsub: Variable<void>;
|
||||
let positionUnsub: Variable<void> | undefined;
|
||||
|
||||
let loopUnsub: Variable<void>;
|
||||
let shuffleUnsub: Variable<void>;
|
||||
let loopUnsub: Variable<void> | undefined;
|
||||
let shuffleUnsub: Variable<void> | undefined;
|
||||
|
||||
let canPlayUnsub: Variable<void>;
|
||||
let playbackStatusUnsub: Variable<void>;
|
||||
let canPlayUnsub: Variable<void> | undefined;
|
||||
let playbackStatusUnsub: Variable<void> | undefined;
|
||||
|
||||
let canGoNextUnsub: Variable<void>;
|
||||
let canGoPreviousUnsub: Variable<void>;
|
||||
let canGoNextUnsub: Variable<void> | undefined;
|
||||
let canGoPreviousUnsub: Variable<void> | undefined;
|
||||
|
||||
let titleUnsub: Variable<void>;
|
||||
let albumUnsub: Variable<void>;
|
||||
let artistUnsub: Variable<void>;
|
||||
let artUrlUnsub: Variable<void>;
|
||||
let titleUnsub: Variable<void> | undefined;
|
||||
let albumUnsub: Variable<void> | undefined;
|
||||
let artistUnsub: Variable<void> | undefined;
|
||||
let artUrlUnsub: Variable<void> | undefined;
|
||||
|
||||
const updatePosition = (player: AstalMpris.Player | undefined): void => {
|
||||
if (positionUnsub) {
|
||||
positionUnsub();
|
||||
positionUnsub.drop();
|
||||
}
|
||||
positionUnsub?.drop();
|
||||
positionUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
timeStamp.set('00:00');
|
||||
@@ -91,10 +89,8 @@ const updatePosition = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateLoop = (player: AstalMpris.Player | undefined): void => {
|
||||
if (loopUnsub) {
|
||||
loopUnsub();
|
||||
loopUnsub.drop();
|
||||
}
|
||||
loopUnsub?.drop();
|
||||
loopUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
loopStatus.set(AstalMpris.Loop.NONE);
|
||||
@@ -117,10 +113,8 @@ const updateLoop = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateShuffle = (player: AstalMpris.Player | undefined): void => {
|
||||
if (shuffleUnsub) {
|
||||
shuffleUnsub();
|
||||
shuffleUnsub.drop();
|
||||
}
|
||||
shuffleUnsub?.drop();
|
||||
shuffleUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
shuffleStatus.set(AstalMpris.Shuffle.OFF);
|
||||
@@ -138,10 +132,8 @@ const updateShuffle = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateCanPlay = (player: AstalMpris.Player | undefined): void => {
|
||||
if (canPlayUnsub) {
|
||||
canPlayUnsub();
|
||||
canPlayUnsub.drop();
|
||||
}
|
||||
canPlayUnsub?.drop();
|
||||
canPlayUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
canPlay.set(false);
|
||||
@@ -159,10 +151,8 @@ const updateCanPlay = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updatePlaybackStatus = (player: AstalMpris.Player | undefined): void => {
|
||||
if (playbackStatusUnsub) {
|
||||
playbackStatusUnsub();
|
||||
playbackStatusUnsub.drop();
|
||||
}
|
||||
playbackStatusUnsub?.drop();
|
||||
playbackStatusUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
playbackStatus.set(AstalMpris.PlaybackStatus.STOPPED);
|
||||
@@ -181,10 +171,8 @@ const updatePlaybackStatus = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateCanGoNext = (player: AstalMpris.Player | undefined): void => {
|
||||
if (canGoNextUnsub) {
|
||||
canGoNextUnsub();
|
||||
canGoNextUnsub.drop();
|
||||
}
|
||||
canGoNextUnsub?.drop();
|
||||
canGoNextUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
canGoNext.set(false);
|
||||
@@ -202,10 +190,8 @@ const updateCanGoNext = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateCanGoPrevious = (player: AstalMpris.Player | undefined): void => {
|
||||
if (canGoPreviousUnsub) {
|
||||
canGoPreviousUnsub();
|
||||
canGoPreviousUnsub.drop();
|
||||
}
|
||||
canGoPreviousUnsub?.drop();
|
||||
canGoPreviousUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
canGoPrevious.set(false);
|
||||
@@ -223,10 +209,8 @@ const updateCanGoPrevious = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateTitle = (player: AstalMpris.Player | undefined): void => {
|
||||
if (titleUnsub) {
|
||||
titleUnsub();
|
||||
titleUnsub.drop();
|
||||
}
|
||||
titleUnsub?.drop();
|
||||
titleUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
mediaTitle.set(noMediaText.get());
|
||||
@@ -248,10 +232,8 @@ const updateTitle = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateAlbum = (player: AstalMpris.Player | undefined): void => {
|
||||
if (albumUnsub) {
|
||||
albumUnsub();
|
||||
albumUnsub.drop();
|
||||
}
|
||||
albumUnsub?.drop();
|
||||
albumUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
mediaAlbum.set('-----');
|
||||
@@ -267,10 +249,8 @@ const updateAlbum = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateArtist = (player: AstalMpris.Player | undefined): void => {
|
||||
if (artistUnsub) {
|
||||
artistUnsub();
|
||||
artistUnsub.drop();
|
||||
}
|
||||
artistUnsub?.drop();
|
||||
artistUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
mediaArtist.set('-----');
|
||||
@@ -288,10 +268,8 @@ const updateArtist = (player: AstalMpris.Player | undefined): void => {
|
||||
};
|
||||
|
||||
const updateArtUrl = (player: AstalMpris.Player | undefined): void => {
|
||||
if (artUrlUnsub) {
|
||||
artUrlUnsub();
|
||||
artUrlUnsub.drop();
|
||||
}
|
||||
artUrlUnsub?.drop();
|
||||
artUrlUnsub = undefined;
|
||||
|
||||
if (player === undefined) {
|
||||
mediaArtUrl.set('');
|
||||
|
||||
@@ -31,7 +31,7 @@ export async function generateMatugenColors(): Promise<MatugenColors | undefined
|
||||
|
||||
const normalizedContrast = contrast.get() > 1 ? 1 : contrast.get() < -1 ? -1 : contrast.get();
|
||||
const contents = await bash(
|
||||
`matugen image -q ${wallpaperPath} -t scheme-${scheme_type.get()} --contrast ${normalizedContrast} --json hex`,
|
||||
`matugen image --dry-run -q ${wallpaperPath} -t scheme-${scheme_type.get()} --contrast ${normalizedContrast} --json hex`,
|
||||
);
|
||||
|
||||
return JSON.parse(contents).colors[options.theme.matugen_settings.mode.get()];
|
||||
|
||||
Reference in New Issue
Block a user