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

NSPasteboard#generalPasteboard returned null when called from macOS launchd Launch Daemon #79

Open
windy1 opened this issue Oct 19, 2020 · 1 comment

Comments

@windy1
Copy link

windy1 commented Oct 19, 2020

Hi, so I'm not entirely sure if this is an issue with the library; I suspect it's more of a side-effect, but when acquiring a ClipboardContext on macOS from a launchd process like

let mut clipboard: ClipboardContext = ClipboardProvider::new().unwrap();

my program panics with the error NSPasteboard#generalPasteboard returned null. The program works OK when I execute it directly.

I am using the following daemon descriptor:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>myprogram</string>
    <key>EnvironmentVariables</key>
    <dict>
        <key>RUST_LOG</key>
        <string>debug</string>
        <key>RUST_BACKTRACE</key>
        <string>1</string>
    </dict>
    <key>ProgramArguments</key>
    <array>
        <string>$HOME/.cargo/bin/myprogram</string>
    </array>
    <key>UserName</key>
    <string>$USER</string>
    <key>StandardOutPath</key>
    <string>$HOME/.myprogram/myprogram.log</string>
    <key>StandardErrorPath</key>
    <string>$HOME/.myprogram/myprogram.log</string>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

Apologies if this isn't strictly related to this library. Any insight would be greatly appreciated!

@qkdreyer
Copy link

you should use launchctl asuser USER_ID where USER_ID can be id -u (i.e. 501 for default user)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants