-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_rest_env.sh
More file actions
executable file
·47 lines (41 loc) · 1.66 KB
/
Copy pathsetup_rest_env.sh
File metadata and controls
executable file
·47 lines (41 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Setup a quiet, comfortable rest environment on macOS
# Reduce screen brightness, lower system volume, enable Do Not Disturb, and optionally start a soothing audio.
# Helper: log
log() {
echo "[setup_rest_env] $1"
}
# 1. Dim screen brightness (requires 'brightness' utility: https://github.com/nriley/brightness)
if command -v brightness >/dev/null 2>&1; then
TARGET_BRIGHTNESS=0.3 # 0.0 (dark) to 1.0 (full)
log "Setting screen brightness to $TARGET_BRIGHTNESS"
brightness $TARGET_BRIGHTNESS
else
log "'brightness' utility not found. Skipping brightness adjustment."
log "You can install it via Homebrew: brew install brightness"
fi
# 2. Lower system volume to a quiet level (0-100)
TARGET_VOLUME=20
log "Setting system volume to $TARGET_VOLUME%"
osascript -e "set volume output volume $TARGET_VOLUME"
# 3. Enable Do Not Disturb (macOS 12+ uses Focus)
log "Enabling Do Not Disturb (Focus)"
# Using AppleScript to toggle Do Not Disturb for 1 hour
osascript -e "tell application \"System Events\"
tell appearance preferences
set dark mode to true
end tell
end tell"
# For macOS Monterey and later, we can use defaults + kill
/usr/bin/defaults write ~/Library/Preferences/com.apple.ncprefs.plist dndEnabled -bool true
killall NotificationCenter 2>/dev/null || true
# 4. Optionally start a soothing audio (e.g., from iTunes/Music)
# Uncomment and set your preferred audio file or playlist.
# AUDIO_FILE="/System/Library/Sounds/Submarine.aiff"
# if [[ -f "$AUDIO_FILE" ]]; then
# afplay "$AUDIO_FILE" &
# log "Playing soothing sound $AUDIO_FILE"
# else
# log "Audio file not found, skipping sound playback."
# fi
log "Rest environment setup complete."