Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vdesabou authored Dec 4, 2024
1 parent 1988f9e commit da7e5d9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion spotify-mini-player/src/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ function main($query, $type, $add_to_option)
playTrackInContextWithMopidy($w, $track_uri, $playlist_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$track_uri\" in context \"$playlist_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand All @@ -207,6 +208,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidyWithoutClearing($w, $track_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$track_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand All @@ -232,6 +234,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidy($w, $playlist_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$playlist_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand Down Expand Up @@ -271,6 +274,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidy($w, $album_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$album_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand Down Expand Up @@ -383,6 +387,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidy($w, $artist_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$artist_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand Down Expand Up @@ -909,6 +914,7 @@ function main($query, $type, $add_to_option)
playTrackInContextWithMopidy($w, $track_uri, $album_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$track_uri\" in context \"$album_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand All @@ -931,6 +937,7 @@ function main($query, $type, $add_to_option)
playTrackInContextWithMopidy($w, $track_uri, $album_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$track_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand All @@ -951,6 +958,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidy($w, $track_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$track_uri\"");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand Down Expand Up @@ -1008,6 +1016,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidyWithoutClearing($w, $track_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$track_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand Down Expand Up @@ -1408,6 +1417,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidyWithoutClearing($w, $track_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$track_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand All @@ -1426,6 +1436,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidy($w, $album_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$album_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand Down Expand Up @@ -1491,6 +1502,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidy($w, $artist_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$artist_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand Down Expand Up @@ -1524,6 +1536,7 @@ function main($query, $type, $add_to_option)
playUriWithMopidy($w, $album_uri);
} else if($output_application == 'APPLESCRIPT') {
exec("osascript -e 'tell application \"Spotify\" to play track \"$album_uri\"'");
exec("osascript -e 'tell application id \"com.apple.systemevents\" to tell process \"Spotify\" to tell its windows to click value of attribute \"AXCloseButton\"'");
} else {
$device_id = getSpotifyConnectCurrentDeviceId($w);
if($device_id != '') {
Expand Down Expand Up @@ -1930,4 +1943,4 @@ function main($query, $type, $add_to_option)
return;
}
}
}
}

0 comments on commit da7e5d9

Please sign in to comment.