From 07d294425a98ee5d1e22d03e2b24ae2c76e487c0 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sat, 23 Aug 2025 12:42:37 +0900 Subject: updates --- .../plugins/music/Get-Artwork.applescript | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 mac/.config/sketchybar.mon/plugins/music/Get-Artwork.applescript (limited to 'mac/.config/sketchybar.mon/plugins/music/Get-Artwork.applescript') diff --git a/mac/.config/sketchybar.mon/plugins/music/Get-Artwork.applescript b/mac/.config/sketchybar.mon/plugins/music/Get-Artwork.applescript new file mode 100644 index 0000000..ca3ee31 --- /dev/null +++ b/mac/.config/sketchybar.mon/plugins/music/Get-Artwork.applescript @@ -0,0 +1,65 @@ +--get current path +tell application "Finder" to set current_path to container of (path to me) as alias + +--get artwork +tell application "Music" + try + if player state is not stopped then + set alb to (get album of current track) + tell artwork 1 of current track + if format is JPEG picture then + set imgFormat to ".jpg" + else + set imgFormat to ".png" + end if + end tell + set rawData to (get raw data of artwork 1 of current track) + else + return + end if + on error + return POSIX path of ((current_path as text) & "Cover-Default.png") + return + end try +end tell + +--create path to save image as jpg or png +set newPath to ((current_path as text) & "tmp" & imgFormat) as text + +try + --create file + tell me to set fileRef to (open for access newPath with write permission) + --overwrite existing file + write rawData to fileRef starting at 0 + tell me to close access fileRef + + delay 1 + + --resize image + set the target_length to 500 + try + tell application "Image Events" + -- start the Image Events application + launch + -- open the image file + set this_image to open newPath + -- perform action + scale this_image to size target_length + -- save the changes + save this_image with icon + -- purge the open image data + close this_image + end tell + on error + return POSIX path of ((current_path as text) & "Cover-Default.png") + end try + + return POSIX path of newPath +on error m number n + log n + log m + try + tell me to close access fileRef + end try + return ((current_path as text) & "Cover-Default.png") as text +end try \ No newline at end of file -- cgit v1.2.3