]> git.r.bdr.sh - rbdr/lyricli/commitdiff
Add mac command
authorRuben Beltran del Rio <redacted>
Sat, 16 Mar 2024 16:08:52 +0000 (17:08 +0100)
committerRuben Beltran del Rio <redacted>
Sat, 16 Mar 2024 16:08:52 +0000 (17:08 +0100)
.gitignore
Makefile
src/sources/apple_music.rs
src/sources/spotify.rs

index 5bfe83902ab0f962becfb9c90aca8534d9f90c94..c58380d003b05d97615fa24d9beeff1f63b45300 100644 (file)
@@ -6,3 +6,5 @@ docs
 .env
 target
 distribution
 .env
 target
 distribution
+*.tar.gz
+*.tar.gz.sha256
index 61dc355d097bc67c502fa84b2f2008c9e1bcb555..e2c1648d4ef77a21e333ea81ca19d3f1d5a9f524 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@ profile := dev
 target = $(shell rustc -vV | grep host | awk '{print $$2}')
 architectures := x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
 app_name := lrc
 target = $(shell rustc -vV | grep host | awk '{print $$2}')
 architectures := x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu
 app_name := lrc
+long_app_name := lyricli
 
 default: build
 
 
 default: build
 
@@ -25,30 +26,43 @@ else
 endif
 
 deb: build
 endif
 
 deb: build
+ifeq ($(findstring linux,$(target)),linux)
        @$(eval filename := $(app_name)-$(target)-$(channel))
        @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo deb --profile $(profile) --target $(target)
        mv target/$(target)/debian/*.deb $(filename).deb
        sha256sum $(filename).deb > $(filename).deb.sha256
        @$(eval filename := $(app_name)-$(target)-$(channel))
        @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo deb --profile $(profile) --target $(target)
        mv target/$(target)/debian/*.deb $(filename).deb
        sha256sum $(filename).deb > $(filename).deb.sha256
-       rsync -avz $(filename).deb deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
-       rsync -avz $(filename).deb.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
+       rsync -avz $(filename).deb deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name)
+       rsync -avz $(filename).deb.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name)
+endif
 
 rpm: build
 
 rpm: build
+ifeq ($(findstring linux,$(target)),linux)
        @$(eval filename := $(app_name)-$(target)-$(channel))
        @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo generate-rpm --profile $(profile) --target $(target)
        mv target/$(target)/generate-rpm/*.rpm $(filename).rpm
        sha256sum $(filename).rpm > $(filename).rpm.sha256
        @$(eval filename := $(app_name)-$(target)-$(channel))
        @export $$(cat .env | xargs) > /dev/null 2>&1 && cargo generate-rpm --profile $(profile) --target $(target)
        mv target/$(target)/generate-rpm/*.rpm $(filename).rpm
        sha256sum $(filename).rpm > $(filename).rpm.sha256
-       rsync -avz $(filename).rpm deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
-       rsync -avz $(filename).rpm.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
+       rsync -avz $(filename).rpm deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name)
+       rsync -avz $(filename).rpm.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name)
+endif
 
 tar: build
        @$(eval filename := $(app_name)-$(target)-$(channel))
        tar -czvf $(filename).tar.gz -C target/$(target)/$(profile)/ $(app_name)
        sha256sum $(filename).tar.gz > $(filename).tar.gz.sha256
 
 tar: build
        @$(eval filename := $(app_name)-$(target)-$(channel))
        tar -czvf $(filename).tar.gz -C target/$(target)/$(profile)/ $(app_name)
        sha256sum $(filename).tar.gz > $(filename).tar.gz.sha256
-       rsync -avz $(filename).tar.gz deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
-       rsync -avz $(filename).tar.gz.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(app_name)
+       rsync -avz $(filename).tar.gz deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name)
+       rsync -avz $(filename).tar.gz.sha256 deploy@conchos.unlimited.pizza:/srv/http/build.r.bdr.sh/$(long_app_name)
 
 package: $(architectures)
 
 
 package: $(architectures)
 
+mac:
+override architectures := x86_64-apple-darwin aarch64-apple-darwin
+ifeq ($(tag),)
+       $(MAKE) -e profile=release -e architectures='$(architectures)' -e channel=unstable package
+else
+       $(MAKE) -e profile=release -e architectures='$(architectures)' -e channel=$(tag) package
+endif
+
+
 ci:
 ifeq ($(GIT_REF),refs/heads/main)
        $(MAKE) -e profile=release -e channel=unstable package
 ci:
 ifeq ($(GIT_REF),refs/heads/main)
        $(MAKE) -e profile=release -e channel=unstable package
index cb36f5c4d2fa980be4820c0980132e2ee4c28f29..06412b88a02a7cbf114c9f746c17eb678b94cafb 100644 (file)
@@ -1,8 +1,8 @@
 use std::ffi::CStr;
 use std::io::Result;
 
 use std::ffi::CStr;
 use std::io::Result;
 
-use cocoa::{base::nil, foundation::NSString};
-use objc::{class, msg_send, sel, sel_impl, runtime::Object};
+use cocoa::{base::{nil, id}, foundation::NSString};
+use objc::{class, msg_send, sel, sel_impl, runtime::{Class, Object}};
 use objc_id::Id;
 
 use crate::Track;
 use objc_id::Id;
 
 use crate::Track;
@@ -28,8 +28,17 @@ impl LyricsSource for AppleMusic {
             let app: Id<Object> = {
                 let cls = class!(SBApplication);
                 let bundle_identifier = NSString::alloc(nil).init_str("com.apple.Music"); 
             let app: Id<Object> = {
                 let cls = class!(SBApplication);
                 let bundle_identifier = NSString::alloc(nil).init_str("com.apple.Music"); 
-                let app: *mut Object = msg_send![cls, applicationWithBundleIdentifier:bundle_identifier];
-                Id::from_ptr(app)
+
+                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];
+                    Id::from_ptr(app)
+                } else {
+                    return None
+                }
             };
 
             if msg_send![app, isRunning] {
             };
 
             if msg_send![app, isRunning] {
index b23ea736150a05b490c9df3df55eb24c03bf979c..e4bf19ce687ba42b2c6ffc99153b573a8933f773 100644 (file)
@@ -1,8 +1,8 @@
 use std::ffi::CStr;
 use std::io::Result;
 
 use std::ffi::CStr;
 use std::io::Result;
 
-use cocoa::{base::nil, foundation::NSString};
-use objc::{class, msg_send, sel, sel_impl, runtime::Object};
+use cocoa::{base::{nil, id}, foundation::NSString};
+use objc::{class, msg_send, sel, sel_impl, runtime::{Class, Object}};
 use objc_id::Id;
 
 use crate::Track;
 use objc_id::Id;
 
 use crate::Track;
@@ -28,8 +28,17 @@ impl LyricsSource for Spotify {
             let app: Id<Object> = {
                 let cls = class!(SBApplication);
                 let bundle_identifier = NSString::alloc(nil).init_str("com.spotify.Client"); 
             let app: Id<Object> = {
                 let cls = class!(SBApplication);
                 let bundle_identifier = NSString::alloc(nil).init_str("com.spotify.Client"); 
-                let app: *mut Object = msg_send![cls, applicationWithBundleIdentifier:bundle_identifier];
-                Id::from_ptr(app)
+
+                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];
+                    Id::from_ptr(app)
+                } else {
+                    return None
+                }
             };
 
             if msg_send![app, isRunning] {
             };
 
             if msg_send![app, isRunning] {