cherrytree
cherrytree copied to clipboard
[Mac] run as an app and not as CLI
Version, Operative system macOS Big Sur 11.2.3 (Latest)
Describe the bug Not sure if its a bug or should be a feature:
Normally the apps installed with brew are:
brew install --cask App name
And then I have one app that I can run directly
In the Cherrytree app is only:
brew install cherrytree
Then I have to open a Terminal and run from there.
I can see it exist in other apps (as an example) :
https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/keepingyouawake.rb#L20
Am I missing something on how to install or run it?
Thanks in advance!
I'm not familiar with what needs to be done in the Mac os to add the app to the desktop menu but I will investigate
me too
Any update on that?
Not yet, will do some research in the next days see if I understand what is needed
Thank's @giuspen
The problem here is, that the app has to kept running on the Terminal and does not appear as an app. and if the terminal is closed then the app crashes.
Hi @giuspen, do you have some findings?
It's kind of annoying to have the terminal always opened
To be honest I was hoping it was as easy as create something like a .desktop file for Linux and install it somewhere at the time of installing cherrytree buy I haven't found such thing. I found instead guides on adding command launchers to the panel and basically that's what you have to do, add a custom launcher/command with the command "cherrytree". I'll try myself and explain better but I need to fix some other stuff for the next release first
Hi everyone!
I've done the installation through Homebrew and it does not create an .app file, it creates a regular bin in /usr/local/bin/cherrytree
You have to create an applescript in automator to create an .app and save it in the /Applications folder to it to appear in the launchpad.
The script needs only these three lines:
tell application "/usr/local/bin/cherrytree"
activate
end tell
If you don't want that ugly automator icon, you can change it in a lot of ways, or you can use an application called Platypus to create it and change the icon.
- After installing it you choose the name of the App you want (Cherrytree in this case)
- Change to applescript
- Click in new and paste the code above in the pop up and save it
- Change interface to none
- Change the icon to the one you want
- Change the identifier name
- Change the author's name
Save it in the Applications folder
And voilà, it is in the Launchpad!!
After you open it, it creates an icon in the dock with the icon you chose and no terminal window whatsoever!
Hope it helps!
After my answer and a little reflection I think I should have inserted Giuseppe Penone as the author's name... 🤣🤣🤣
My bad @giuspen
I've created a .app file with the original cherrytree icon with bigsur style and the proper credit to Giuseppe!!
@bernardmotoni your help is very useful, do you think I may try and have your app file(s) installed somewhere on the filesystem in the homebrew install or the user will have to manually add it? I will give it a try anyway later on my Mac OSX Big Sur VM
@giuspen Glad I could help!!! I don't know how to build the homebrew install, but a lot of those I install during the installation script they automatically copy the .app do the /Applications folder...
I'll check it out!
Found this in the Homebrew issues... It's a script people use to remove an old version of the app in the App folder and copy the new one...
I can't test this one, but I think it's worth a try.
version() { mdls -name kMDItemVersion "$1"| egrep -o [0-9.]+ ;}
App=(/App*s/"${1##*/}")
[[ ! -a $App || -L $App || $(version $1) > $(version $App) ]] &&
{ mv "$App" ~/.Trash
mv "$1" "${App%/*}"
ln -s "$App" "${1%/*}"/
}
Thanks @bernardmotoni I'll try and do some testing on the launcher in the next days
Thanks, @bernardmotoni, I get still a terminal icon in the dock, is there a way to prevent this?
Thanks, @bernardmotoni, I get still a terminal icon in the dock, is there a way to prevent this?
R u ready for the workout? LOL
After some trial and error I found this:
You have to run the app, after it is in the dock, right click it -> options -> show in finder
Then it will open the folder containing the bin
file. In my case, with the latest version, it was
/usr/local/Cellar/cherrytree/0.99.38/bin
After that You'll right click cherrytree
and click in Get Info.
In the info page you HAVE to change the permissions of the app to read and write for your user, admin and everyone.
Then you proceed to pick the icon of the cherrytree app and drag it into the "terminal icon" of the bin
If you don't have an icon to put, you can take the one I made inside the cherrytree.app
and place it there.
Right click cherrytree.app
and click in Show Package Content then go to Contents -> Resources and then you'll find a file called AppIcon.icns
. This is the guy you want.
Drag it into the info dialog and you'll get the official cherrytree icon Big Sur style in your Dock.
Sorry for the long post. Hope it'll help.
I just found out that the .zip I made was creating an .app inside a .app...
Remade it to work right..
In general on macOS, an application is just a folder in a specific format:
/Applications/MacPorts/CherryTree.app/Contents/Info.plist
/Applications/MacPorts/CherryTree.app/Contents/MacOS/CherryTree
/Applications/MacPorts/CherryTree.app/Contents/PkgInfo
/Applications/MacPorts/CherryTree.app/Contents/Resources/CherryTree.icns
The CherryTree
executable can be the application, or a script that launches it. The icns file is obvious. The Info.plist
file has a specific format. Here is the one we use on MacPorts for the python version of cherrytree. The c++ version would be very similar.
% cat /Applications/MacPorts/CherryTree.app/Contents/Info.plist
<?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>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>CherryTree</string>
<key>CFBundleIconFile</key>
<string>CherryTree.icns</string>
<key>LSUIElement</key>
<true/>
<key>CFBundleIdentifier</key>
<string>com.github.giuspen.cherrytree.CherryTree</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>CherryTree</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.39.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.39.4</string>
</dict>
</plist>
The PkgInfo
file is an ASCII file that is presently this:
APPL????
If you wanted to make a self-contained, relocatable version of cherrytree you would move all the linked libraries and similar needed resources into the Resources folder, and then tell the executable where to find them. This usually means relinking the executable using @rpath
links to the needed libraries (changing these with install_name_tool
). This can get tricky, so many people use dylibbundler:
% port info dylibbundler
dylibbundler @1.0.0 (devel)
Variants: universal
Description: dylibbundler is a small command-line programs that aims to make bundling .dylibs as easy as possible. It
automatically determines which dylibs are needed by your program, copies these libraries inside the app
bundle, and fixes both them and the executable to be ready for distribution, all this with a single
command. It will also work if your program uses plug-ins that have dependencies too.
Homepage: https://github.com/auriamg/macdylibbundler
Platforms: darwin
License: MIT
Maintainers: Email: [email protected], GitHub: ryandesign
Policy: openmaintainer
I just found out that the .zip I made was creating an .app inside a .app...
Remade it to work right..
Oh wow, this worked a treat for me! This should be added to the install process or https://giuspen.net/cherrytreemanual/
Hi everyone!
I've done the installation through Homebrew and it does not create an .app file, it creates a regular bin in /usr/local/bin/cherrytree
You have to create an applescript in automator to create an .app and save it in the /Applications folder to it to appear in the launchpad.
The script needs only these three lines:
tell application "/usr/local/bin/cherrytree"
activate
end tell
If you don't want that ugly automator icon, you can change it in a lot of ways, or you can use an application called Platypus to create it and change the icon.
- After installing it you choose the name of the App you want (Cherrytree in this case)
- Change to applescript
- Click in new and paste the code above in the pop up and save it
- Change interface to none
- Change the icon to the one you want
- Change the identifier name
- Change the author's name
Save it in the Applications folder
And voilà, it is in the Launchpad!!
After you open it, it creates an icon in the dock with the icon you chose and no terminal window whatsoever!
Hope it helps!
Thank you for your help. I was able to successfully resolve my issue using the method you provided. It was both effective and convenient, and aligns well with the logic of macOS. I appreciate it.
Open Automator on your Mac. Select "Application" as the type of document to create. In the search bar, type "Run AppleScript" and select it. In the newly added "Run AppleScript" box, copy and paste the following script:
tell application "/usr/local/bin/cherrytree" activate end tell
In my case, the correct path was /opt/homebrew/bin/cherrytree
Thanks, @bernardmotoni, I get still a terminal icon in the dock, is there a way to prevent this?
R u ready for the workout? LOL
After some trial and error I found this:
You have to run the app, after it is in the dock, right click it -> options -> show in finder
Then it will open the folder containing the
bin
file. In my case, with the latest version, it was/usr/local/Cellar/cherrytree/0.99.38/bin
After that You'll right click
cherrytree
and click in Get Info.In the info page you HAVE to change the permissions of the app to read and write for your user, admin and everyone.
Then you proceed to pick the icon of the cherrytree app and drag it into the "terminal icon" of the
bin
If you don't have an icon to put, you can take the one I made inside the
cherrytree.app
and place it there.Right click
cherrytree.app
and click in Show Package Content then go to Contents -> Resources and then you'll find a file calledAppIcon.icns
. This is the guy you want.Drag it into the info dialog and you'll get the official cherrytree icon Big Sur style in your Dock.
Sorry for the long post. Hope it'll help.
Now the final step left...
If you "keep it in dock", then once you open it via dock icon, it launches the terminal, rather than *.app
Now if you drag the app to the dock, once it is launched it opens new app, but closes the launcher.
Which is inconsistent with how all of my other apps work... :(
There is any chance to insert directly in brew the app? (like other programs as VsCode)
I found one solution with Automator:
# No file selected execution
[[ -z "$@" ]] && exec /opt/homebrew/bin/cherrytree > /dev/null 2>&1 &
# Files selected execution
for f in "$@"
do
exec /opt/homebrew/bin/cherrytree "$f" > /dev/null 2>&1 &
done
exit 0
This setup permits running multiple instances with multiple files or no one.
To change the application icon, simply open information and drag and drop the icon over the default automator icon
Actually I'm studying how to add icon to all associated files
Based on this solution: https://gist.github.com/philipptempel/6110875
- Open the
CherryTree.app
in finder with the second option (Show package continent) - Paste the icon file of cherryTree (I download it from documentation)
CherryTree.app/Contents/Resources/CherryTree.icns
- Edit
CherryTree.app/Contents/Info.plist
as follow:- Search
<key>CFBundleIconFile</key>
and change thestring
parameter with ONLY the name of icon (hereCherryTree
) - Search
<key>CFBundleDocumentTypes</key>
override thearray tag
with follow:
<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeExtensions</key> <array> <string>ctb</string> <string>ctx</string> <string>cbd</string> <string>cbz</string> </array> <key>CFBundleTypeName</key> <string>CherryTree note file</string> <key>CFBundleTypeIconFile</key> <string>CherryTree</string> <key>CFBundleTypeOSTypes</key> <array> <string>****</string> </array> <key>CFBundleTypeRole</key> <string>Viewer</string> </dict> </array>
- Search
- Now exit from the application folder (yes, in Mac applications are simply a folder), move the
CherryTree.app
to another folder, and then again in theApplication
folder (This is done so Launch Services picks up the changes to Info.plist we just performed.)
Now should see the application il launch pad and file with the .cbt
extension change