diff --git a/LICENSE b/LICENSE index ca62623..7b0a45a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 David Jacka +Copyright (c) 2026 David Jacka, mchampanis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 63a8f6c..6038cb5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,14 @@ # useful_scripts -Some random useful scripts. -1. Using repeat keys for some applications on macos +Some random useful scripts (mostly for macOS). + +1. `fix_press_and_hold.sh` enable repeat keys only for certain applications +2. `drag_window_from_anywhere.sh` drag a window from anywhere inside it using Ctrl+Cmd and dragging with mouse +3. `remove_dock_delay.sh` speed up appearance and disappearance of Dock (if auto-hide is enabled) +4. `fix_bluetooth_mouse_lag.sh` fix Bluetooth mouse polling/lag +5. `disable_dsstore_usb_network.sh` disable creation of .DS_Store files on USB and network drives +6. `notunes_set_player.sh` stop Music/iTunes from opening when you push the Play media key; optionally open Tidal or Spotify instead + +## requirements + +https://github.com/tombonez/noTunes diff --git a/disable_dsstore_usb_network.sh b/disable_dsstore_usb_network.sh new file mode 100755 index 0000000..3564732 --- /dev/null +++ b/disable_dsstore_usb_network.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +if [ "$1" == "undo" ]; then + echo "Enabling .DS_Store file creation on network shares and removable drives..." + defaults write com.apple.desktopservices DSDontWriteNetworkStores false + defaults write com.apple.desktopservices DSDontWriteUSBStores -bool false +else + echo "Disabling .DS_Store file creation on network shares and removable drives..." + defaults write com.apple.desktopservices DSDontWriteNetworkStores true + defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true +fi + +echo "Done." diff --git a/drag_window_from_anywhere.sh b/drag_window_from_anywhere.sh new file mode 100755 index 0000000..4d3e2a8 --- /dev/null +++ b/drag_window_from_anywhere.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +if [ "$1" == "undo" ]; then + echo "Undoing drag windows from any part of window..." + defaults write -g NSWindowShouldDragOnGesture -bool false +else + echo "Allowing windows to be dragged from any part of the window (Ctrl-Cmd + )..." + defaults write -g NSWindowShouldDragOnGesture -bool true +fi + +echo "Done." diff --git a/fix_bluetooth_mouse_lag.sh b/fix_bluetooth_mouse_lag.sh index 9d95743..2dfd2bb 100755 --- a/fix_bluetooth_mouse_lag.sh +++ b/fix_bluetooth_mouse_lag.sh @@ -10,4 +10,4 @@ else sudo defaults write /Library/Preferences/com.apple.airport.bt.plist bluetoothCoexMgmt Hybrid fi -echo "Done." \ No newline at end of file +echo "Done." diff --git a/fix_press_and_hold.sh b/fix_press_and_hold.sh old mode 100644 new mode 100755 index 9083b7f..96795d9 --- a/fix_press_and_hold.sh +++ b/fix_press_and_hold.sh @@ -1,9 +1,13 @@ -KEY='ApplePressAndHoldEnabled' \ -&& defaults delete -g "$KEY" \ -; echo \ -&& APP_ID_PREFIX='com\.jetbrains\.|com\.microsoft\.VSCode|com\.todesktop\.230313mzl4w4u92' \ -&& defaults read | egrep -o "${APP_ID_PREFIX}[^\"]+" | sort --unique \ +#!/bin/bash + +set -e + +defaults delete -g ApplePressAndHoldEnabled + +APP_ID_PREFIX='com\.jetbrains\.|com\.microsoft\.VSCode|com\.todesktop\.230313mzl4w4u92' + +defaults read | egrep -o "${APP_ID_PREFIX}[^\"]+" | sort --unique \ | while read APP_ID; do echo "Setting \"repeat-character-while-key-held\" for application: '$APP_ID'..." - defaults write "$APP_ID" "$KEY" -bool 'false' + defaults write "$APP_ID" ApplePressAndHoldEnabled -bool 'false' done diff --git a/notunes_set_player.sh b/notunes_set_player.sh new file mode 100755 index 0000000..4d90b0e --- /dev/null +++ b/notunes_set_player.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# https://github.com/tombonez/noTunes +# `brew install --cask notunes` +# noTunes is a macOS application that will prevent iTunes or Apple Music from launching. +# You can configure it to open a different program when the Play media key is pressed. + +set -e + +if [ "$1" == "undo" ]; then + echo "Disabling noTunes replacement app..." + defaults delete digital.twisted.noTunes replacement +elif [ "$1" == "Tidal" ]; then + echo "Setting noTunes default app to Tidal..." + defaults write digital.twisted.noTunes replacement /Applications/Tidal.app +else + echo "Setting noTunes default app to Spotify..." + defaults write digital.twisted.noTunes replacement /Applications/Spotify.app +fi + +echo "Done." diff --git a/remove_dock_delay.sh b/remove_dock_delay.sh new file mode 100755 index 0000000..e8d9321 --- /dev/null +++ b/remove_dock_delay.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +if [ "$1" == "undo" ]; then + echo "Undoing speedy Dock..." + # defaults delete com.apple.dock autohide-time-modifier + defaults delete com.apple.dock autohide-delay + killall Dock +else + echo "Making the Dock faster..." + # defaults write com.apple.dock autohide-time-modifier -int 0.25 # this is very aggressive + defaults write com.apple.dock autohide-delay -float 0 + killall Dock +fi + +echo "Done."