kcrawford / dockutil

command line tool for managing dock items
http://patternbuffer.wordpress.com
Apache License 2.0
1.38k stars 131 forks source link

does not work when called from a launchagent #58

Closed jaltonen closed 2 years ago

jaltonen commented 8 years ago

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 commented 8 years ago

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

kcrawford commented 8 years ago

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

jaltonen commented 8 years ago

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 commented 8 years ago

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:

<?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">

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 commented 8 years ago

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 commented 2 years ago

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