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

does not work when called from a launchagent #58

Closed
jaltonen opened this issue Jul 1, 2016 · 6 comments
Closed

does not work when called from a launchagent #58

jaltonen opened this issue Jul 1, 2016 · 6 comments

Comments

@jaltonen
Copy link

jaltonen commented Jul 1, 2016

I feel like I used dockutil in agents in the 10.9 days. Went to use from an agent with 2.0.2 and 10.11 and could not get it to work. Upgraded to 2.0.3 still not working. Tried umpteen variations of how to identify the currently logged in user in the script, never could get it to work. During troubleshooting i figured out i could get the dockutil statement to work in a LaunchAgent if i assigned the statement to a variable

this does not work
/usr/local/bin/dockutil --add /Users/$USER/Downloads --display folder --section others

for reasons i don't understand this does work

doit=/usr/local/bin/dockutil --add /Users/$USER/Downloads --display folder --section others

@jaltonen
Copy link
Author

jaltonen commented Jul 1, 2016

damn, it sure was hard to get the back ticks to show up in the comment field

@kcrawford
Copy link
Owner

Could you show the whole launch agent and script (if using a script).

@jaltonen
Copy link
Author

jaltonen commented Jul 5, 2016

AGENT:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"

      "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

   <key>Label</key>

   <string>edu.vcu.sota.dockfixer</string>

   <key>ProgramArguments</key>

   <array>

      <string>/Library/Scripts/dockfixer.sh</string>

   </array>

   <key>RunAtLoad</key>

   <true/>

</dict>


</plist>

SCRIPT:

#!/bin/bash

doit=``/usr/local/bin/dockutil --add /Users/$USER/Downloads --display folder --section others

exit 0

@kcrawford
Copy link
Owner

Yeah I don't understand why the backticks would make a difference unless $USER isn't set except in subshells, but that seems odd.

You could log $USER or the whole command.

And turn on verbose and log the output of dockutil.

Another workaround would be to use ~/Downloads.

Kyle

Sent from Mobile

On Jul 5, 2016, at 8:42 AM, JohnAltonen notifications@github.com wrote:

AGENT:

Label
edu.vcu.sota.dockfixer
ProgramArguments

/Library/Scripts/dockfixer.sh

RunAtLoad

SCRIPT:

#!/bin/bash
doit=/usr/local/bin/dockutil --add /Users/$USER/Downloads --display folder --section others
exit 0


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@jaltonen
Copy link
Author

jaltonen commented Jul 5, 2016

tried all that, logging $USER, current_user=$(stat -f '%Su' /dev/console), using ~/Downloads, no worky. Is it just me ? This is working for others ? Trigger with an agent, agent/script ?

Its working with the backticks so i'll go with that.

@kcrawford
Copy link
Owner

This is a shell script issue and backticks or the equivalent are needed if executed this way. Closing this while doing housekeeping of issues.

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