Add workspace app icon side-effects and add wiki link for settings. (#387)
* Add side-effect for app icons for workspaces and udated mpris types. * Add links to workspace icon toggles. * Add subtitle
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import icons from 'lib/icons';
|
||||
import { BoxWidget } from 'lib/types/widget';
|
||||
import { getPlayerInfo } from '../../helpers';
|
||||
import { MprisPlayer } from 'types/service/mpris';
|
||||
import { isLoopActive, isValidLoopStatus } from './helpers';
|
||||
|
||||
const media = await Service.import('mpris');
|
||||
@@ -36,7 +35,7 @@ export const loopControl = (): BoxWidget => {
|
||||
child: Widget.Icon({
|
||||
setup: (self) => {
|
||||
self.hook(media, () => {
|
||||
const foundPlayer: MprisPlayer = getPlayerInfo();
|
||||
const foundPlayer = getPlayerInfo();
|
||||
|
||||
if (foundPlayer === undefined) {
|
||||
self.icon = icons.mpris.loop['none'];
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const media = await Service.import('mpris');
|
||||
import { getPlayerInfo } from '../../helpers';
|
||||
import { MprisPlayer } from 'types/service/mpris';
|
||||
import { isValidPlaybackStatus } from './helpers';
|
||||
import Button from 'types/widgets/button';
|
||||
import Icon from 'types/widgets/icon';
|
||||
@@ -26,10 +25,12 @@ export const playPause = (): Button<Icon<Attribute>, Attribute> => {
|
||||
},
|
||||
child: Widget.Icon({
|
||||
icon: Utils.watch(icons.mpris.paused, media, 'changed', () => {
|
||||
const foundPlayer: MprisPlayer = getPlayerInfo();
|
||||
const foundPlayer = getPlayerInfo();
|
||||
|
||||
if (foundPlayer === undefined) {
|
||||
return icons.mpris['paused'];
|
||||
}
|
||||
|
||||
const playbackStatus = foundPlayer.play_back_status?.toLowerCase();
|
||||
|
||||
if (playbackStatus && isValidPlaybackStatus(playbackStatus)) {
|
||||
|
||||
@@ -46,6 +46,9 @@ export const initializeActivePlayerHook = (): void => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getPlayerInfo = (): MprisPlayer => {
|
||||
export const getPlayerInfo = (): MprisPlayer | undefined => {
|
||||
if (media.players.length === 0) {
|
||||
return;
|
||||
}
|
||||
return media.players.find((p) => p.bus_name === curPlayer.value) || media.players[0];
|
||||
};
|
||||
|
||||
@@ -2,7 +2,13 @@ import { Attribute } from 'lib/types/widget';
|
||||
import { MprisPlayer } from 'types/service/mpris';
|
||||
import Slider from 'types/widgets/slider';
|
||||
|
||||
export const updateTooltip = (self: Slider<Attribute>, foundPlayer: MprisPlayer): void => {
|
||||
/**
|
||||
* Updates the tooltip text of the slider based on the player's current position.
|
||||
*
|
||||
* @param self - The slider component to update.
|
||||
* @param foundPlayer - The MPRIS player object, if available.
|
||||
*/
|
||||
export const updateTooltip = (self: Slider<Attribute>, foundPlayer?: MprisPlayer): void => {
|
||||
if (foundPlayer === undefined) {
|
||||
self.tooltip_text = '00:00';
|
||||
return;
|
||||
@@ -29,7 +35,13 @@ export const updateTooltip = (self: Slider<Attribute>, foundPlayer: MprisPlayer)
|
||||
}
|
||||
};
|
||||
|
||||
export const update = (self: Slider<Attribute>, foundPlayer: MprisPlayer): void => {
|
||||
/**
|
||||
* Updates the value of the slider based on the player's current position and length.
|
||||
*
|
||||
* @param self - The slider component to update.
|
||||
* @param foundPlayer - The MPRIS player object, if available.
|
||||
*/
|
||||
export const update = (self: Slider<Attribute>, foundPlayer?: MprisPlayer): void => {
|
||||
if (foundPlayer !== undefined) {
|
||||
const value = foundPlayer.length ? foundPlayer.position / foundPlayer.length : 0;
|
||||
self.value = value > 0 ? value : 0;
|
||||
|
||||
Reference in New Issue
Block a user