Make media label togglable (#122)
* make it possible to truncate media title to 0 * undo oopsie * apply @painerp change * make the label togglable * Update widget/settings/pages/config/bar/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update modules/bar/media/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update modules/bar/media/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> * Update modules/bar/media/index.ts Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com> --------- Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import { openMenu } from "../utils.js";
|
||||
import options from "options";
|
||||
import { getCurrentPlayer } from 'lib/shared/media.js';
|
||||
|
||||
const { show_artist, truncation, truncation_size } = options.bar.media;
|
||||
const { show_artist, truncation, truncation_size, show_label } = options.bar.media;
|
||||
|
||||
const Media = () => {
|
||||
const activePlayer = Variable(mpris.players[0]);
|
||||
@@ -33,8 +33,8 @@ const Media = () => {
|
||||
|
||||
const songIcon = Variable("");
|
||||
|
||||
const mediaLabel = Utils.watch(" Media ", [mpris, show_artist, truncation, truncation_size], () => {
|
||||
if (activePlayer.value) {
|
||||
const mediaLabel = Utils.watch("Media", [mpris, show_artist, truncation, truncation_size, show_label], () => {
|
||||
if (activePlayer.value && show_label.value) {
|
||||
const { track_title, identity, track_artists } = activePlayer.value;
|
||||
songIcon.value = getIconForPlayer(identity);
|
||||
const trackArtist = show_artist.value
|
||||
@@ -50,8 +50,8 @@ const Media = () => {
|
||||
? `${truncatedLabel}`
|
||||
: `${truncatedLabel.substring(0, truncatedLabel.length - 3)}...`;
|
||||
} else {
|
||||
songIcon.value = "";
|
||||
return " Media ";
|
||||
songIcon.value = getIconForPlayer(activePlayer.value?.identity || "");
|
||||
return `Media`;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ const Media = () => {
|
||||
children: [
|
||||
Widget.Label({
|
||||
class_name: "bar-button-icon media",
|
||||
label: songIcon.bind("value"),
|
||||
label: songIcon.bind("value").as(v => v || ""),
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: "bar-button-label media",
|
||||
|
||||
@@ -697,6 +697,7 @@ const options = mkOptions(OPTIONS, {
|
||||
media: {
|
||||
show_artist: opt(false),
|
||||
truncation: opt(true),
|
||||
show_label: opt(true),
|
||||
truncation_size: opt(30)
|
||||
},
|
||||
notifications: {
|
||||
|
||||
@@ -73,8 +73,9 @@ export const BarSettings = () => {
|
||||
Header('Media'),
|
||||
Option({ opt: options.theme.bar.buttons.media.spacing, title: 'Inner Spacing', subtitle: 'Spacing between the icon and the label inside the buttons.', type: 'string' }),
|
||||
Option({ opt: options.bar.media.show_artist, title: 'Show Track Artist', type: 'boolean' }),
|
||||
Option({ opt: options.bar.media.truncation, title: 'Truncate Media Label', type: 'boolean' }),
|
||||
Option({ opt: options.bar.media.truncation_size, title: 'Truncation Size', type: 'number', min: 10 }),
|
||||
Option({ opt: options.bar.media.show_label, title: 'Toggle Media Label', type: 'boolean' }),
|
||||
Option({ opt: options.bar.media.truncation, title: 'Truncate Media Label', subtitle: 'Only applicable if Toggle Media Label is enabled', type: 'boolean' }),
|
||||
Option({ opt: options.bar.media.truncation_size, title: 'Truncation Size', subtitle: 'Only applicable if Toggle Media Label is enabled', type: 'number', min: 10 }),
|
||||
|
||||
Header('Notifications'),
|
||||
Option({ opt: options.bar.notifications.show_total, title: 'Show Total # of notifications', type: 'boolean' }),
|
||||
@@ -82,4 +83,4 @@ export const BarSettings = () => {
|
||||
]
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user