Skip to content

Commit 7fd8e43

Browse files
authored
Merge pull request #153 from unixorn/2025-01-housekeeping
2025-02-01 Housekeeping
2 parents 9985c2e + 249c002 commit 7fd8e43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2149
-434
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The Tumult collection is Apache 2.0 licensed. Some scripts in the `bin` director
6767
| `disturb` | Re-enable notifications in Notification Center |
6868
| `dns-resolvers` | macOS doesn't respect `/etc/resolve.conf`, add a helper to print what it's actually using |
6969
| `do-not-disturb` | Stifle notifications in Notification Center |
70-
| `dump-entitlements` | Dumps the [entitlements](https://developer.apple.com/documentation/bundleresources/entitlements) a given macOS binary has assigned to it |
70+
| `dump-entitlements` | Dumps the [entitlements](https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/AboutEntitlements.html) a given macOS binary has assigned to it |
7171
| `eject-all` | Eject all removable disks |
7272
| `enable-bouncing-dock-icons` | Enable icons bouncing in your Dock |
7373
| `enable-crash-reports` | Re-enable crash report dialogs |

bin/720p

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,32 @@
1616
#
1717
# Doesn't work with all apps, but does for iTerm2
1818

19-
if [ "$(uname -a | grep -ci DARWIN)" != 1 ]; then
20-
echo "Sorry, this script only works on macOS"
21-
exit 1
22-
fi
19+
function echo-stderr() {
20+
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
21+
}
22+
23+
function fail() {
24+
echo-stderr "$1"
25+
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
26+
}
27+
28+
function check-dependency() {
29+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
30+
fail "Missing dependency: can't find $1 in your PATH"
31+
fi
32+
}
33+
34+
function only-run-on() {
35+
# shellcheck disable=SC2086
36+
if [[ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "$(echo $1 | tr '[:upper:]' '[:lower:]')" ]]; then
37+
fail "This script only runs on $1, this machine is running $(uname -s)"
38+
else
39+
debug "OS ($(uname -s)) is valid..."
40+
fi
41+
}
42+
43+
only-run-on darwin
44+
check-dependency osascript
2345

2446
echo "Setting $1 bounds to 720p"
2547

bin/ask-password

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
#!/bin/bash
22
#
33
# Make it easy to ask for a password
4+
#
5+
# Copyright 2015-2025 Joe Block <[email protected]>
6+
# License: Apache 2
47

58
set -e
69

7-
if [[ "$(uname -s)" != 'Darwin' ]]; then
8-
echo 'Sorry, this script only works on macOS'
9-
exit 1
10-
fi
10+
function echo-stderr() {
11+
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
12+
}
13+
14+
function fail() {
15+
echo-stderr "$1"
16+
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
17+
}
18+
19+
function check-dependency() {
20+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
21+
fail "Missing dependency: can't find $1 in your PATH"
22+
fi
23+
}
24+
25+
function only-run-on() {
26+
# shellcheck disable=SC2086
27+
if [[ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "$(echo $1 | tr '[:upper:]' '[:lower:]')" ]]; then
28+
fail "This script only runs on $1, this machine is running $(uname -s)"
29+
else
30+
debug "OS ($(uname -s)) is valid..."
31+
fi
32+
}
33+
34+
only-run-on darwin
35+
check-dependency osascript
1136

1237
if [[ -z $1 ]]; then
1338
prompt="Password:"

bin/autocorrect-disable

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22
#
33
# Disable autocorrect
44
#
5-
# Copyright 2021, Joe Block <[email protected]>
5+
# Copyright 2021-2025, Joe Block <[email protected]>
6+
# License: Apache 2
7+
8+
function echo-stderr() {
9+
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
10+
}
11+
12+
function fail() {
13+
echo-stderr "$1"
14+
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
15+
}
16+
17+
function check-dependency() {
18+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
19+
fail "Missing dependency: can't find $1 in your PATH"
20+
fi
21+
}
22+
23+
function only-run-on() {
24+
# shellcheck disable=SC2086
25+
if [[ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "$(echo $1 | tr '[:upper:]' '[:lower:]')" ]]; then
26+
fail "This script only runs on $1, this machine is running $(uname -s)"
27+
else
28+
debug "OS ($(uname -s)) is valid..."
29+
fi
30+
}
31+
32+
only-run-on darwin
33+
check-dependency defaults
634

735
exec defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

bin/autocorrect-enable

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22
#
33
# Enable autocorrect
44
#
5-
# Copyright 2021, Joe Block <[email protected]>
5+
# Copyright 2021-2025, Joe Block <[email protected]>
6+
# License: Apache 2
7+
8+
function echo-stderr() {
9+
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
10+
}
11+
12+
function fail() {
13+
echo-stderr "$1"
14+
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
15+
}
16+
17+
function check-dependency() {
18+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
19+
fail "Missing dependency: can't find $1 in your PATH"
20+
fi
21+
}
22+
23+
function only-run-on() {
24+
# shellcheck disable=SC2086
25+
if [[ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "$(echo $1 | tr '[:upper:]' '[:lower:]')" ]]; then
26+
fail "This script only runs on $1, this machine is running $(uname -s)"
27+
else
28+
debug "OS ($(uname -s)) is valid..."
29+
fi
30+
}
31+
32+
only-run-on darwin
33+
check-dependency defaults
634

735
exec defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool true

bin/battery-percentage

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright 2015,2022 Joseph Block <[email protected]>
2+
# Copyright 2015-2025 Joseph Block <[email protected]>
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -15,10 +15,32 @@
1515

1616
set -o pipefail
1717

18-
if [[ "$(uname -s)" != 'Darwin' ]]; then
19-
echo 'Sorry, this script only works on macOS'
20-
exit 1
21-
fi
18+
function echo-stderr() {
19+
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
20+
}
21+
22+
function fail() {
23+
echo-stderr "$1"
24+
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
25+
}
26+
27+
function check-dependency() {
28+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
29+
fail "Missing dependency: can't find $1 in your PATH"
30+
fi
31+
}
32+
33+
function only-run-on() {
34+
# shellcheck disable=SC2086
35+
if [[ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "$(echo $1 | tr '[:upper:]' '[:lower:]')" ]]; then
36+
fail "This script only runs on $1, this machine is running $(uname -s)"
37+
else
38+
debug "OS ($(uname -s)) is valid..."
39+
fi
40+
}
41+
42+
only-run-on darwin
43+
check-dependency pmset
2244

2345
# Print battery percentage
2446
pmset -g batt | grep -E "([0-9]+\%).*" -o --colour=auto | cut -f1 -d';'

bin/battery-time

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Copyright 2015,2022 Joseph Block <[email protected]>
2+
# Copyright 2015-2025 Joseph Block <[email protected]>
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -15,10 +15,32 @@
1515

1616
set -o pipefail
1717

18-
if [[ "$(uname -s)" != 'Darwin' ]]; then
19-
echo 'Sorry, this script only works on macOS'
20-
exit 1
21-
fi
18+
function echo-stderr() {
19+
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
20+
}
21+
22+
function fail() {
23+
echo-stderr "$1"
24+
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
25+
}
26+
27+
function check-dependency() {
28+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
29+
fail "Missing dependency: can't find $1 in your PATH"
30+
fi
31+
}
32+
33+
function only-run-on() {
34+
# shellcheck disable=SC2086
35+
if [[ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "$(echo $1 | tr '[:upper:]' '[:lower:]')" ]]; then
36+
fail "This script only runs on $1, this machine is running $(uname -s)"
37+
else
38+
debug "OS ($(uname -s)) is valid..."
39+
fi
40+
}
41+
42+
only-run-on darwin
43+
check-dependency pmset
2244

2345
# Print system's estimate of battery time remaining
2446
pmset -g batt | grep -E "([0-9]+\%).*" -o --colour=auto | cut -f3 -d';'

bin/bundle-id

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,35 @@
22
#
33
# Print the bundle ID of an application
44
#
5-
# Copyright 2022, Joe Block <[email protected]>
6-
if [[ "$(uname -s)" != 'Darwin' ]]; then
7-
echo 'Sorry, this script only works on macOS'
8-
exit 1
9-
fi
5+
# Copyright 2022-2025 Joe Block <[email protected]>
6+
#
7+
# License: Apache 2.0
8+
9+
function echo-stderr() {
10+
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
11+
}
12+
13+
function fail() {
14+
echo-stderr "$1"
15+
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
16+
}
17+
18+
function check-dependency() {
19+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
20+
fail "Missing dependency: can't find $1 in your PATH"
21+
fi
22+
}
23+
24+
function only-run-on() {
25+
# shellcheck disable=SC2086
26+
if [[ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "$(echo $1 | tr '[:upper:]' '[:lower:]')" ]]; then
27+
fail "This script only runs on $1, this machine is running $(uname -s)"
28+
else
29+
debug "OS ($(uname -s)) is valid..."
30+
fi
31+
}
32+
33+
only-run-on darwin
34+
check-dependency osascript
1035

1136
exec osascript -e "id of app \"$1\""

bin/change-wallpaper

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
11
#!/bin/bash
22
#
33
# Force wallpaper to switch immediately
4+
#
5+
# Copyright 2016-2025 Joe Block <[email protected]>
46

57
set -e
68

7-
if [[ "$(uname -s)" != 'Darwin' ]]; then
8-
echo 'Sorry, this script only works on macOS'
9-
exit 1
10-
fi
9+
function echo-stderr() {
10+
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
11+
}
12+
13+
function fail() {
14+
echo-stderr "$1"
15+
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
16+
}
17+
18+
function check-dependency() {
19+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
20+
fail "Missing dependency: can't find $1 in your PATH"
21+
fi
22+
}
23+
24+
function only-run-on() {
25+
# shellcheck disable=SC2086
26+
if [[ "$(uname -s | tr '[:upper:]' '[:lower:]')" != "$(echo $1 | tr '[:upper:]' '[:lower:]')" ]]; then
27+
fail "This script only runs on $1, this machine is running $(uname -s)"
28+
else
29+
debug "OS ($(uname -s)) is valid..."
30+
fi
31+
}
32+
33+
only-run-on darwin
34+
check-dependency osascript
1135

1236
exec osascript <<EOF
1337
tell application "System Events"

bin/charger-wattage

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#
33
# Show the wattage of your charger
44
#
5-
# Copyright 2021, Joe Block <[email protected]>
5+
# Copyright 2021-2025, Joe Block <[email protected]>
6+
#
7+
# License: Apache 2.0
68

79
set -o pipefail
810
if [[ -n "$DEBUG" ]]; then
@@ -29,14 +31,20 @@ function charger-wattage() {
2931
pmset -g ac | awk '/Wattage/ {print $3}'
3032
}
3133

32-
if [[ "$(uname -s)" != 'Darwin' ]]; then
33-
echo 'Sorry, this script only works on macOS'
34-
exit 1
35-
fi
34+
function only-run-on() {
35+
if [[ "$(uname -s)" != "$1" ]]; then
36+
echo "This script only runs on $1"
37+
exit 1
38+
fi
39+
}
3640

37-
if has pmset; then
38-
charger-wattage
39-
else
40-
# shellcheck disable=SC2016
41-
fail 'Cannot find pmset in your $PATH'
42-
fi
41+
function check-dependency() {
42+
if ! (builtin command -V "$1" >/dev/null 2>&1); then
43+
fail "Missing dependency: can't find $1 in your PATH"
44+
fi
45+
}
46+
47+
only-run-on Darwin
48+
check-dependency pmset
49+
50+
charger-wattage

0 commit comments

Comments
 (0)