Flash windows icon when various scripts finish running

This commit is contained in:
Michael Campagnaro 2026-02-24 18:06:49 -05:00
parent bade7f762a
commit e009688aa0
14 changed files with 93 additions and 7 deletions

View File

@ -41,7 +41,7 @@ reload() {
} }
update-shell() { update-shell() {
if [[ '${platform,,}' == *'ming'* ]]; then if [[ ${platform,,} == *'ming'* ]]; then
pacman -Syu pacman -Syu
printf "\n${BOLD}${YELLOW}Close this shell, open a new one, and then run 'pacman -Su'${NORMAL}\n" printf "\n${BOLD}${YELLOW}Close this shell, open a new one, and then run 'pacman -Su'${NORMAL}\n"
fi fi
@ -148,6 +148,30 @@ remove_extra_spaces() {
echo "$ret" echo "$ret"
} }
flash_taskbar() {
if [[ ${platform,,} == *'ming'* ]]; then
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "
\$h = (Get-Process mintty -EA SilentlyContinue | ? MainWindowHandle | select -First 1).MainWindowHandle
if (-not \$h) { exit }
Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices;
public static class F {
[StructLayout(LayoutKind.Sequential)] public struct I { public uint cb; public IntPtr h; public uint f; public uint c; public uint t; }
[DllImport(\"user32.dll\")] public static extern bool FlashWindowEx(ref I i);
}'
\$i = New-Object F+I
\$i.cb = [Runtime.InteropServices.Marshal]::SizeOf(\$i)
\$i.h = [IntPtr]\$h
\$i.f = 2 -bor 12
\$i.c = 0
\$i.t = 0
[F]::FlashWindowEx([ref]\$i) | Out-Null
"
else
echo "flash_taskbar not implemented for this platform"
fi
}
################## ##################
# Building code # Building code
################## ##################
@ -198,7 +222,7 @@ if [[ $platform == 'Darwin' ]]; then
alias trash='rmtrash' alias trash='rmtrash'
alias tt='rmtrash' alias tt='rmtrash'
elif [[ "${platform,,}" == *'ming'* ]]; then # convert to lowercase then compare with wildcard elif [[ ${platform,,} == *'ming'* ]]; then # convert to lowercase then compare with wildcard
#alias rm='echo "use trash command instead!"' #alias rm='echo "use trash command instead!"'
#alias rmr='echo "use trash command instead!"' #alias rmr='echo "use trash command instead!"'
alias trash='remove_windows_file' alias trash='remove_windows_file'
@ -226,7 +250,7 @@ mkcd() {
alias aliases='vim ~/.aliases' alias aliases='vim ~/.aliases'
alias al='aliases' alias al='aliases'
if [[ "${platform,,}" == *'ming'* ]]; then if [[ ${platform,,} == *'ming'* ]]; then
_checksum() { _checksum() {
local algo="$1" local algo="$1"
local file="$2" local file="$2"
@ -412,6 +436,7 @@ function my_transcribe_video() {
else else
transcribe-video "$file" "$output" $start_time $end_time tiny base transcribe-video "$file" "$output" $start_time $end_time tiny base
fi fi
flash_taskbar
} }
function my_transcribe_video_all_models() { function my_transcribe_video_all_models() {
@ -433,6 +458,7 @@ function my_transcribe_video_all_models() {
if [[ $end_time == "" ]]; then end_time="0"; fi if [[ $end_time == "" ]]; then end_time="0"; fi
transcribe-video "$file" "$output" $start_time $end_time tiny base small medium transcribe-video "$file" "$output" $start_time $end_time tiny base small medium
flash_taskbar
} }
@ -509,6 +535,7 @@ download_youtube_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
@ -555,6 +582,7 @@ download_youtube_playlist() {
cd .. cd ..
printf "${BOLD}Finished downloading the playlist\n${NORMAL}" printf "${BOLD}Finished downloading the playlist\n${NORMAL}"
flash_taskbar
} }
download_youtube_playlist_list() { download_youtube_playlist_list() {
@ -574,6 +602,7 @@ download_youtube_playlist_list() {
eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string.
printf "${BOLD}Finished downloading the playlist video list\n${NORMAL}" printf "${BOLD}Finished downloading the playlist video list\n${NORMAL}"
flash_taskbar
} }
download_youtube_uploads_list() { download_youtube_uploads_list() {
@ -602,6 +631,7 @@ download_youtube_uploads_list() {
eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string. eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string.
printf "${BOLD}Finished downloading the upload list\n${NORMAL}" printf "${BOLD}Finished downloading the upload list\n${NORMAL}"
flash_taskbar
} }
function download_youtube_audio() { function download_youtube_audio() {
@ -646,6 +676,7 @@ function download_youtube_audio() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Twitch chat transcript # Download Twitch chat transcript
@ -699,9 +730,13 @@ download_twitch_chat() {
# To extract a portion of a video, you have to first download the entire file and then use the # To extract a portion of a video, you have to first download the entire file and then use the
# `trim-video` or `compress-video' with a time range. # `trim-video` or `compress-video' with a time range.
# #
# To download a portion of a stream: # To download a partial stream use one of these commands. We need to reencode to remove extra frames from the start/end with a negative timeline.
# #
# yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 5:25:38.00 -to 5:56:50.00" URL # This reencodes during the download, slightly faster than the next option:
# yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 0:7:10.00 -to 0:8:06.00" --external-downloader-args "ffmpeg_o:-c:v libx264 -c:a aac" URL
#
# Download then re-encode:
# yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 5:25:38.00 -to 5:56:50.00" URL -o temp.mp4 ; trim-video-cpu temp.mp4 "FINAL_NAME" 0
# #
download_twitch_vid() { download_twitch_vid() {
local format="$1" local format="$1"
@ -812,6 +847,7 @@ download_twitch_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Vimeo videos. # Download Vimeo videos.
@ -898,6 +934,7 @@ download_vimeo_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Twitter videos. # Download Twitter videos.
@ -966,9 +1003,12 @@ download_twitter_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download Instagram videos. # Download Instagram videos.
# If the download fails because you need to be authenticated then don't use the cookies arg because IG will flag your
# account as a bot and might ban you. Instead, use the instagram download code from private dotfiles.
download_instagram_vid() { download_instagram_vid() {
local transcribe="$1" local transcribe="$1"
local make_folder="$2" local make_folder="$2"
@ -1037,6 +1077,7 @@ download_instagram_vid() {
if [[ $make_folder == "1" ]]; then cd ..; fi if [[ $make_folder == "1" ]]; then cd ..; fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Download MP4 video. # Download MP4 video.
@ -1060,6 +1101,7 @@ download_mp4() {
fi fi
mv $temp_name "$filename.mp4" mv $temp_name "$filename.mp4"
flash_taskbar
} }
# Download a stream to mp4. Can be from an m3u8 file, an mpd, etc. Whatever the # Download a stream to mp4. Can be from an m3u8 file, an mpd, etc. Whatever the
@ -1096,6 +1138,7 @@ download_mp4_from_stream() {
fi fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
# Same notes from above regarding cookies/headers. # Same notes from above regarding cookies/headers.
@ -1117,6 +1160,7 @@ download_aac_from_stream() {
fi fi
printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n"
flash_taskbar
} }
@ -1293,7 +1337,7 @@ function compress_and_normalize_volume() {
error "Provide a final file name and optional args for compress-video" error "Provide a final file name and optional args for compress-video"
return return
fi fi
compress-video f.mp4 ff $opts ; normalize-volume ff.mp4 "$final_name" compress-video f.mp4 ff $opts ; normalize-volume ff.mp4 "$final_name" ; flash_taskbar
} }
alias cvn='compress_and_normalize_volume' alias cvn='compress_and_normalize_volume'
@ -1302,7 +1346,7 @@ alias cvn='compress_and_normalize_volume'
# Git # Git
#################################################################################################### ####################################################################################################
if [[ '${platform,,}' == *'ming'* ]]; then if [[ ${platform,,} == *'ming'* ]]; then
# Fix a weird mingw 'not a valid identifierline' error. # Fix a weird mingw 'not a valid identifierline' error.
# Got the fix from https://github.com/Alexpux/MSYS2-packages/issues/735#issuecomment-328938800 # Got the fix from https://github.com/Alexpux/MSYS2-packages/issues/735#issuecomment-328938800
alias git="PATH=/usr/bin git" alias git="PATH=/usr/bin git"

View File

@ -10,6 +10,8 @@
# #
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -50,3 +52,4 @@ eval $cmd
printf "\n${GREEN}${BOLD}Done analyzing audio in $filename\n${NORMAL}" printf "\n${GREEN}${BOLD}Done analyzing audio in $filename\n${NORMAL}"
printf "\n${YELLOW}${BOLD}Look at the reported max_volume value. If != 0 then call the change-volume script, passing it the filename, an output name and the delta to bring the volume to 0.\ne.g. if the max_volume is -5 db, then you would pass 5.${NORMAL}\n\n" printf "\n${YELLOW}${BOLD}Look at the reported max_volume value. If != 0 then call the change-volume script, passing it the filename, an output name and the delta to bring the volume to 0.\ne.g. if the max_volume is -5 db, then you would pass 5.${NORMAL}\n\n"
flash_taskbar

View File

@ -7,6 +7,8 @@
# #
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -57,3 +59,4 @@ eval $cmd
printf "\n${GREEN}${BOLD}Done modifying volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n" printf "\n${GREEN}${BOLD}Done modifying volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n"
flash_taskbar

View File

@ -2,6 +2,8 @@
# Bigger crf values == bigger compression. # Bigger crf values == bigger compression.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -49,3 +51,5 @@ fi
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5 compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5
flash_taskbar

View File

@ -2,6 +2,8 @@
# Bigger crf values == bigger compression. # Bigger crf values == bigger compression.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -95,3 +97,5 @@ else
encode $crf encode $crf
done done
fi fi
flash_taskbar

View File

@ -3,6 +3,8 @@
# This is for reencoding a non-mp4 video to mp4 using an mpeg4 encoder. # This is for reencoding a non-mp4 video to mp4 using an mpeg4 encoder.
# Can optionally compress the video. # Can optionally compress the video.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -94,3 +96,5 @@ else
fi fi
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n" printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n"
flash_taskbar

View File

@ -3,6 +3,8 @@
# Re-encodes the video to get a more accurate timeline. Same settings as trim-video-vbr. # Re-encodes the video to get a more accurate timeline. Same settings as trim-video-vbr.
# If you want fast video joining at the expense of accuracy then use join-video-fast. # If you want fast video joining at the expense of accuracy then use join-video-fast.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -64,3 +66,4 @@ time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
flash_taskbar

View File

@ -5,6 +5,8 @@
# playback time might oscillate a bit. Use join-video for accurate joining at # playback time might oscillate a bit. Use join-video for accurate joining at
# the cost of a much slower processing time. # the cost of a much slower processing time.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -44,3 +46,4 @@ ffmpeg -y -stats -loglevel level+error -f concat -safe 0 -i "$filename" -c copy
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
flash_taskbar

View File

@ -10,6 +10,8 @@
# #
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -78,3 +80,4 @@ eval "$cmd"
printf "\n${GREEN}${BOLD}Done normalizing volume in $filename.$extension | output: $output${NORMAL}\n" printf "\n${GREEN}${BOLD}Done normalizing volume in $filename.$extension | output: $output${NORMAL}\n"
rm $temp_file rm $temp_file
flash_taskbar

View File

@ -2,6 +2,8 @@
# Re-encodes the audio to get a more accurate seek time. # Re-encodes the audio to get a more accurate seek time.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -58,3 +60,4 @@ ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@ -2,6 +2,8 @@
# Re-encodes the video to get a more accurate seek time. If you want fast trimming at the expense of accuracy then use trim-video-fast. # Re-encodes the video to get a more accurate seek time. If you want fast trimming at the expense of accuracy then use trim-video-fast.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -62,3 +64,4 @@ ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -async 1 -i "
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@ -5,6 +5,8 @@
# time might oscillate a bit. Use trim-video for accurate trimming at the cost # time might oscillate a bit. Use trim-video for accurate trimming at the cost
# of a much slower processing time. # of a much slower processing time.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -64,3 +66,4 @@ ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@ -3,6 +3,8 @@
# Re-encodes the video using a constrained bitrate/output size. If you want to # Re-encodes the video using a constrained bitrate/output size. If you want to
# control the visual quality with a variable bitrate then use trim-video-vbr # control the visual quality with a variable bitrate then use trim-video-vbr
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -90,3 +92,4 @@ ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar

View File

@ -7,6 +7,8 @@
# #
# The higher the CRF value, the higher the compression. # The higher the CRF value, the higher the compression.
source "$HOME/dotfiles/script_helpers/windows.sh"
if which tput >/dev/null 2>&1; then if which tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors)
fi fi
@ -124,3 +126,4 @@ time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
flash_taskbar