May be a silly post but I thought I post here for some ideas if any. So i been tasked to create a green colored folder on users desktop that contains "X file". I can get this working on my local system but when I package it and deploy it to another system when the folder installs on the new system the color reverts back to default. Basically it seems like the custom folder color settings don't carry over. I've tried installing the folder in a shared location then creating a colored alias still no go. I've also tried creating a custom green icon folder and trying to redirect that icon to the shared folder location but even that is proving to be challenging. has anybody ever had to tackle a silly task like this? I've been at it for a few days already maybe I'm overthinking?
Solved
Green Folder on users deskotp
Best answer by dsavageED
Applescript is probably the most reliable way to set an icon, it aint pretty though...
#!/bin/bash
ITEM_PATH="$4"
echo "The path is $ITEM_PATH"
ICON="$8"
echo "The icon is $ICON"
AS_ICON=`echo "\\"${ICON}\\""`
AS_PATH=`echo "\\"${ITEM_PATH}\\""`
# Variable with necessary aplescript features around them
osascript <<EOD
use framework "AppKit"
--------------------------------------------------------------------------------
# PROPERTY DECLARATIONS:
property this : a reference to current application
property NSWorkspace : a reference to NSWorkspace of this
property NSImage : a reference to NSImage of this
--------------------------------------------------------------------------------
# IMPLEMENTATION:
on run argv
set icon to $AS_ICON
set target to $AS_PATH
setIcon to icon for target
end run
--------------------------------------------------------------------------------
# HANDLERS:
to setIcon to iconPath for filePath
set sharedWorkspace to NSWorkspace's sharedWorkspace()
set newImage to NSImage's alloc()
set icon to newImage's initWithContentsOfFile:iconPath
set success to sharedWorkspace's setIcon:icon forFile:filePath options:0
end setIcon
EOD
fi
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
