diff --git a/linux_configuration/scripts/digital_wellbeing/music_parallelism.sh b/linux_configuration/scripts/digital_wellbeing/music_parallelism.sh index dd5eca7..4c05131 100755 --- a/linux_configuration/scripts/digital_wellbeing/music_parallelism.sh +++ b/linux_configuration/scripts/digital_wellbeing/music_parallelism.sh @@ -27,7 +27,8 @@ LOG_DIR="${XDG_STATE_HOME:-$HOME/.local/state}/music-parallelism" mkdir -p "$LOG_DIR" 2> /dev/null || true export LOG_FILE="$LOG_DIR/music-parallelism.log" CHECK_INTERVAL=3 -FAST_CHECK_INTERVAL=0.5 +FAST_CHECK_INTERVAL=2 +IDLE_CHECK_INTERVAL=10 # Override focus apps with extended list for this script FOCUS_APPS_WINDOWS=( @@ -223,7 +224,7 @@ instant_monitor_loop() { sleep "$FAST_CHECK_INTERVAL" # High-frequency check while focus app is active else # No focus app detected: use longer sleep to reduce fork overhead significantly - sleep 3 + sleep "$IDLE_CHECK_INTERVAL" fi done } diff --git a/linux_configuration/scripts/utils/organize_downloads.sh b/linux_configuration/scripts/utils/organize_downloads.sh index 3050426..4b398cb 100755 --- a/linux_configuration/scripts/utils/organize_downloads.sh +++ b/linux_configuration/scripts/utils/organize_downloads.sh @@ -37,9 +37,11 @@ TEMP_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/media_organize_$$" IMAGE_EXTENSIONS=("jpg" "jpeg" "png" "gif" "bmp" "tiff" "tif" "webp" "raw" "cr2" "nef" "orf" "arw" "dng" "heic" "heif") VIDEO_EXTENSIONS=("mp4" "avi" "mkv" "mov" "wmv" "flv" "webm" "m4v" "3gp" "ogv" "mpg" "mpeg" "mts" "m2ts" "vob") -# Function to log messages with timestamp +# Function to log messages with timestamp (bash builtin %()T = zero forks) log() { - echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" + local ts + printf -v ts '%(%Y-%m-%d %H:%M:%S)T' -1 + echo "[$ts] $1" } # Parse CLI flags early @@ -65,11 +67,11 @@ while [[ ${1:-} =~ ^- ]]; do esac done -# Function to check if file has media extension +# Function to check if file has media extension (zero forks: bash 4 ${var,,}) is_media_file() { local file="$1" local extension="${file##*.}" - extension=$(echo "$extension" | tr '[:upper:]' '[:lower:]') + extension="${extension,,}" # Check if it's an image for ext in "${IMAGE_EXTENSIONS[@]}"; do