Cargo-app crate and screen recording permission in macOS

I often find myself emailing myself screenshots of random memes or other things on the web. :wink:
I figured I might as well make a small rust app on macos with the cargo-app crate (https://crates.io/crates/cargo-app). However, when I run the program to take a screenshot, my computer will ask: "Screenshot tool would like to record this computer's screen. Grant access to this application in Security and Privacy settings." So naturally, I go to the security panel in settings, and check the box for allowing screen recording under the name of my application. But when I go to run the program again, the same message is displayed and I can't take a screenshot. Is this a problem with how I am using cargo-app or the gtk-rs crate for the gui? Or is there perhapse a field missing in the toml for [package.metadata.app]?

here is my code for the app:

mod r;
fn main() {

   let application = Application::new(
       Some("com.yee"),
       Default::default(),
   ).expect("failed to initialize GTK application");

   application.connect_activate(|app| {
       let window = ApplicationWindow::new(app);
       window.set_title("Screenshot tool");
       window.set_default_size(350, 70);

       let button = Button::new_with_label("Click me!");
       button.connect_clicked(|_| {

                r::screenshot();
                r::sendmail("screenshot taken");
            
            }
       });
       window.add(&button);

       window.show_all();
   });

   application.run(&[]);
}

here is the file r.rs (excluding the code that doesn't need to be known for this question):

pub fn screenshot() {
    //stuff to take screenshot
}

pub fn sendmail() {
    //stuff to send mail
}

and here is the toml:

[package.metadata.app]

out = "screenshottool.app"

bin = "/Users/xxxxxxx/Library/Mobile Documents/com~apple~CloudDocs/Rust_projects    /screenshottool/target/debug/screenshottoo,"

display_name = "antivirus"

icon = "icon.icns"

[dependencies.gtk]

version = "0.8.0"

features = ["v3_16"]

[dependencies.gio]

version = "0.8.0"

features = ["v2_44"]

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.