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:
orangc
2024-08-15 04:18:13 +03:00
committed by GitHub
parent ea2ebc5c4b
commit 250443de63
3 changed files with 11 additions and 9 deletions

View File

@@ -4,7 +4,7 @@ import { openMenu } from "../utils.js";
import options from "options"; import options from "options";
import { getCurrentPlayer } from 'lib/shared/media.js'; 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 Media = () => {
const activePlayer = Variable(mpris.players[0]); const activePlayer = Variable(mpris.players[0]);
@@ -33,8 +33,8 @@ const Media = () => {
const songIcon = Variable(""); const songIcon = Variable("");
const mediaLabel = Utils.watch("󰎇 Media 󰎇", [mpris, show_artist, truncation, truncation_size], () => { const mediaLabel = Utils.watch("Media", [mpris, show_artist, truncation, truncation_size, show_label], () => {
if (activePlayer.value) { if (activePlayer.value && show_label.value) {
const { track_title, identity, track_artists } = activePlayer.value; const { track_title, identity, track_artists } = activePlayer.value;
songIcon.value = getIconForPlayer(identity); songIcon.value = getIconForPlayer(identity);
const trackArtist = show_artist.value const trackArtist = show_artist.value
@@ -50,8 +50,8 @@ const Media = () => {
? `${truncatedLabel}` ? `${truncatedLabel}`
: `${truncatedLabel.substring(0, truncatedLabel.length - 3)}...`; : `${truncatedLabel.substring(0, truncatedLabel.length - 3)}...`;
} else { } else {
songIcon.value = ""; songIcon.value = getIconForPlayer(activePlayer.value?.identity || "");
return "󰎇 Media 󰎇"; return `Media`;
} }
}); });
@@ -64,7 +64,7 @@ const Media = () => {
children: [ children: [
Widget.Label({ Widget.Label({
class_name: "bar-button-icon media", class_name: "bar-button-icon media",
label: songIcon.bind("value"), label: songIcon.bind("value").as(v => v || "󰝚"),
}), }),
Widget.Label({ Widget.Label({
class_name: "bar-button-label media", class_name: "bar-button-label media",

View File

@@ -697,6 +697,7 @@ const options = mkOptions(OPTIONS, {
media: { media: {
show_artist: opt(false), show_artist: opt(false),
truncation: opt(true), truncation: opt(true),
show_label: opt(true),
truncation_size: opt(30) truncation_size: opt(30)
}, },
notifications: { notifications: {

View File

@@ -73,8 +73,9 @@ export const BarSettings = () => {
Header('Media'), 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.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.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.show_label, title: 'Toggle Media Label', type: 'boolean' }),
Option({ opt: options.bar.media.truncation_size, title: 'Truncation Size', type: 'number', min: 10 }), 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'), Header('Notifications'),
Option({ opt: options.bar.notifications.show_total, title: 'Show Total # of notifications', type: 'boolean' }), Option({ opt: options.bar.notifications.show_total, title: 'Show Total # of notifications', type: 'boolean' }),