use std::ffi::CStr;
use std::io::Result;
-use cocoa::{base::{nil, id}, foundation::NSString};
-use objc::{class, msg_send, sel, sel_impl, runtime::{Class, Object}};
+use cocoa::{
+ base::{id, nil},
+ foundation::NSString,
+};
+use objc::{
+ class, msg_send,
+ runtime::{Class, Object},
+ sel, sel_impl,
+};
use objc_id::Id;
use crate::Track;
}
impl LyricsSource for Spotify {
-
fn name(&self) -> String {
"spotify".to_string()
}
unsafe {
let app: Id<Object> = {
let cls = class!(SBApplication);
- let bundle_identifier = NSString::alloc(nil).init_str("com.spotify.Client");
+ let bundle_identifier = NSString::alloc(nil).init_str("com.spotify.Client");
let workspace_class = Class::get("NSWorkspace").unwrap();
let shared_workspace: id = msg_send![workspace_class, sharedWorkspace];
let app_url: id = msg_send![shared_workspace, URLForApplicationWithBundleIdentifier:bundle_identifier];
if app_url != nil {
- let app: *mut Object = msg_send![cls, applicationWithBundleIdentifier:bundle_identifier];
+ let app: *mut Object =
+ msg_send![cls, applicationWithBundleIdentifier:bundle_identifier];
Id::from_ptr(app)
} else {
- return None
+ return None;
}
};
let name = CStr::from_ptr(name_ptr).to_string_lossy().into_owned();
let artist = CStr::from_ptr(artist_ptr).to_string_lossy().into_owned();
-
- return Some(Track {
- name,
- artist
- })
+ return Some(Track { name, artist });
}
}
}