macos support
This commit is contained in:
20
main.js
20
main.js
@@ -7,6 +7,18 @@ let win;
|
||||
let lastSong = "";
|
||||
let lastPaused = true;
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
getMediaCommand = 'powershell -ExecutionPolicy Bypass -File get-media.ps1';
|
||||
mediaControlCommand = 'MediaControl.exe';
|
||||
} else if (process.platform === 'darwin') {
|
||||
getMediaCommand = './get-media.sh'; // Adjust this path/command to your macOS script
|
||||
mediaControlCommand = 'osascript MediaControl.scpt';
|
||||
} else {
|
||||
console.error("Unsupported OS");
|
||||
resolve({ updated: false });
|
||||
return;
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
checkNowPlaying();
|
||||
@@ -52,7 +64,7 @@ async function checkNowPlaying() {
|
||||
|
||||
function checkOwnSong() {
|
||||
return new Promise((resolve) => {
|
||||
exec(`powershell -ExecutionPolicy Bypass -File get-media.ps1`, async (error, stdout) => {
|
||||
exec(getMediaCommand, async (error, stdout) => {
|
||||
if (error) {
|
||||
console.error("PowerShell error:", error);
|
||||
resolve({ updated: false });
|
||||
@@ -139,7 +151,7 @@ function fetchAlbumArt(title, artist) {
|
||||
|
||||
ipcMain.on('media-control', (event, command) => {
|
||||
if (command) {
|
||||
exec(`MediaControl.exe ${command}`, (error, stdout, stderr) => {
|
||||
exec(`${mediaControlCommand} ${command}`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`Error running MediaControl.exe:`, error);
|
||||
} else {
|
||||
@@ -398,10 +410,10 @@ function getMainPageHTML() {
|
||||
|
||||
if (data.paused) {
|
||||
// Player is paused => show "Play" button
|
||||
playPauseButton.textContent = "▶️";
|
||||
playPauseButton.textContent = "⏵︎";
|
||||
} else {
|
||||
// Player is playing => show "Pause" button and update track info
|
||||
playPauseButton.textContent = "⏸️";
|
||||
playPauseButton.textContent = "⏸︎";
|
||||
|
||||
songTitleElem.innerText = data.title ?? "Unknown Title";
|
||||
songArtistElem.innerText = data.artist ?? "Unknown Artist";
|
||||
|
||||
Reference in New Issue
Block a user