From 0847a00714dcaf45c4405758a54aebdfde893d50 Mon Sep 17 00:00:00 2001 From: doman Date: Tue, 14 Nov 2023 19:11:04 +0100 Subject: [PATCH] move HC to scriptrc --- .config/scriptrc/mac.sh | 54 ++++++++++++++++++++++++++++++++++------- .zshrc | 4 +-- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/.config/scriptrc/mac.sh b/.config/scriptrc/mac.sh index e205daa..f2eaaf0 100644 --- a/.config/scriptrc/mac.sh +++ b/.config/scriptrc/mac.sh @@ -1,18 +1,54 @@ setupmac() { - defaults write com.apple.dock expose-animation-duration -float 0.1 - defaults write -g InitialKeyRepeat -int 12 - defaults write -g KeyRepeat -int 1 - defaults write com.apple.Dock autohide-delay -float 0; killall Dock - defaults write -g com.apple.mouse.scaling -integer -1 + defaults write com.apple.dock expose-animation-duration -float 0.1 + defaults write -g InitialKeyRepeat -int 12 + defaults write -g KeyRepeat -int 1 + defaults write com.apple.Dock autohide-delay -float 0 + defaults write -g com.apple.mouse.scaling -integer -1 +} + +function disable_hot_corners(){ + defaults write com.apple.dock "wvous-tl-corner" -int 0 + defaults write com.apple.dock "wvous-tr-corner" -int 0 + defaults write com.apple.dock "wvous-br-corner" -int 0 +} + +function enable_hot_corners(){ + defaults write com.apple.dock "wvous-tl-corner" -int 2 + defaults write com.apple.dock "wvous-tr-corner" -int 3 + defaults write com.apple.dock "wvous-br-corner" -int 1 } check_ssh_add() { - if [[ "$(ssh-add -l)" == "The agent has no identities." ]] ; then - ssh-add ~/.ssh/id_rsa - setupmac - fi + if [[ "$(ssh-add -l)" == "The agent has no identities." ]] ; then + ssh-add ~/.ssh/id_rsa + setupmac + enable_hot_corners + + # Restart Dock + killall Dock + fi } +hc() { + # Make sure to read from a corner that has an active value > 0 + has_hot_corners=$(defaults read com.apple.dock "wvous-tl-corner") + + # Toggle + if (( $has_hot_corners != 0 )) + then + disable_hot_corners + else + enable_hot_corners + fi + + echo "Hot corners are now:" + defaults read com.apple.dock "wvous-tl-corner" + defaults read com.apple.dock "wvous-tr-corner" + defaults read com.apple.dock "wvous-br-corner" + + # Restart Dock + killall Dock +} if [[ "$(uname)" == "Darwin" ]]; then check_ssh_add diff --git a/.zshrc b/.zshrc index 6551bc8..956f817 100755 --- a/.zshrc +++ b/.zshrc @@ -198,7 +198,7 @@ bindkey '^l' autosuggest-accept export FZF_DEFAULT_OPTS="--reverse --bind change:first --bind ctrl-j:down,ctrl-k:up -i --cycle --header-first --border rounded" # exports - local bin, python, brew -export PATH="$HOME/.local/bin:$HOME/.bin:/Users/$USER/Library/Python/3.9/bin:$HOME/Projects/Personal/scripts:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/opt/libpq/bin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" +export PATH="$HOME/.local/bin:$HOME/.bin:/Users/$USER/Library/Python/3.9/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/opt/libpq/bin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" # mysql client on macos export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH" @@ -215,7 +215,7 @@ fi # Load scripts if [ -d "$HOME/.config/scriptrc" ]; then - for SCRIPTFILE in $HOME/.config/scriptrc/*; do + for SCRIPTFILE in $HOME/.config/scriptrc/*sh; do source $SCRIPTFILE done fi