Tips & Tricks
1. Hiding files on Mac
From the macOS Sonoma 14, it’s easy to hide files and widgets on the desktop, what is useful, for example, during presentations.
To do this, you need to go to System Settings - choose „Desktop & Dock” and in sections „Desktop & Stage Manager” and „Widgets”, you can turn on or off showing files and widgets on the desktop.
Defaults command is used for changing many system settings of macOS through the terminal. It is useful for administrators who want to change some settings on the machine remotely. It is also useful for individual users who want to change quickly some settings with a script, without having to go to the system settings app. We can, for example, use the previous example with hiding files, to automate it to quickly hide and unhide files and widgets on the desktop. Here’s the script:
checkValue=$(defaults read com.apple.WindowManager StandardHideDesktopIcons)
if [ "$checkValue" = "0" ]; then
defaults write com.apple.WindowManager StandardHideDesktopIcons -bool true
defaults write com.apple.WindowManager StandardHideWidgets -bool true
else
defaults write com.apple.WindowManager StandardHideDesktopIcons -bool false
defaults write com.apple.WindowManager StandardHideWidgets -bool false
fi
We can this script running through the Shortcuts app and we have quick shortcut to hide files and widgets on the desktop😃.
More about defaults command you can read here.
2. Defaults command
3. Make a link to specific email message
In the Mail application on macOS, you can make a link to a specific email message and paste it to any app. For example, you can make a new event in the calendar or a new reminder in the Reminder app and paste there a link to the email message, which is connected to the event/reminder.
To make a link, you need to get an ID of the message, which you can do through AppleScript. This is the script:
tell application "Mail"
set mailSelected to get selection
set messageID to get message id of item 1 of mailSelected
end tell
set messageURL to "message://%3C" & messageID & "%3E"
set the clipboard to the messageURL
For first, we download the selected message; second, we get the ID of it; then we add the „message://%3C” before ID and "%3E" after ID; and in the end, we copy this URL to the clipboard where we can paste it to any app. There is no guarantee that every app will recognize it as a URL, but many Apple apps recognize it without a problem; and also, this URL is working not only on macOS but also on iOS! So, this is very useful.