diff --git a/dotfiles/.local/bin/clean.sh b/dotfiles/.local/bin/clean.sh new file mode 100755 index 0000000..0f1b371 --- /dev/null +++ b/dotfiles/.local/bin/clean.sh @@ -0,0 +1,86 @@ +#! /bin/bash + +if [ -z "$1" ] || [ "$1" = "--help" ]; then + printf "%s\n" "Usage: app-cleaner.sh /path/to/app.app" + exit 0 +fi + +IFS=$'\n' + +red=$(tput setaf 1) +normal=$(tput sgr0) + +printf "%s\n" "Finding app data…" +sleep 1 + +locations=( + "$HOME/Library" + "$HOME/Library/Application Scripts" + "$HOME/Library/Application Support" + "$HOME/Library/Application Support/CrashReporter" + "$HOME/Library/Containers" + "$HOME/Library/Caches" + "$HOME/Library/HTTPStorages" + "$HOME/Library/Group Containers" + "$HOME/Library/Internet Plug-Ins" + "$HOME/Library/LaunchAgents" + "$HOME/Library/Logs" + "$HOME/Library/Preferences" + "$HOME/Library/Preferences/ByHost" + "$HOME/Library/Saved Application State" + "$HOME/Library/WebKit" + "/Applications" + "/Library" + "/Library/Application Support" + "/Library/Application Support/CrashReporter" + "/Library/Caches" + "/Library/Extensions" + "/Library/Internet Plug-Ins" + "/Library/LaunchAgents" + "/Library/LaunchDaemons" + "/Library/Logs" + "/Library/Preferences" + "/Library/PrivilegedHelperTools" + "/private/var/db/receipts" + "/usr/local/bin" + "/usr/local/etc" + "/usr/local/opt" + "/usr/local/sbin" + "/usr/local/share" + "/usr/local/var" + $(getconf DARWIN_USER_CACHE_DIR | sed "s/\/$//") + $(getconf DARWIN_USER_TEMP_DIR | sed "s/\/$//") +) + +paths=() +app_name=$1 +bundle_identifier=$2 + +for location in "${locations[@]}"; do + paths+=($(find "$location" -iname "*$app_name*" -maxdepth 1 -prune 2>&1 | grep -v "No such file or directory" | grep -v "Operation not permitted" | grep -v "Permission denied")) +done + +if [ -n "$bundle_identifier" ]; then + for location in "${locations[@]}"; do + paths+=($(find "$location" -iname "*$bundle_identifier*" -maxdepth 1 -prune 2>&1 | grep -v "No such file or directory" | grep -v "Operation not permitted" | grep -v "Permission denied")) + done +fi + +if [ ${#paths[@]} -eq 0 ]; then + printf "%s\n" "No data found…" + exit 0 +fi + +paths=($(printf "%s\n" "${paths[@]}" | sort -u)); + +printf "%s\n" "${paths[@]}" + +printf "$red%s$normal" "Move app data to trash (y or n)? " +read -r answer +if [ "$answer" = "y" ]; then + printf "%s\n" "Moving app data to trash…" + sleep 1 + posixFiles=$(printf ", POSIX file \"%s\"" "${paths[@]}" | awk '{print substr($0,3)}') + osascript -e "tell application \"Finder\" to delete { $posixFiles }" > /dev/null + printf "%s\n" "Done" +fi diff --git a/dotfiles/.local/bin/dnsleaktest.sh b/dotfiles/.local/bin/dnsleaktest.sh new file mode 100755 index 0000000..0029dc0 --- /dev/null +++ b/dotfiles/.local/bin/dnsleaktest.sh @@ -0,0 +1,142 @@ +#!/usr/bin/env bash +#usage: ./dnsleaktest.sh [-i interface_ip|interface_name] +#example: ./dnsleaktest.sh -i eth1 +# ./dnsleaktest.sh -i 10.0.0.2 + +RED='\033[0;31m' +BOLD='\033[1m' +NC='\033[0m' +api_domain='bash.ws' +error_code=1 + +getopts "i:" opt +interface=$OPTARG + +function echo_bold { + echo -e "${BOLD}${1}${NC}" +} + +if [ -z "$interface" ]; then + curl_interface="" + ping_interface="" +else + curl_interface="--interface ${interface}" + ping_interface="-I ${interface}" + echo_bold "Interface: ${interface}" + echo "" +fi + +function increment_error_code { + error_code=$((error_code + 1)) +} + +function echo_error { + (>&2 echo -e "${RED}${1}${NC}") +} + +function require_command { + command -v $1 > /dev/null + if [ $? -ne 0 ]; then + echo_error "Please, install \"$1\"" + exit $error_code + fi + increment_error_code +} + +function check_internet_connection { + curl --silent --head ${curl_interface} --request GET "https://${api_domain}" | grep "200 OK" > /dev/null + if [ $? -ne 0 ]; then + echo_error "No internet connection." + exit $error_code + fi + increment_error_code +} + +require_command curl +require_command ping +check_internet_connection + +if command -v jq &> /dev/null; then + jq_exists=1 +else + jq_exists=0 +fi + +if hash shuf 2>/dev/null; then + id=$(shuf -i 1000000-9999999 -n 1) +else + id=$(jot -w %i -r 1 1000000 9999999) +fi + +for i in $(seq 1 10); do + ping -c 1 ${ping_interface} "${i}.${id}.${api_domain}" > /dev/null 2>&1 +done + +function print_servers { + + if (( $jq_exists )); then + + echo ${result_json} | \ + jq --monochrome-output \ + --raw-output \ + ".[] | select(.type == \"${1}\") | \"\(.ip)\(if .country_name != \"\" and .country_name != false then \" [\(.country_name)\(if .asn != \"\" and .asn != false then \" \(.asn)\" else \"\" end)]\" else \"\" end)\"" + + else + + while IFS= read -r line; do + if [[ "$line" != *${1} ]]; then + continue + fi + + ip=$(echo $line | cut -d'|' -f 1) + code=$(echo $line | cut -d'|' -f 2) + country=$(echo $line | cut -d'|' -f 3) + asn=$(echo $line | cut -d'|' -f 4) + + if [ -z "${ip// }" ]; then + continue + fi + + if [ -z "${country// }" ]; then + echo "$ip" + else + if [ -z "${asn// }" ]; then + echo "$ip [$country]" + else + echo "$ip [$country, $asn]" + fi + fi + done <<< "$result_txt" + + fi +} + + +if (( $jq_exists )); then + result_json=$(curl ${curl_interface} --silent "https://${api_domain}/dnsleak/test/${id}?json") +else + result_txt=$(curl ${curl_interface} --silent "https://${api_domain}/dnsleak/test/${id}?txt") +fi + +dns_count=$(print_servers "dns" | wc -l) + +echo_bold "Your IP:" +print_servers "ip" + +echo "" +if [ ${dns_count} -eq "0" ];then + echo_bold "No DNS servers found" +else + if [ ${dns_count} -eq "1" ];then + echo_bold "You use ${dns_count} DNS server:" + else + echo_bold "You use ${dns_count} DNS servers:" + fi + print_servers "dns" +fi + +echo "" +echo_bold "Conclusion:" +print_servers "conclusion" + +exit 0 \ No newline at end of file diff --git a/dotfiles/.local/bin/doNotCharge.sh b/dotfiles/.local/bin/doNotCharge.sh new file mode 100755 index 0000000..00b4e44 --- /dev/null +++ b/dotfiles/.local/bin/doNotCharge.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +charging=$(cbattery status charging) +[ $? -eq 0 ] && cbattery charging off diff --git a/dotfiles/.local/bin/iterm-scratchpad.scpt b/dotfiles/.local/bin/iterm-scratchpad.scpt new file mode 100644 index 0000000..b5b1e66 Binary files /dev/null and b/dotfiles/.local/bin/iterm-scratchpad.scpt differ diff --git a/dotfiles/.local/bin/kill.sh b/dotfiles/.local/bin/kill.sh new file mode 100755 index 0000000..91510c6 --- /dev/null +++ b/dotfiles/.local/bin/kill.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +ps -u $USER -o pid,%mem,%cpu,command | sort -b -k2 -r | sed -n '1!p' | cut -b 1-75 | fzf | cut -d ' ' -f1 | xargs -I {} kill -9 "{}" diff --git a/dotfiles/.local/bin/launchWireshark.sh b/dotfiles/.local/bin/launchWireshark.sh new file mode 100755 index 0000000..72c94b1 --- /dev/null +++ b/dotfiles/.local/bin/launchWireshark.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +#sudo launchctl load -w '/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist' +loader.sh -l wireshark +open -a Wireshark -W +loader.sh -u wireshark diff --git a/dotfiles/.local/bin/loader.sh b/dotfiles/.local/bin/loader.sh new file mode 100755 index 0000000..c3c7c7f --- /dev/null +++ b/dotfiles/.local/bin/loader.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +usage() { + cat << EOF +usage: ${0##*/} [command] + -h Print this help message. + -l Start (load) agent or daemon. + -u Stop (unload) agent or daemon. +EOF +} + +getPath() { + case "$1" in + cisco) + echo '/Library/LaunchDaemons/com.cisco.anyconnect.vpnagentd.plist /Library/LaunchDaemons/com.cisco.anyconnect.ciscod64.plist /Library/LaunchAgents/com.cisco.anyconnect.notification.plist /Library/LaunchAgents/com.cisco.anyconnect.aciseposture.plist /Library/LaunchAgents/com.cisco.anyconnect.gui.plist' + ;; + postgresql) + echo '/Users/slococo/Library/LaunchAgents/homebrew.mxcl.postgresql@14.plist' + ;; + zerotier) + echo '/Library/LaunchDaemons/com.zerotier.one.plist' + ;; + wireshark) + echo '/Library/LaunchDaemons/org.wireshark.ChmodBPF.plist' + ;; + openvpn) + echo '/Library/LaunchDaemons/org.openvpn.helper.plist /Library/LaunchDaemons/org.openvpn.client.plist' + ;; + citrix) + echo '/Library/LaunchDaemons/com.citrix.CtxWorkspaceHelperDaemon.plist /Library/LaunchDaemons/com.citrix.ctxusbd.plist /Library/LaunchDaemons/com.citrix.ctxworkspaceupdater.plist /Library/LaunchAgents/com.citrix.ServiceRecords.plist /Library/LaunchAgents/com.citrix.safariadapter.plist /Library/LaunchAgents/com.citrix.AuthManager_Mac.plist /Library/LaunchAgents/com.citrix.ReceiverHelper.plist' + ;; + microsoft) + echo '/Library/LaunchDaemons/com.microsoft.autoupdate.helper.plist /Library/LaunchAgents/com.microsoft.update.agent.plist' + ;; + zoom) + echo '/Library/LaunchDaemons/us.zoom.ZoomDaemon.plist' + ;; + ?) + printf '%s: invalid program -''%s'\\n "$OPTARG" + exit 1 + ;; + esac +} + +runScript() { + while getopts ':hl:u:' flag; do + case $flag in + h) + usage + exit 0 + ;; + l) + programs=($(getPath $2)) + for value in "${programs[@]}"; do + if [[ $value == *"LaunchAgent"* ]]; then + service.sh -e "$value" -u + else + owner="$(stat -f '%Su' $value)" + if [[ "$owner" == "root" ]]; then + service.sh -e "$value" + else + service.sh -e "$value" -u + fi + fi + done + ;; + u) + programs=($(getPath $2)) + for value in "${programs[@]}"; do + if [[ $value == *"LaunchAgent"* ]]; then + service.sh -d "$value" -u + else + owner="$(stat -f '%Su' $value)" + if [[ "$owner" == "root" ]]; then + service.sh -d "$value" + else + service.sh -d "$value" -u + fi + fi + done + ;; + ?) + printf '%s: invalid option -''%s'\\n "${0##*/}" "$OPTARG" + exit 1 + ;; + esac + done +} + +runScript "$@" diff --git a/dotfiles/.local/bin/open.sh b/dotfiles/.local/bin/open.sh new file mode 100755 index 0000000..eb48466 --- /dev/null +++ b/dotfiles/.local/bin/open.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +sleep 3 +#scratchpad_id=$(osascript ~/.local/bin/iterm-scratchpad.scpt | awk '{print $NF}') +#alacritty -t "scratchpad" > /dev/null 2>&1 & +/Applications/Alacritty.app/Contents/MacOS/alacritty -t "scratchpad" & +#/opt/homebrew/bin/alacritty -t "scratchpad" & +#scratchpad_id=$(ps aux | grep 'scratchpad' | grep -v 'grep' | awk '{print $2}') +#sleep 1 +#scratchpad_id=$(/opt/homebrew/bin/yabai -m query --windows | jq '.[] | select(.title=="scratchpad").id') +##echo "$scratchpad_id" +##sleep 1 +#/opt/homebrew/bin/yabai -m window "$scratchpad_id" --space 10 +##/opt/homebrew/bin/yabai -m window "$scratchpad_id" --minimize +#/opt/homebrew/bin/yabai -m window "$scratchpad_id" --toggle float +#/opt/homebrew/bin/yabai -m window "$scratchpad_id" --grid 4:4:1:1:2:2 +#/opt/homebrew/bin/yabai -m window "$scratchpad_id" --layer above +#/opt/homebrew/bin/yabai -m space --focus 1 diff --git a/dotfiles/.local/bin/pdfConvert.sh b/dotfiles/.local/bin/pdfConvert.sh new file mode 100755 index 0000000..fa5126a --- /dev/null +++ b/dotfiles/.local/bin/pdfConvert.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +/Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to pdf "$1" diff --git a/dotfiles/.local/bin/popup.sh b/dotfiles/.local/bin/popup.sh new file mode 100755 index 0000000..34e8e90 --- /dev/null +++ b/dotfiles/.local/bin/popup.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +TITLE=mylauncher + +#SCREEN_WIDTH=`yabai -m query --displays --display | jq '.frame.w*2'` +#SCREEN_HEIGHT=`yabai -m query --displays --display | jq '.frame.h*2'` + +#TERM_WIDTH=1280 +#TERM_HEIGHT=1260 +#TERM_HEIGHT=1960 + +#let "X=SCREEN_WIDTH/2-TERM_WIDTH/2" +#let "Y=SCREEN_HEIGHT/2-TERM_HEIGHT/2" + +#alacritty -t "${TITLE}" -o window.position.x="${X}" -o window.position.y="${Y}" -o window.dimensions.lines=35 -o window.dimensions.columns=80 -o window.decorations=none --working-directory "$(pwd)" -e "$1" +#alacritty -t "${TITLE}" -o window.position.x="${X}" -o window.position.y="${Y}" -o window.dimensions.lines=10 -o window.dimensions.columns=80 -o window.decorations=none --working-directory "$(pwd)" -e "$1" + +alacritty -t "${TITLE}" --config-file=$HOME/.config/alacritty/alacritty-launcher.toml --working-directory "$(pwd)" -e "$1" diff --git a/dotfiles/.local/bin/rename.sh b/dotfiles/.local/bin/rename.sh new file mode 100755 index 0000000..fd25095 --- /dev/null +++ b/dotfiles/.local/bin/rename.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +find "$1" -type f -name "*$2*" | while read FILE; do + mv $FILE "$(echo $FILE | sed "s/$2/$3/g")" +done diff --git a/dotfiles/.local/bin/sailingMode.sh b/dotfiles/.local/bin/sailingMode.sh new file mode 100755 index 0000000..b93e39a --- /dev/null +++ b/dotfiles/.local/bin/sailingMode.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +BATTERY_PERCENTAGE=$(battery status | awk -F' ' '{print $5}' | tr -d '%') +CHARGING_STATUS=$(battery status | grep -o "smc charging .*" | awk '{print $3}') + +if (( BATTERY_PERCENTAGE > 70 )) && [[ $CHARGING_STATUS == "enabled" ]]; then + battery charging off +elif (( BATTERY_PERCENTAGE < 30 )) && [[ $CHARGING_STATUS == "disabled" ]]; then + battery charging on +fi diff --git a/dotfiles/.local/bin/scratch.sh b/dotfiles/.local/bin/scratch.sh new file mode 100755 index 0000000..fbc036a --- /dev/null +++ b/dotfiles/.local/bin/scratch.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +scratchpad_id=$(yabai -m query --windows | jq '.[] | select(.title=="scratchpad").id') + +if [[ "$scratchpad_id" == "" || "$scratchpad_id" -lt 1 ]]; then + exit 1 +fi + +is_visible=$(yabai -m query --windows --window "$scratchpad_id" | jq '."is-visible"') + +if [[ "$is_visible" = true ]]; then + yabai -m window "$scratchpad_id" --space 10 +else + yabai -m window "$scratchpad_id" --space mouse + yabai -m window --focus "$scratchpad_id" +fi diff --git a/dotfiles/.local/bin/service.sh b/dotfiles/.local/bin/service.sh new file mode 100755 index 0000000..53a1a90 --- /dev/null +++ b/dotfiles/.local/bin/service.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +usage() { + cat << EOF +usage: ${0##*/} [command] + -h Print this help message. + -e Start (load) agent or daemon. + -d Stop (unload) agent or daemon. + -u If it is a user agent or daemon. +EOF +} + +runScript() { + while getopts ':he:d:u' flag; do + case $flag in + h) + usage + exit 0 + ;; + e) + action="sudo launchctl load -w $(realpath $2)" + ;; + d) + action="sudo launchctl unload -w $(realpath $2)" + ;; + u) + action="${action:5}" + ;; + ?) + printf '%s: invalid option -''%s'\\n "${0##*/}" "$OPTARG" + exit 1 + ;; + esac + done + + + eval "$action" +} + +runScript "$@" diff --git a/dotfiles/.local/bin/systemctl.sh b/dotfiles/.local/bin/systemctl.sh new file mode 100755 index 0000000..f1b7e7d --- /dev/null +++ b/dotfiles/.local/bin/systemctl.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +start_service() { + case "$1" in + docker) colima start --mount $HOME:w --mount /Volumes/SSD:w ;; + cisco|postgresql|zerotier|wireshark|openvpn) loader.sh -l "$1" ;; + *) echo "Invalid command." >&2; exit 1 ;; + esac +} + +stop_service() { + case "$1" in + docker) colima stop ;; + cisco|postgresql|zerotier|wireshark|openvpn) loader.sh -u "$1" ;; + *) echo "Invalid command." >&2; exit 1 ;; + esac +} + +case "$1" in + start) + shift + for service in "$@"; do + start_service "$service" + done + ;; + stop) + shift + for service in "$@"; do + stop_service "$service" + done + ;; + *) + echo "Usage: $0 {start|stop} " >&2 + exit 1 + ;; +esac + diff --git a/dotfiles/.local/bin/uninstall.sh b/dotfiles/.local/bin/uninstall.sh new file mode 100755 index 0000000..9d68354 --- /dev/null +++ b/dotfiles/.local/bin/uninstall.sh @@ -0,0 +1,124 @@ +#! /bin/bash + +if [ -z "$1" ] || [ "$1" = "--help" ]; then + printf "%s\n" "Usage: app-cleaner.sh /path/to/app.app" + exit 0 +fi + +IFS=$'\n' + +red=$(tput setaf 1) +normal=$(tput sgr0) + +if [ ! -e "$1/Contents/Info.plist" ]; then + printf "%s\n" "Cannot find app plist" + exit 1 +fi + +bundle_identifier=$(/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "$1/Contents/Info.plist" 2> /dev/null) + +if [ "$bundle_identifier" = "" ]; then + printf "%s\n" "Cannot find app bundle identifier" + exit 1 +fi + +printf "%s\n" "Checking for running processes…" +sleep 1 + +app_name=$(basename $1 .app) + +processes=($(pgrep -afil "$app_name" | grep -v "uninstall.sh")) + +if [ ${#processes[@]} -gt 0 ]; then + printf "%s\n" "${processes[@]}" + printf "$red%s$normal" "Kill running processes (y or n)? " + read -r answer + if [ "$answer" = "y" ]; then + printf "%s\n" "Killing running processes…" + sleep 1 + for process in "${processes[@]}"; do + echo $process | awk '{print $1}' | xargs sudo kill 2>&1 | grep -v "No such process" + done + fi +fi + +paths=() + +paths+=($(find /private/var/db/receipts -iname "*$app_name*.bom" -maxdepth 1 -prune 2>&1 | grep -v "Permission denied")) +paths+=($(find /private/var/db/receipts -iname "*$bundle_identifier*.bom" -maxdepth 1 -prune 2>&1 | grep -v "Permission denied")) + +if [ ${#paths[@]} -gt 0 ]; then + printf "%s\n" "Saving bill of material logs to desktop…" + sleep 1 + for path in "${paths[@]}"; do + mkdir -p "$HOME/Desktop/$app_name" + lsbom -f -l -s -p f $path > "$HOME/Desktop/$app_name/$(basename $path).log" + done +fi + +printf "%s\n" "Finding app data…" +sleep 1 + +locations=( + "$HOME/Library" + "$HOME/Library/Application Scripts" + "$HOME/Library/Application Support" + "$HOME/Library/Application Support/CrashReporter" + "$HOME/Library/Containers" + "$HOME/Library/Caches" + "$HOME/Library/HTTPStorages" + "$HOME/Library/Group Containers" + "$HOME/Library/Internet Plug-Ins" + "$HOME/Library/LaunchAgents" + "$HOME/Library/Logs" + "$HOME/Library/Preferences" + "$HOME/Library/Preferences/ByHost" + "$HOME/Library/Saved Application State" + "$HOME/Library/WebKit" + "/Library" + "/Library/Application Support" + "/Library/Application Support/CrashReporter" + "/Library/Caches" + "/Library/Extensions" + "/Library/Internet Plug-Ins" + "/Library/LaunchAgents" + "/Library/LaunchDaemons" + "/Library/Logs" + "/Library/Preferences" + "/Library/PrivilegedHelperTools" + "/private/var/db/receipts" + "/usr/local/bin" + "/usr/local/etc" + "/usr/local/opt" + "/usr/local/sbin" + "/usr/local/share" + "/usr/local/var" + $(getconf DARWIN_USER_CACHE_DIR | sed "s/\/$//") + $(getconf DARWIN_USER_TEMP_DIR | sed "s/\/$//") +) + +paths=($1) + +for location in "${locations[@]}"; do + paths+=($(find "$location" -iname "*$app_name*" -maxdepth 1 -prune 2>&1 | grep -v "No such file or directory" | grep -v "Operation not permitted" | grep -v "Permission denied")) +done + +for location in "${locations[@]}"; do + paths+=($(find "$location" -iname "*$bundle_identifier*" -maxdepth 1 -prune 2>&1 | grep -v "No such file or directory" | grep -v "Operation not permitted" | grep -v "Permission denied")) +done + +paths=($(printf "%s\n" "${paths[@]}" | sort -u)); + +printf "%s\n" "${paths[@]}" + +printf "$red%s$normal" "Move app data to trash (y or n)? " +read -r answer +if [ "$answer" = "y" ]; then + printf "%s\n" "Moving app data to trash…" + sleep 1 + posixFiles=$(printf ", POSIX file \"%s\"" "${paths[@]}" | awk '{print substr($0,3)}') + osascript -e "tell application \"Finder\" to delete { $posixFiles }" > /dev/null + printf "%s\n" "Done" + + brew list "$app_name" && brew uninstall "$app_name" +fi diff --git a/dotfiles/.local/bin/unloadOpenVPN.sh b/dotfiles/.local/bin/unloadOpenVPN.sh new file mode 100755 index 0000000..fe769c2 --- /dev/null +++ b/dotfiles/.local/bin/unloadOpenVPN.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +sudo launchctl unload -w '/Library/LaunchDaemons/org.openvpn.client.plist' +sudo launchctl unload -w '/Library/LaunchDaemons/org.openvpn.helper.plist' diff --git a/dotfiles/.local/bin/upgradeCasks.sh b/dotfiles/.local/bin/upgradeCasks.sh new file mode 100755 index 0000000..8fa48f9 --- /dev/null +++ b/dotfiles/.local/bin/upgradeCasks.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +BREW_IGNORE_LIST=$(cat "$XDG_CACHE_HOME"/brew_ignore | tr '\n' '|' | sed 's/.$//' | sed 's/|/\\|/g') +brew upgrade --cask --greedy --force $(brew list --cask | grep --invert-match --regexp $BREW_IGNORE_LIST) diff --git a/dotfiles/.local/bin/upgradeFormula.sh b/dotfiles/.local/bin/upgradeFormula.sh new file mode 100755 index 0000000..35a1da1 --- /dev/null +++ b/dotfiles/.local/bin/upgradeFormula.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +brew update + +BREW_IGNORE_LIST='yabai\|skhd' +brew upgrade --formula $(brew list --formula | grep --invert-match --regexp $BREW_IGNORE_LIST) + +if brew outdated --formula | grep -q "yabai"; then + yabai --stop-service + yabai --uninstall-service + brew upgrade --formula yabai + yabai --start-service +fi + +if brew outdated --formula | grep -q "skhd"; then + skhd --stop-service + skhd --uninstall-service + brew upgrade --formula skhd + skhd --start-service +fi diff --git a/dotfiles/.local/bin/vpn.sh b/dotfiles/.local/bin/vpn.sh new file mode 100755 index 0000000..a71200e --- /dev/null +++ b/dotfiles/.local/bin/vpn.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +cleanup() { + echo "Ctrl+C pressed. Disconnecting VPN..." + sudo killswitch -d + exit 0 +} + +trap cleanup INT + +echo "Connecting VPN..." +(sleep 10; sudo killswitch -e) & +sudo openvpn /Users/slococo/Documents/client.ovpn + +exit 1