From 89bf4427d6d5243d26894f74a7ced881caaee95a Mon Sep 17 00:00:00 2001 From: 5ouma <101255979+5ouma@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:04:40 +0900 Subject: [PATCH] feat(mli): Manage macOS Login Items Automatically load when running setup. --- .github/workflows/test.yml | 2 +- .../topgrade/.config/topgrade/topgrade.toml | 7 + config/zsh/.config/zsh/.zshenv | 2 +- data/Brewfile | 1 + data/login_items.json | 137 ++++++++++++++++++ setup | 10 +- 6 files changed, 155 insertions(+), 4 deletions(-) create mode 100755 data/login_items.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54a0aacb..79bf993d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - name: 🍎 Install macOS tools via Homebrew if: ${{ matrix.os == 'macOS-13' || matrix.os == 'macOS-14' }} - run: brew install 5ouma/formula/mksei blacktop/tap/lporg + run: brew install 5ouma/formula/mksei 5ouma/formula/mli blacktop/tap/lporg - name: ⚙️ Run setup env: diff --git a/config/topgrade/.config/topgrade/topgrade.toml b/config/topgrade/.config/topgrade/topgrade.toml index 3c41faf9..6480699c 100644 --- a/config/topgrade/.config/topgrade/topgrade.toml +++ b/config/topgrade/.config/topgrade/topgrade.toml @@ -49,3 +49,10 @@ repos = ["~/*", "~/ghq/*/*/*"] printf '\\033[33;1mSkipped\\033[m\n' fi """ +"mli" = """ + if (type mli &>/dev/null); then + mli save -f --file="$data/login_items.json" + else + printf '\\033[33;1mSkipped\\033[m\n' + fi +""" diff --git a/config/zsh/.config/zsh/.zshenv b/config/zsh/.config/zsh/.zshenv index 08aec5b0..67f3ab21 100644 --- a/config/zsh/.config/zsh/.zshenv +++ b/config/zsh/.config/zsh/.zshenv @@ -7,7 +7,7 @@ if [[ "$(uname)" == 'Darwin' ]]; then [[ "$(uname -m)" == 'arm64' ]] && eval "$(/opt/homebrew/bin/brew shellenv)" else eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - export HOMEBREW_BUNDLE_BREW_SKIP='5ouma/formula/mksei blacktop/tap/lporg' + export HOMEBREW_BUNDLE_BREW_SKIP='5ouma/formula/mksei 5ouma/formula/mli blacktop/tap/lporg' fi # dotfiles diff --git a/data/Brewfile b/data/Brewfile index c2a2713d..7bd16775 100644 --- a/data/Brewfile +++ b/data/Brewfile @@ -52,6 +52,7 @@ brew "zoxide" brew "zsh" brew "5ouma/formula/gh-dash" brew "5ouma/formula/mksei" +brew "5ouma/formula/mli" brew "blacktop/tap/lporg" brew "pomdtr/tap/tweety" cask "1password" diff --git a/data/login_items.json b/data/login_items.json new file mode 100755 index 00000000..aee3cc18 --- /dev/null +++ b/data/login_items.json @@ -0,0 +1,137 @@ +[ + { + "Name": "1Password", + "Path": "/Applications/1Password.app", + "Hidden": false + }, + { + "Name": "Activity Monitor", + "Path": "/System/Applications/Utilities/Activity Monitor.app", + "Hidden": false + }, + { + "Name": "Alfred 5", + "Path": "/Applications/Alfred 5.app", + "Hidden": false + }, + { + "Name": "Discord", + "Path": "/Applications/Discord.app", + "Hidden": false + }, + { + "Name": "Discord PTB", + "Path": "/Applications/Discord PTB.app", + "Hidden": false + }, + { + "Name": "Displaperture", + "Path": "/Applications/Displaperture.app", + "Hidden": false + }, + { + "Name": "Email", + "Path": "/Applications/Email.app", + "Hidden": false + }, + { + "Name": "FigmaAgent", + "Path": "/Users/souma/Library/Application Support/Figma/FigmaAgent.app", + "Hidden": false + }, + { + "Name": "Fuwari", + "Path": "/Applications/Fuwari.app", + "Hidden": false + }, + { + "Name": "Gitify", + "Path": "/Applications/Gitify.app", + "Hidden": false + }, + { + "Name": "Google Drive", + "Path": "/Applications/Google Drive.app", + "Hidden": false + }, + { + "Name": "Hammerspoon", + "Path": "/Applications/Hammerspoon.app", + "Hidden": false + }, + { + "Name": "HandyPalette", + "Path": "/Applications/HandyPalette.app", + "Hidden": false + }, + { + "Name": "Hidden Bar", + "Path": "/Applications/Hidden Bar.app", + "Hidden": false + }, + { + "Name": "HotKey", + "Path": "/Applications/HotKey.app", + "Hidden": false + }, + { + "Name": "Itsycal", + "Path": "/Applications/Itsycal.app", + "Hidden": false + }, + { + "Name": "LINE", + "Path": "/Applications/LINE.app", + "Hidden": false + }, + { + "Name": "MacUpdater", + "Path": "/Applications/MacUpdater.app", + "Hidden": false + }, + { + "Name": "Mail", + "Path": "/System/Applications/Mail.app", + "Hidden": false + }, + { + "Name": "Notion", + "Path": "/Applications/Notion.app", + "Hidden": false + }, + { + "Name": "OrbStack", + "Path": "/Applications/OrbStack.app", + "Hidden": false + }, + { + "Name": "Raycast", + "Path": "/Applications/Raycast.app", + "Hidden": false + }, + { + "Name": "Rectangle", + "Path": "/Applications/Rectangle.app", + "Hidden": false + }, + { + "Name": "RunCat", + "Path": "/Applications/RunCat.app", + "Hidden": false + }, + { + "Name": "Spark Desktop", + "Path": "/Applications/Spark Desktop.app", + "Hidden": false + }, + { + "Name": "Speedtest", + "Path": "/Applications/Speedtest.app", + "Hidden": false + }, + { + "Name": "TickTick", + "Path": "/Applications/TickTick.app", + "Hidden": false + } +] diff --git a/setup b/setup index 59fcf7c1..66c8f566 100755 --- a/setup +++ b/setup @@ -32,7 +32,7 @@ getGum() { curl -sL "$gumUrl" | tar zxC "$TMPDIR" 'gum' && alias gumCom='$TMPDIR/gum' printf '\r ' else - alias gumCom='$(which gum)' + alias gumCom="$(which gum)" fi if [[ ! -f "$data/blue.json" ]]; then @@ -285,7 +285,7 @@ EOM #==================================================[ Apps ]==================================================# installApps() { - (! isDarwin) && export HOMEBREW_BUNDLE_BREW_SKIP='5ouma/formula/mksei blacktop/tap/lporg' + (! isDarwin) && export HOMEBREW_BUNDLE_BREW_SKIP='5ouma/formula/mksei 5ouma/formula/mli blacktop/tap/lporg' (gum run "Satisfying Brewfile's dependencies..." -- brew bundle check --file="$data/Brewfile") && skip brew update && brew bundle install --no-lock --file="$data/Brewfile" } && run 'installApps' '## 📲 Install commands and apps' @@ -321,6 +321,12 @@ restoreAppShortcuts() { gum run 'Running `mksei load`...' -- mksei load "$data/keyboard_shortcuts.json" } && run 'restoreAppShortcuts' '## ⌨️ Restore App Shortcuts' true +restoreLoginItems() { + (mli check --file="$data/login_items.json" &>/dev/null) && skip + # shellcheck disable=SC2016 + gum run 'Running `mli load`...' -- mli load --file="$data/login_items.json" +} && run 'restoreLoginItems' '## 📑 Restore Login Items' true + generateGitHooks() { [[ -f "$XDG_CONFIG_HOME/git/hooks/pre-commit" && -f "$XDG_CONFIG_HOME/git/hooks/commit-msg" ]] && skip pre-commit init-templatedir "$XDG_CONFIG_HOME/git" -c="$data/pre-commit.yml" | sed -n 1p