mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-20 14:12:19 +01:00
Created scripts/lib/common.sh with shared functions: - log_message(), log() - consistent logging with timestamps - require_root() - root privilege checking with optional sudo re-exec - get_actual_user(), get_actual_user_home() - handle SUDO_USER properly - parse_interactive_args() - standard --interactive/-i and --help/-h handling - notify() - cross-platform desktop notifications - require_command(), ensure_dir() - common utility functions - enable_service(), is_service_active() - systemd helpers Refactored scripts to use common library: - block_compulsive_opening.sh - setup_pc_startup_monitor.sh - setup_periodic_system.sh - setup_thorium_startup.sh - nvidia_troubleshoot.sh - hosts/guard/setup_hosts_guard.sh - hosts/guard/enforce-hosts.sh Merged duplicate scripts: - Created convert_video.sh (combined to_mp4.sh and to_webm.sh) - Removed pdf_to_png.sh (was identical to pdf_to_image.sh) Reduced duplication from 4.08% (48 clones) to 1.86% (26 clones)
23 lines
720 B
Bash
23 lines
720 B
Bash
#!/bin/bash
|
|
# YouTube Music Wrapper - Blocks launch when focus apps are running
|
|
# This replaces the actual youtube-music binary
|
|
|
|
set -euo pipefail
|
|
|
|
# Source common library for shared functions
|
|
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
|
source "$SCRIPT_DIR/../lib/common.sh"
|
|
|
|
REAL_BINARY="/opt/YouTube Music/youtube-music.real"
|
|
LOG_FILE="${XDG_STATE_HOME:-$HOME/.local/state}/music-parallelism/music-parallelism.log"
|
|
|
|
# Main
|
|
if focus_app=$(is_focus_app_running); then
|
|
log_message "BLOCKED: YouTube Music launch prevented (focus app: $focus_app)" "$LOG_FILE"
|
|
notify "🚫 YouTube Music Blocked" "Focus mode active ($focus_app)" normal 3000
|
|
exit 1
|
|
fi
|
|
|
|
# No focus app running, launch normally
|
|
exec "$REAL_BINARY" "$@"
|