Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test this on macOS #2

Open
Rodrigodd opened this issue Feb 3, 2024 · 5 comments
Open

Test this on macOS #2

Rodrigodd opened this issue Feb 3, 2024 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@Rodrigodd
Copy link
Owner

I don't have a macOS to test this on, so I cannot ensure that this is working there. But as far as I know, All crates used support macOS.

@Rodrigodd Rodrigodd added the help wanted Extra attention is needed label Feb 3, 2024
@anna-hope
Copy link

anna-hope commented Feb 5, 2024

Hi! I tried to build this on MacOS (Sonoma 14.3, rust 1.75.0):

  • First, you need to install LLVM (brew install llvm, and then echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc)

But then, running cargo build -p attractor-egui --release, I get this error:

Compiling wallpaper v4.0.0 (https://github.com/Rodrigodd/wallpaper.rs.git?rev=5733320aca9349bcf06c727250dac5ec6c6b5f42#5733320a)
error[E0412]: cannot find type `Path` in this scope
  --> /Users/annahope/.cargo/git/checkouts/wallpaper.rs-85390b1710a6df7f/5733320/src/macos.rs:20:14
   |
20 |     P: AsRef<Path> + std::fmt::Display,
   |              ^^^^ not found in this scope
   |
help: consider importing this struct
   |
1  + use std::path::Path;
   |

Looks like this file needs to import std::path::Path.

@jacobbarssbailey
Copy link

It seems like wallpaper.rs has a few issues on OS X. Apologies for the raw diff, but here's a quick and dirty set of changes to what I did to get it to build with 1.76.0-nightly (after installing LLVM).

index c94ce0a..ad2442d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,6 +14,7 @@ license = "Unlicense"
 dirs = { version = "1", optional = true }
 thiserror = "1"
 reqwest = { version = "0.11", optional = true, features = ["blocking"] }
+rust-ini = "0.12"

 [target.'cfg(unix)'.dependencies]
 enquote = "1"
diff --git a/src/macos.rs b/src/macos.rs
index 06f74b5..ed85584 100644
--- a/src/macos.rs
+++ b/src/macos.rs
@@ -1,4 +1,5 @@
-use crate::{get_stdout, run, Mode, Result};
+use crate::{get_stdout, run, Result};
+use std::path::Path;

 #[cfg(feature = "from_url")]
 use crate::download_image;
@@ -19,13 +20,14 @@ pub fn set_from_path<P>(path: P) -> Result<()>
 where
     P: AsRef<Path> + std::fmt::Display,
 {
+    let path_str = path.to_string(); // Convert path to a string
     run(
         "osascript",
         &[
             "-e",
             &format!(
                 r#"tell application "System Events" to tell every desktop to set picture to {}"#,
-                enquote::enquote('"', path),
+                enquote::enquote('"', &path_str),
             ),
         ],
     )
@@ -38,7 +40,3 @@ pub fn set_from_url(url: &str) -> Result<()> {
     set_from_path(&path)
 }

-/// No-op. Unable to change with AppleScript.
-pub fn set_mode(_: Mode) -> Result<()> {
-    Err("unsupported on macos".into())
-}```

@jacobbarssbailey
Copy link

It seems like it's not doing great with my Macbook Pro's high dpi display. Looks to be half-sized, and the Configuration controls appear to be relative to the window (vs. the actual mouse position). I've never used egui, will have to leave this to somebody else to try and fix.

image

@jacobbarssbailey
Copy link

All that said, everything does build and work, nice work!

@Rodrigodd
Copy link
Owner Author

Thanks @anna-hope and @jacobbarssbailey for testing it out!

In #7, I added a GitHub action that builds the project on macOS, and I think it is working now. If this was the only problem, I will close this issue.

@jacobbarssbailey, there appears to be a problem with handling DPI scaling (I don't remember if I am handling it at all). I will create another issue about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants