Skip to content

Commit

Permalink
✨ Add Mac App Store command line utility support
Browse files Browse the repository at this point in the history
Extended the functionality of the utilities shell script, utils.sh, to support commands from the Mac App Store using the 'mas' command line interface. New functions 'mas_install' and 'mas_install_with_confirmation' help automate the installation of MacOS apps.

As a part of the change, certain apps which were previously noted to be manually installed from the Mac App Store are now automated in their respective scripts. This includes apps like "Kindle", "GoPro Player + ReelSteady", "Bandwidth+", "Be Focused - Pomodoro Timer", "Presentify - Screen Annotation", "EasyRes", "Magnet", "Itemido: Manage Home Inventory" and "Telephone - VoIP SIP softphone".

This update helps the script manage a broader range of applications. Additionally, references to manual installation steps for these apps are removed from 'print_optional_manual_items.sh'.

Aliases have been introduced to shorten commonly used 'mas' commands, included in the 'bash_aliases' file.

Finally, included 'mas-cli.sh' in 'main.sh' for the installation of 'mas' itself.
  • Loading branch information
wingy3181 committed Dec 3, 2023
1 parent cdf57fc commit d555f5c
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/os/installs/macos/desktop_utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ cd "$(dirname "${BASH_SOURCE[0]}")" \
print_in_purple "\n Desktop Utilities\n\n"

brew_install_with_confirmation "AppCleaner" "appcleaner" "--cask"
mas_install_with_confirmation "Bandwidth+" "490461369"
# https://xwavesoft.com/be-focused-pro-for-iphone-ipad-mac-os-x.html
mas_install_with_confirmation "Be Focused - Pomodoro Timer" "973134470"
brew_install_with_confirmation "Cheatsheet" "cheatsheet" "--cask"
brew_install_with_confirmation "DisplayLink USB Graphics Software" "displaylink" "--cask"
mas_install_with_confirmation "EasyRes" "688211836"
mas_install_with_confirmation "Magnet" "441258766"
# https://presentify.compzets.com/
mas_install_with_confirmation "Presentify - Screen Annotation" "1507246666"
brew_install_with_confirmation "Raycast" "raycast" "--cask"
brew_install_with_confirmation "Silicon" "silicon" "--cask"
brew_install_with_confirmation "Unarchiver" "the-unarchiver" "--cask"
Expand Down
1 change: 1 addition & 0 deletions src/os/installs/macos/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ main() {
./xcode.sh
./rosetta_2.sh
./homebrew.sh
./mas-cli.sh
./../bash.sh

./git.sh
Expand Down
11 changes: 11 additions & 0 deletions src/os/installs/macos/mas-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

cd "$(dirname "${BASH_SOURCE[0]}")" \
&& . "../../utils.sh" \
&& . "./utils.sh"

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

print_in_purple "\n Mac App Store command line interface\n\n"

brew_install "mas-cli" "mas"
5 changes: 5 additions & 0 deletions src/os/installs/macos/misc_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ cd "$(dirname "${BASH_SOURCE[0]}")" \

print_in_purple "\n Miscellaneous Tools\n\n"

# https://www.itemido.com/en/index.html
mas_install_with_confirmation "Itemido: Manage Home Inventory" "1552953842"
# brew_install_with_confirmation "Keybase" "keybase" "--cask"
# https://www.64characters.com/telephone/
# https://github.com/64characters/Telephone
mas_install_with_confirmation "Telephone - VoIP SIP softphone" "406825478"
2 changes: 2 additions & 0 deletions src/os/installs/macos/office_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ print_in_purple "\n Office Tools\n\n"

brew_install_with_confirmation "Dropbox" "dropbox" "--cask"
brew_install_with_confirmation "Calibre" "calibre" "--cask"
# Rename registered device within Amazon https://www.amazon.com.au/hz/mycd/digital-console/alldevices
mas_install_with_confirmation "Kindle" "302584613"
brew_install_with_confirmation "Notion" "notion" "--cask"
brew_install_with_confirmation "PDF Expert" "pdf-expert" "--cask"
brew_install_with_confirmation "Microsoft Office" "microsoft-office" "--cask"
Expand Down
63 changes: 63 additions & 0 deletions src/os/installs/macos/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,66 @@ brew_upgrade() {
"Homebrew (upgrade)"

}

mas_install() {

declare -r APP_STORE_READABLE_NAME="$1"
declare -r APP_STORE_IDENTIFIER="$2"

# If environment variable is set and readable name does not match regex, then exit and don't bother installation
if [[ -n "$INSTALL_APPLICATION_IF_READABLE_NAME_MATCH_REGEX" && ! "$APP_STORE_READABLE_NAME" =~ $INSTALL_APPLICATION_IF_READABLE_NAME_MATCH_REGEX ]]; then
print_warning "$APP_STORE_READABLE_NAME not installed as readable name did not match regex: \"$INSTALL_APPLICATION_IF_READABLE_NAME_MATCH_REGEX\""
return 1
fi

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Check if `Mac App Store command line interface` is installed.

if ! cmd_exists "mas"; then
print_error "$APP_STORE_READABLE_NAME ('Mac App Store command line interface' is not installed)"
return 1
fi

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Install the specified formula.


execute \
"mas install $APP_STORE_IDENTIFIER" \
"$APP_STORE_READABLE_NAME (https://apps.apple.com/au/app/id$APP_STORE_IDENTIFIER)"

}

mas_install_with_confirmation() {

declare -r APP_STORE_READABLE_NAME="$1"
declare -r APP_STORE_IDENTIFIER="$2"
declare -r APP_STORE_NAME_WITH_LINK="$APP_STORE_READABLE_NAME (https://apps.apple.com/au/app/id$APP_STORE_IDENTIFIER)"

# Install application if previous confirmation reply was 'install all'
if [[ "$previousInstallApplicationConfirmationReply" =~ ^[aA]$ ]]; then
mas_install "$@"
# DON'T install application if previous confirmation reply was 'skip all'
elif [[ "$previousInstallApplicationConfirmationReply" =~ ^[sS]$ ]]; then
print_warning "$APP_STORE_NAME_WITH_LINK (not installed)"
# Otherwise, prompt user and install application based on reply
else
local installApplicationConfirmationReply=""
# Until a valid reply has been entered, keep prompting user
while [[ -z "$installApplicationConfirmationReply" || "$installApplicationConfirmationReply" =~ ^[^yYnNaAsS]$ ]]; do
ask_for_install_application_confirmation "Do you want to install $APP_STORE_NAME_WITH_LINK?"
installApplicationConfirmationReply="$(get_answer)"
done

if answer_is_yes || answer_is_yes_to_all; then
mas_install "$@"
elif answer_is_no || answer_is_skip_all; then
print_warning "$APP_STORE_NAME_WITH_LINK (not installed)"
fi

previousInstallApplicationConfirmationReply="$(get_answer)"
fi

}
3 changes: 3 additions & 0 deletions src/os/installs/macos/video_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ print_in_purple "\n Video Tools\n\n"
brew_install_with_confirmation "VLC" "vlc" "--cask"

brew_install_with_confirmation "FFmpeg" "ffmpeg"
# https://gopro.com/en/au/shop/quik-app-video-photo-editor
# https://gopro.com/en/au/info/gopro-player
mas_install_with_confirmation "GoPro Player + ReelSteady" "1460836908"
brew_install_with_confirmation "Handbrake" "handbrake" "--cask"


Expand Down
10 changes: 1 addition & 9 deletions src/os/print_optional_manual_items.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,25 @@ main() {
print_optional_info "Assess Unity (https://unity.com/)"

print_in_purple "\n Desktop Utilities\n\n"
print_optional_info "Install Magnet from App Store (https://itunes.apple.com/au/app/magnet/id441258766?mt=12)"
print_optional_info "Install Bandwidth+ from App Store (https://itunes.apple.com/au/app/bandwidth/id490461369?mt=12)"
print_optional_info "Install Be Focused from App Store (https://apps.apple.com/au/app/be-focused-pomodoro-timer/id973134470?mt=12 | https://xwavesoft.com/be-focused-pro-for-iphone-ipad-mac-os-x.html)"
print_optional_info "Install Presentify from App Store (https://apps.apple.com/app/id1507246666 and https://presentify.compzets.com/)"
print_optional_info "Install EasyRes from App Store (https://itunes.apple.com/au/app/easyres/id688211836?mt=12)"
print_optional_info "Install XtraFinder (http://www.trankynam.com/xtrafinder/) + setup preferences at src/os/preferences/macos/xtrafinder.sh"

print_in_purple "\n Miscellaneous Tools\n\n"
print_optional_info "Install Keybase"
print_optional_info "Install Ledger Live (https://www.ledger.com/pages/ledger-live or 'brew install --cask ledger-live')"
print_optional_info "Install Telephone - VoIP SIP softphone (https://apps.apple.com/us/app/telephone/id406825478 and https://www.64characters.com/telephone/ and https://github.com/64characters/Telephone)"
print_optional_info "Install Itemido: Manage Home Inventory from App Store (https://apps.apple.com/us/app/itemido-manage-home-inventory/id1552953842 and https://www.itemido.com/en/index.html)"
print_optional_info "Assess Rewind (https://www.rewind.ai/)"

print_in_purple "\n Remote Access Tools\n\n"
print_optional_info "Install Synergy (https://symless.com/synergy)"
print_optional_info "Assess TeamViewer (https://www.teamviewer.com/)"

print_in_purple "\n Office Tools\n\n"
print_optional_info "Install Kindle from App Store (https://apps.apple.com/us/app/amazon-kindle/id302584613) and rename registered device within Amazon https://www.amazon.com.au/hz/mycd/digital-console/alldevices"
print_optional_info "Install Evernote (archive of old notes - use webapp)"
print_optional_info "Rename registered Kindle device within Amazon https://www.amazon.com.au/hz/mycd/digital-console/alldevices"
print_optional_info "Assess Liquitext (https://www.liquidtext.net/)"
print_optional_info "Assess Logseq (https://logseq.com/)"

print_in_purple "\n Video Tools\n\n"
print_optional_info "Install Spatial Media Metadata Injector (https://github.com/google/spatial-media/releases and https://github.com/google/spatial-media/issues/261#issuecomment-1590148367)"
print_optional_info "Install GoPro Player + ReelSteady from App Store (https://apps.apple.com/us/app/gopro-player/id1460836908?ls=1&mt=12 and https://gopro.com/en/au/info/gopro-player)"
print_optional_info "Install Blackvue Viewer for Mac (https://www.blackvue.com/download/blackvue-mac-viewer-cloud/)"

print_in_purple "\n Virtualisation Tools\n\n"
Expand Down
14 changes: 14 additions & 0 deletions src/shell/macos/bash_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ alias brew-bundle-read-dump='brew bundle install --file=$HOME/.dotfiles/src/os/i

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Shorter commands for `Mac App Store command line interface`.

# https://github.com/mas-cli/mas
# https://github.com/mas-cli/mas/tree/main/Sources/MasKit/Commands
alias maso="mas outdated"
alias masi="mas install"
alias masr="mas uninstall"
alias mass="mas search"
alias masl="mas list"
alias masu="mas upgrade"

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Clear DNS cache.

alias clear-dns-cache="sudo dscacheutil -flushcache; \
Expand Down Expand Up @@ -109,6 +122,7 @@ alias u="sudo softwareupdate --install --all \
&& brew upgrade \
&& brew-upgrade-casks \
&& brew cleanup \
&& mas upgrade \
&& bash-it update \
&& upgrade-jenv \
&& sdk selfupdate \
Expand Down

0 comments on commit d555f5c

Please sign in to comment.