mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 13:03:13 +02:00
fix(linux_configuration): sync music_parallelism.sh from live and detoxify organize_downloads.sh
- music_parallelism.sh: restore batched-pgrep/xdotool optimization that exists
in /usr/local/bin/ but had been lost from the repo, plus bump intervals
(FAST 0.5s->2s, IDLE 3s->10s) to further cut fork rate
- organize_downloads.sh: replace per-file tr fork with bash 4 ${var,,}
parameter expansion, replace per-log-line $(date) fork with printf %()T builtin
Follow-up to fork-storm fixes after observing 122 CPU-hours of date calls
in a 90-minute window (root cause was nvidia-pmon-logger.sh, fixed separately).
This commit is contained in:
parent
f84135f6d7
commit
b6768218f3
@ -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
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user