This repository has been archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packages.sh
executable file
·131 lines (101 loc) · 4.28 KB
/
packages.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
install_packages() {
# brew bundle doesn't support --no-quarantine. Note that this disables
# Gatekeeper for these Casks; automating this is technically a security
# issue!
brew cask install --no-quarantine android-platform-tools
# Check if these applications are already installed. They need to run in
# order to complete installation; they will only be launched if newly
# installed.
cask_before=$(brew cask list bitwarden soundsource telegram 2> /dev/null)
## LibreOffice Language Pack doesn't install to /Applications/ so this
## returns nothing to stdout; exit code is sufficient
brew cask list libreoffice-language-pack &> /dev/null
lolang_instbefore=$?
# Install packages
brew bundle --no-lock && hash -r
# Run Bitwarden if newly installed, for Safari extension
if ! echo "$cask_before" | ggrep -q Bitwarden && brew cask list bitwarden > /dev/null 2>&1; then
open -a Bitwarden && sleep 3 && pkill -x Bitwarden
fi
# Get LibreOffice Language Pack version and check if newly installed
lolang_vers="$(brew cask list --versions libreoffice-language-pack 2> /dev/null | gawk 'BEGIN {rc=1} {rc=0; print $2} END {exit rc}')"
# Run LibreOffice Language Pack installer if newly installed. Also skips if
# package not in Brewfile.
if [ "$lolang_instbefore" -ne 0 ] && [ -n "$lolang_vers" ]; then
# Launching LibreOffice also generates file associations
open -ja LibreOffice && sleep 5 && pkill -x soffice
open /usr/local/Caskroom/libreoffice-language-pack/"$lolang_vers"/'LibreOffice Language Pack.app'/
fi
# If SoundSource newly installed, run Audio Capture Engine installer
if ! echo "$cask_before" | ggrep -q SoundSource && brew cask list soundsource > /dev/null 2>&1; then
sudo /Applications/SoundSource.app/Contents/Resources/aceinstaller install -s
fi
# Run Telegram if newly installed, for Share menu extension
if ! echo "$cask_before" | ggrep -q Telegram && brew cask list telegram > /dev/null 2>&1; then
open -a Telegram && sleep 3 && pkill -x Telegram
fi
# Install Python 3 packages
/usr/local/bin/python3 -m pip install -r requirements.txt
}
install_launchbar_actions() {
gmkdir -p "$HOME/Library/Application Support/LaunchBar/Actions/" > /dev/null 2>&1
cd "$HOME/Library/Application Support/LaunchBar/Actions/"
# https://github.com/bswinnerton/launchbar-github
if [ ! -d github.lbaction ]; then
git clone https://github.com/bswinnerton/launchbar-github github.lbaction
fi
# https://github.com/v0rn/xkcdpass.lbaction
if [ ! -d xkcdpass.lbaction ]; then
git clone https://github.com/v0rn/xkcdpass.lbaction xkcdpass.lbaction
fi
}
clone_git_repos() {
gmkdir "$HOME/git/" > /dev/null 2>&1
cd "$HOME/git/"
if [ ! -d markdown-css ]; then
git clone https://github.com/otsaloma/markdown-css.git
fi
}
install_vagrant_plugins() {
installed_vagrant_plugins=$(vagrant plugin list)
for plugin in vagrant-scp vagrant-vbguest; do
if ! echo "$installed_vagrant_plugins" | ggrep -q "$plugin"; then
vagrant plugin install "$plugin"
fi
done
}
set_login_items() {
# Note: AppleScript only uses double quotes
# Login items
## Clear all existing login items
IFS=','
for item in $(osascript -e 'tell application "System Events" to get the name of every login item' | gsed 's/, /,/g'); do
osascript -e "tell application \"System Events\" to delete login item \"$item\""
done
unset IFS
# Add login items
## Use separate osascript calls, otherwise you only get output from the last
## to run and order seems to change
osascript -e 'tell application "System Events" to make login item at end with properties {name: "LaunchBar", path: "/Applications/LaunchBar.app", hidden: false}' > /dev/null
osascript -e 'tell application "System Events" to make login item at end with properties {name: "SoundSource", path: "/Applications/SoundSource.app", hidden: true}' > /dev/null
# Enable skhd and yabai at login
brew services start skhd
brew services start yabai
}
main() {
export HOMEBREW_NO_ANALYTICS=1
# Install Homebrew
if ! which brew > /dev/null 2>&1; then
# Homebrew install command, see https://brew.sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
hash -r
fi
install_packages
install_launchbar_actions
clone_git_repos
install_vagrant_plugins
set_login_items
}
main
# vim: set filetype=bash foldmethod=syntax: