commit 4a3257afc1bfa619d9ad029bfd7b438edb95c84c
parent f65158144806f35220a8e423f45bd877ff843d2a
Author: Anders Damsgaard <andersd@riseup.net>
Date: Thu, 28 Sep 2017 20:39:01 -0400
improve init script launching
Diffstat:
12 files changed, 59 insertions(+), 129 deletions(-)
diff --git a/init/10_osx.sh b/init/10_osx.sh
@@ -1,5 +1,8 @@
#!/usr/bin/env bash
-[[ "$(uname)" != "Darwin" ]] && exit 1
+[[ "$(uname)" != "Darwin" ]] && return 1
+
+read -p "Do you want to set macOS settings? [y/n] " -n 1 -r
+[[ "$REPLY" == [Nn]* ]] && return 1
# Derived from mathiasbynens's macos setup script
@@ -18,11 +21,11 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
###############################################################################
# Set computer name (as done via System Preferences → Sharing)
-hostname=flaptop
-sudo scutil --set ComputerName "$(hostname)"
-sudo scutil --set HostName "$(hostname)"
-sudo scutil --set LocalHostName "$(hostname)"
-sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$(hostname)"
+#hostname=flaptop
+#sudo scutil --set ComputerName "$(hostname)"
+#sudo scutil --set HostName "$(hostname)"
+#sudo scutil --set LocalHostName "$(hostname)"
+#sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$(hostname)"
# Set standby delay to 24 hours (default is 1 hour)
sudo pmset -a standbydelay 86400
@@ -137,11 +140,11 @@ defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
sudo pmset -a hibernatemode 0
# Remove the sleep image file to save disk space
-sudo rm /private/var/vm/sleepimage
+#sudo rm /private/var/vm/sleepimage
# Create a zero-byte file instead…
-sudo touch /private/var/vm/sleepimage
+#sudo touch /private/var/vm/sleepimage
# …and make sure it can’t be rewritten
-sudo chflags uchg /private/var/vm/sleepimage
+#sudo chflags uchg /private/var/vm/sleepimage
###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
@@ -177,9 +180,9 @@ defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
-# Set a blazingly fast keyboard repeat rate (was 1 and 10)
-defaults write NSGlobalDomain KeyRepeat -int 10
-defaults write NSGlobalDomain InitialKeyRepeat -int 100
+# Set a blazingly fast keyboard repeat rate (macOS defaults: 6 and 25)
+defaults write NSGlobalDomain KeyRepeat -int 3
+defaults write NSGlobalDomain InitialKeyRepeat -int 30
# Set language and text formats
# Note: if you’re in the US, replace `EUR` with `USD`, `Centimeters` with
@@ -235,7 +238,7 @@ defaults write com.apple.finder DisableAllAnimations -bool true
# Set Desktop as the default location for new Finder windows
# For other paths, use `PfLo` and `file:///full/path/here/`
-defaults write com.apple.finder NewWindowTarget -string "PfDe"
+#defaults write com.apple.finder NewWindowTarget -string "PfDe"
#defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Desktop/"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/"
@@ -280,9 +283,9 @@ defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
# Disable disk image verification
-defaults write com.apple.frameworks.diskimages skip-verify -bool true
-defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
-defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
+#defaults write com.apple.frameworks.diskimages skip-verify -bool true
+#defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
+#defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
# Automatically open a new Finder window when a volume is mounted
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
@@ -290,12 +293,12 @@ defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true
# Show item info near icons on the desktop and in other icon views
-/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
-/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
-/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
+#/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
+#/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
+#/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
# Show item info to the right of the icons on the desktop
-/usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist
+#/usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist
# Enable snap-to-grid for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
@@ -308,9 +311,9 @@ defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
# Increase the size of icons on the desktop and in other icon views
-/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
-/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
-/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
+#/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
+#/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
+#/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
# Use list view in all Finder windows by default
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
@@ -492,10 +495,10 @@ defaults write com.apple.Safari WebContinuousSpellCheckingEnabled -bool true
defaults write com.apple.Safari WebAutomaticSpellingCorrectionEnabled -bool false
# Disable AutoFill
-defaults write com.apple.Safari AutoFillFromAddressBook -bool false
-defaults write com.apple.Safari AutoFillPasswords -bool false
-defaults write com.apple.Safari AutoFillCreditCardData -bool false
-defaults write com.apple.Safari AutoFillMiscellaneousForms -bool false
+#defaults write com.apple.Safari AutoFillFromAddressBook -bool false
+#defaults write com.apple.Safari AutoFillPasswords -bool false
+#defaults write com.apple.Safari AutoFillCreditCardData -bool false
+#defaults write com.apple.Safari AutoFillMiscellaneousForms -bool false
# Warn about fraudulent websites
defaults write com.apple.Safari WarnAboutFraudulentWebsites -bool true
@@ -539,7 +542,7 @@ defaults write com.apple.mail DisableSendAnimations -bool true
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
# Add the keyboard shortcut ⌘ + Enter to send an email in Mail.app
-defaults write com.apple.mail NSUserKeyEquivalents -dict-add "Send" "@\U21a9"
+#defaults write com.apple.mail NSUserKeyEquivalents -dict-add "Send" "@\U21a9"
# Display emails in threaded mode, sorted by date (oldest at the top)
defaults write com.apple.mail DraftsViewerAttributes -dict-add "DisplayInThreadedMode" -string "yes"
@@ -586,8 +589,6 @@ defaults write com.apple.spotlight orderedItems -array \
'{"enabled" = 0;"name" = "MOVIES";}' \
'{"enabled" = 0;"name" = "PRESENTATIONS";}' \
'{"enabled" = 0;"name" = "SPREADSHEETS";}'
- '{"enabled" = 0;"name" = "SOURCE";}' \
- '{"enabled" = 0;"name" = "MENU_DEFINITION";}' \
'{"enabled" = 0;"name" = "MENU_OTHER";}' \
'{"enabled" = 0;"name" = "MENU_CONVERSION";}' \
'{"enabled" = 0;"name" = "MENU_EXPRESSION";}' \
@@ -667,7 +668,7 @@ defaults write com.apple.terminal SecureKeyboardEntry -bool true
defaults write com.apple.Terminal ShowLineMarks -int 0
# Install the Solarized Dark theme for iTerm
-open "${HOME}/init/Solarized Dark.itermcolors"
+#open "${HOME}/init/Solarized Dark.itermcolors"
# Don’t display the annoying prompt when quitting iTerm
defaults write com.googlecode.iterm2 PromptOnQuit -bool false
@@ -680,7 +681,7 @@ defaults write com.googlecode.iterm2 PromptOnQuit -bool false
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
# Disable local Time Machine backups
-hash tmutil &> /dev/null && sudo tmutil disablelocal
+#hash tmutil &> /dev/null && sudo tmutil disablelocal
###############################################################################
# Activity Monitor #
diff --git a/init/10_osx_xcode.sh b/init/10_osx_xcode.sh
@@ -1,7 +1,7 @@
-#!/bin/sh
+#!/usr/bin/env bash
# OSX-stuff only
-[[ "$(uname)" != "Darwin" ]] && exit 1
+[[ "$(uname)" != "Darwin" ]] && return 1
if [[ ! -d "$('xcode-select' -print-path 2>/dev/null)" ]]; then
sudo xcode-select -switch /usr/bin
diff --git a/init/10_symlinks.sh b/init/10_symlinks.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Create folders
mkdir -p ~/bin
@@ -38,13 +38,13 @@ for f in links/*; do
SOURCE=$PWD/$f
TARGET=~/$(basename $f)
- # Skip symlink generation if the link already exists
- [ -L $TARGET ] && continue
-
# Rename any original files or directories
[ -f $TARGET ] && mv $TARGET ${TARGET}_bck
[ -d $TARGET ] && mv $TARGET ${TARGET}_bck
+ # Remove old symlinks
+ [ -L $TARGET ] && rm $TARGET
+
echo "Symlink: $SOURCE -> $TARGET"
ln -s $SOURCE $TARGET
done
diff --git a/init/20_debian_apt.sh b/init/20_debian_apt.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-[[ "$(uname)" != "Linux" ]] && exit 1
-[[ "$(cat /etc/issue 2> /dev/null)" =~ Debian ]] || exit 1
+[[ "$(uname)" != "Linux" ]] && return 1
+[[ "$(cat /etc/issue 2> /dev/null)" =~ Debian ]] || return 1
set -e
diff --git a/init/20_osx_homebrew.sh b/init/20_osx_homebrew.sh
@@ -1,7 +1,9 @@
-#!/bin/bash
+#!/usr/bin/env bash
# OSX-stuff only
-[[ "$(uname)" != "Darwin" ]] && exit 1
+[[ "$(uname)" != "Darwin" ]] && return 1
+
+[[ "$(type -P brew)" ]] && echo "Homebrew already installed." && return 0
# install homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
diff --git a/init/30_osx_casks.sh b/init/30_osx_casks.sh
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/usr/bin/env bash
# OSX-stuff only
-[[ "$(uname)" != "Darwin" ]] && exit 1
+[[ "$(uname)" != "Darwin" ]] && return 1
# Exit if, for some reason, Homebrew is not installed.
[[ ! "$(type -P brew)" ]] && echo "Homebrew failed to install." && return 1
@@ -12,6 +12,7 @@ casks=(
adobe-creative-cloud
alfred
battle-net
+ bartender
bitbar
duet
firefox
diff --git a/init/30_osx_recipes.sh b/init/30_osx_recipes.sh
@@ -1,10 +1,10 @@
-#!/bin/bash
+#!/usr/bin/env bash
# OSX-stuff only
-[[ "$(uname)" != "Darwin" ]] && exit 1
+[[ "$(uname)" != "Darwin" ]] && return 1
## Exit if, for some reason, Homebrew is not installed.
-[[ ! "$(type -P brew)" ]] && echo "Recipes need Homebrew to install." && exit 1
+[[ ! "$(type -P brew)" ]] && echo "Recipes need Homebrew to install." && return 1
# from `brew list`
brews=(
@@ -78,7 +78,7 @@ done
# notmuch-mutt requirements
-[[ ! "$(type -P cpanm)" ]] && echo "cpanm failed to install." && exit 1
+[[ ! "$(type -P cpanm)" ]] && echo "cpanm failed to install." && return 1
cpanm Digest::SHA\
Mail::Box\
Mail::Header\
diff --git a/init/30_python_pip.sh b/init/30_python_pip.sh
@@ -1,5 +1,5 @@
-#!/bin/bash
-[[ ! "$(type -P pip)" ]] && echo "Pip needs to be installed." && exit 1
+#!/usr/bin/env bash
+[[ ! "$(type -P pip)" ]] && echo "Pip needs to be installed." && return 1
# pip packages
pips=(
diff --git a/init/50_vim.sh b/init/50_vim.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# Install vim-plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
diff --git a/init/50_zsh.sh b/init/50_zsh.sh
@@ -1,3 +1,5 @@
+#!/usr/bin/env bash
+
# Clone zsh syntax highlighting and git prompt
(mkdir -p $HOME/code && cd $HOME/code &&
if [ ! -d zsh-syntax-highlighting ]; then
diff --git a/install.sh b/install.sh
@@ -2,5 +2,6 @@
# Run initialization scripts
for s in init/*.sh; do
- bash $s;
+ echo "\n### $s ###########################"
+ source $s
done
diff --git a/misc_code/bitbar-plugins/kwm.2s.sh b/misc_code/bitbar-plugins/kwm.2s.sh
@@ -1,77 +0,0 @@
-#!/bin/bash
-
-color="#f0c674"
-
-#kwmc=$HOME/code/kwm/bin/kwmc
-kwmc=/usr/local/bin/kwmc
-
-currentFocus=$($kwmc query focus)
-currentMouse=$($kwmc query mouse-follows)
-tag=$($kwmc query tag)
-
-if [ "$1" = 'quit' ]; then
- killall kwm
- exit
-fi
-
-if [ "$1" = 'reload' ]; then
- $kwmc config reload
- exit
-fi
-
-if [ "$1" = 'refresh' ]; then
- $kwmc tree -c refresh
- exit
-fi
-
-if [ "$1" = 'bsp' ]; then
- $kwmc space -t bsp
- exit
-fi
-
-if [ "$1" = 'monocle' ]; then
- $kwmc space -t monocle
- exit
-fi
-
-if [ "$1" = 'float' ]; then
- $kwmc space -t float
- exit
-fi
-
-if [ "$1" = 'toggle-autoraise' ]; then
- [[ $currentFocus = "autoraise" ]] && value="disabled" || value="autoraise"
- $kwmc config focus $value
- exit
-fi
-
-if [ "$1" = 'toggle-mouse-follows' ]; then
- [[ $currentMouse = "enabled" ]] && value="disable" || value="enable"
- $kwmc config focus mouse-follows $value
- exit
-fi
-
-echo "$(echo kwm $tag | sed 's/kwm Connection failed!//') | dropdown=false color=${color}"
-
-echo "---";
-
-echo "BSP | bash=$0 param1=bsp terminal=false"
-echo "Monocle | bash=$0 param1=monocle terminal=false"
-echo "Floating | bash=$0 param1=float terminal=false"
-
-echo "---"
-
-[[ $currentFocus = "autoraise" ]] && focus="Disable" || focus="Enable"
-
-echo "$focus Focus Follows Mouse | bash=$0 param1=toggle-autoraise terminal=false"
-
-[[ $currentMouse = "enabled" ]] && mouse="Disable" || mouse="Enable"
-
-echo "$mouse Mouse Follows Focus | bash=$0 param1=toggle-mouse-follows terminal=false"
-
-echo "---"
-
-echo "Refresh kwm | bash=$0 param1=refresh terminal=false"
-echo "Reload kwm | bash=$0 param1=reload terminal=false"
-echo "Quit kwm | bash=$0 param1=quit terminal=false"
-