Open Tinosaurus opened 3 years ago
Spotify is not supported on Windows.
See https://github.com/dylanaraps/neofetch/blob/0ce03cfd7e0899297403fbbb1f8db26a2c76dc4d/neofetch#L2928
I don't know, if possible, how to get the song info from spotify on Windows.
Is dbus
available on WSL?
https://www.freedesktop.org/wiki/Software/dbus/#Windowsport according to this link,
"The Windows port from the windbus and dbus4win projects was merged into the freedesktop dbus development branch several years ago, and is released as part of dbus. Thanks to all the past and current contributors to that port.
It is known that the Windows port runs on Windows Vista, 8, 10 and server variants. Supported compilers/SDK are MSVC, mingw-w32/w64(gcc) and cygwin(gcc)."
So dbus might be ported to windows, but not sure on how well it would work, since ive never used it.
You could try to install dbus and change
"Linux") get_song_dbus "spotify" ;;
to
"Linux" | "Windows") get_song_dbus "spotify" ;;
That's the only idea I have.
You could use Microsoft.Windows.SDK.Contracts and Windows.Media.Control to get it tho I had to build an application with net to be able to do so
Here's the application if you don't want to build it yourself https://ongezell.com/software/musicidentifier/musicprofilerv1.7z https://www.virustotal.com/gui/url/fe785dbd68e54fcb6d9bfcf321e6f6cc3e9218d8c754cbe59261da2b5e7eae96 extract it somewhere, I extracted where the .conf for neofetch is located
just put this into your .conf file
songTitle=$(cd "C:\Users\user\.config\neofetch\musicprofiler"; ./musicprofiler.bat)
prin "$(color 14)Song: $songTitle"
Enjoy
you could always build yourself too, here's the code for it:
Program.cs
using System;
using System.Text;
using System.Threading.Tasks;
using Windows.Media.Control;
namespace TestGetCurrentMedia
{
internal class Program
{
public static async Task Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
var gsmtcsm = await GetSystemMediaTransportControlsSessionManager();
Gsmtcsm_CurrentSessionChanged(gsmtcsm, null);
gsmtcsm.CurrentSessionChanged += Gsmtcsm_CurrentSessionChanged;
Console.ReadLine();
}
static string LastString = "";
private static async void Gsmtcsm_CurrentSessionChanged(GlobalSystemMediaTransportControlsSessionManager sender, CurrentSessionChangedEventArgs args)
{
var s = sender.GetCurrentSession();
if (s != null)
{
s.MediaPropertiesChanged += S_MediaPropertiesChanged;
S_MediaPropertiesChanged(s, null);
s.PlaybackInfoChanged += S_PlaybackInfoChanged;
S_PlaybackInfoChanged(s, null);
}
//GC.Collect();
}
private static void S_PlaybackInfoChanged(GlobalSystemMediaTransportControlsSession sender, PlaybackInfoChangedEventArgs args)
{
GlobalSystemMediaTransportControlsSessionPlaybackInfo playbackInfo = sender.GetPlaybackInfo();
Console.WriteLine(LastString);
Environment.Exit(0); //removing this line will make it constantly fetch the song playing
//Console.WriteLine(LastString + " = " + playbackInfo.PlaybackStatus);
}
private static async void S_MediaPropertiesChanged(GlobalSystemMediaTransportControlsSession sender, MediaPropertiesChangedEventArgs args)
{
GlobalSystemMediaTransportControlsSessionMediaProperties mediaProperties = await sender.TryGetMediaPropertiesAsync();
if (mediaProperties != null)
{
string Curr = ($"{mediaProperties.Artist} - {mediaProperties.Title}");
//string Curr = ($"{mediaProperties.Artist} - {mediaProperties.Title} - {mediaProperties.TrackNumber}");
if (!Curr.Equals(LastString))
{
//Console.WriteLine(Curr);
LastString = Curr;
S_PlaybackInfoChanged(sender, null);
}
}
}
private static async Task<GlobalSystemMediaTransportControlsSessionManager> GetSystemMediaTransportControlsSessionManager() =>
await GlobalSystemMediaTransportControlsSessionManager.RequestAsync();
}
}
yourproject.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-windows10.0.17763.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
Description
Song command always shows unknown artist, album and song. Tested with VLC and Spotify.
If theres smth wrong with the report, please let me know and ill try to provide if you need smth
Neofetch version
7.1.0
Screenshot
Config file
Verbose log
https://pastebin.com/ng2eJDyv