# Useful and "Use Less" Scripts

**URL:** <https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327>\
**Category:** Community contributions\
**Created:** [October 4, 2024, 6:44pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327 "2024-10-04T18:44:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 4, 2024, 6:44pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/1 "2024-10-04T18:44:50Z")

</div>

A collection of scripts I’ve created that are _ **useful** _ to me, while also allowing me to _ **use less** _ additional packages by leveraging what’s pre-installed with many Linux distros.

The scripts work on _ **MY** _ system and are provided _ **AS-IS** _.

I made them to be modifiable and usable on any Arch-based distro, but most work out-of-the-box on non-Arch distros. Ultimately, they can be modified and used in whatever way you see fit for your system.

```auto
"Happy Scripting!"

```

🧑‍💻 ✍

* * *

## Scripts

> **Wallpaper Changer**
>
> If you are like me, you may have a folder filled with wallpapers, and you like when your wallpapers change throughout the day, in this case, every 60 seconds.
> 
> Here’s a bash script which does this using `feh`:
> 
> ```auto
> #!/bin/bash
> 
> while true; do
> feh --randomize --bg-fill /path/to/wallpaper/directory &
> sleep 60
> 
> done
> 
> ```

> **Open Links in FreeTube (X11)**
>
> This was created based on [another thread](https://forum.endeavouros.com/t/automatic-opening-youtube-links-in-freetube/58367). But basically, if you copy a YouTube link, and you have FreeTube installed, this script will open the link in FreeTube.
> 
> ```auto
> #!/bin/bash
> 
> # Specify the application to open links
> APP="/path/to/freetube"
> 
> # Create an associative array to track opened links
> declare -A opened_links
> 
> # Function to open the link
> open_link() {
> local link="$1"
> if [[-z "${opened_links[$link]}" ]]; then
> opened_links[$link]=1
> $APP "$link" &
> fi
> }
> 
> # Monitor the clipboard for YouTube links
> monitor_clipboard() {
> local last_clipboard=""
> while true; do
> current_clipboard=$(xclip -o -selection clipboard)
> if [["$current_clipboard" != "$last_clipboard"]]; then
> if [["$current_clipboard" =~ ^(https?://)?(www\.)?(youtube\.com|youtu\.be)/]]; then
> open_link "$current_clipboard"
> fi
> last_clipboard="$current_clipboard"
> fi
> sleep 1
> done
> }
> 
> # Start monitoring
> monitor_clipboard &
> 
> ```

> **Open Links in FreeTube (Wayland)**
>
> Full instructions for Wayland can be found here:
> 
> > [@Automatic Opening YouTube Links in FreeTube](https://forum.endeavouros.com/t/automatic-opening-youtube-links-in-freetube/58367/5):
> >
> > As for Wayland… I could test this, I won’t. That said, the instructions below may work. Disclaimer: I understood and tested the X11 version and it works. Test the below version at your own “risk” after reading it and trying to understand it. There are explanations anyway. Create the Bash Script: This script will check if the URL is a YouTube link and then open it with the specified application. #!/bin/bash # Define the application you want to use, e.g., mpv APP="mpv" # Function to open …

> **Open Links in MPV**
>
> This is the MPV equivalent to the FreeTube version. It uses xclip, so it’s likely not gonna work in Wayland. If there are other streaming services that you watch, you can add them to the list by following the YouTube link formats in the script.
> 
> ```auto
> #!/bin/bash
> 
> # Function to open the link in mpv
> ## Change 1080 to a higher or lower resolution based on your needs
> open_link() {
> local link="$1"
> if [[-z "${opened_links[$link]}" ]]; then
> opened_links[$link]=1
> mpv --ytdl-format="bestvideo[height<=?1080]+bestaudio/best" "$link" &
> fi
> }
> 
> # Create an associative array to track opened links
> declare -A opened_links
> 
> # Monitor the clipboard for YouTube links
> monitor_clipboard() {
> local last_clipboard=""
> while true; do
> current_clipboard=$(xclip -o -selection clipboard)
> if [["$current_clipboard" != "$last_clipboard"]]; then
> if [["$current_clipboard" =~ ^(https?://)?(www\.)?(youtube\.com|youtu\.be)/]]; then
> open_link "$current_clipboard"
> fi
> last_clipboard="$current_clipboard"
> fi
> sleep 1
> done
> }
> 
> # Start monitoring
> monitor_clipboard &
> 
> ```

> **Update Notifier (that you don't need, but I digress)**
>
> What it does:
> 
> - Checks the Arch and AUR repos for updates using `checkupdates && yay -Qua`.
> - If updates are available (there will be), a notification is sent using `notify-send`.
> - If the user clicks it, it launches a terminal and begins the update.
> 
> Note that `yay -Qua` currently returns the same result as `yay -Qu`.  
> The check is done every 6 hours, but you can change it to a frequency you prefer.
> 
> ~~Note: It uses `paru` instead of `yay` to check AUR updates because `yay` doesn’t seem to have a command that does this without also attempting to update.~~
> 
> ```auto
> #!/bin/bash
> 
> # Function to check for updates and send notification
> check_updates() {
> updates=$(checkupdates && yay -Qua)
> 
> if [-n "$updates"]; then
> notify-send -t 60000 -a "System Updates" "Updates Available" "Click to update in your terminal" -A "Update"
> 
> if [$? -eq 0]; then
> # Notification was clicked, launch alacritty and run pacman and yay
> alacritty -H -e "bash -c 'sudo pacman -Syu && yay -Sua; echo; read -p \"Press Enter to close this window...\"'"
> fi
> fi
> }
> 
> # Main loop
> while true; do
> check_updates
> sleep 6h
> done
> 
> ```

> **Periodic Reminder**
>
> Having trouble remembering to do something, like eating, taking a break, checking your to-do list? Here’s a generic reminder to help with that.
> 
> This simply uses `notify-send` to remind you every hour.
> 
> ```auto
> #!/bin/bash
> 
> # Default heading and body
> HEADING="Tasks Reminder"
> BODY="Check your schedule and TO-DOs."
> 
> # Check if custom heading and body are provided as arguments
> if [$# -eq 2]; then
> HEADING="$1"
> BODY="$2"
> fi
> 
> # Function to send notification
> send_notification() {
> notify-send --urgency=critical "$HEADING" "$BODY"
> }
> 
> # Infinite loop to send notifications every hour
> while true; do
> CURRENT_MINUTE=$(date +%M)
> 
> # Wait until the start of the next hour
> sleep $(( (60 - CURRENT_MINUTE) * 60 ))
> 
> send_notification
> done
> 
> ```

> **Weekly or Daily Reminder at a Specified Time of Day**
>
> Sometimes I find myself forgetting that I have one more thing to do before the work day is done. So, in order to ensure I do that final task, I have a specific reminder that has lots of text, so I can’t miss it, which makes it so that I am reminded to do the task. It’s a very “in your face” reminder, since I use `dunst` as my notification daemon — this makes the reminder appear bigger than what I’d get with a DE-specific daemon.
> 
> This simply uses `notify-send` to remind you at specific times, like 17:55.
> 
> ```auto
> #!/bin/bash
> 
> # Configuration
> HEADING="Lesson Reminder"
> BODY="REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER REMINDER"
> 
> # Days to run the script (1=Monday, 7=Sunday)
> ACTIVE_DAYS=(1 2 3 4 5) # Monday to Friday
> 
> # Notification times in HH:MM format
> NOTIFICATION_TIMES=("16:00" "17:00" "17:30" "17:55")
> 
> # Function to send notification
> send_notification() {
> notify-send --urgency=critical "$HEADING" "$BODY"
> }
> 
> # Function to check if the current day is in the active days list
> is_active_day() {
> local current_day=$1
> for day in "${ACTIVE_DAYS[@]}"; do
> if ["$current_day" -eq "$day"]; then
> return 0 # True
> fi
> done
> return 1 # False
> }
> 
> # Main loop
> while true; do
> CURRENT_DAY=$(date +%u) # Get current day of the week (1=Monday, 7=Sunday)
> CURRENT_TIME=$(date +%H:%M) # Get current time in HH:MM format
> 
> if is_active_day "$CURRENT_DAY"; then
> for TIME in "${NOTIFICATION_TIMES[@]}"; do
> if ["$CURRENT_TIME" == "$TIME"]; then
> send_notification
> sleep 60 # Sleep for 60 seconds to avoid multiple notifications
> break
> fi
> done
> fi
> 
> sleep 30 # Sleep for 30 seconds before checking again
> done
> 
> ```

> **Capture Video Frames from a Specific Video**
>
> Because I sometimes do animation practice, I find myself opening a video in `mpv` then running the capture every frame command. However, sometimes this slows down my system and I don’t ever actually want every frame. So instead, I’ve created a script that captures every fourth frame. Of course, if you find it useful, you can change how often it captures frames.
> 
> Here’s a bash script which does this using `ffmpeg`. In order to use it, open a terminal in the directory with the video file, then type the name of the script followed by the name of the video file like so “`./cap_x_frames example_video.mp4`”.
> 
> I will probably convert this to a Nemo action, because this isn’t necessarily more efficient than using the `ffmpeg` command directly.  
> But for now..
> 
> ```auto
> #!/bin/bash
> 
> # Set the number of frames to skip
> frames_to_skip=4
> 
> # Specify the output directory here
> output_dir="/path/to/output/directory"
> 
> # Check if the video file is provided
> if ["$#" -ne 1]; then
> echo "Usage: $0 video_file"
> exit 1
> fi
> 
> video_file="$1"
> 
> # Create output directory
> mkdir -p "$output_dir"
> 
> # Get the total number of frames, frame rate, and video resolution using ffprobe
> video_info=$(ffprobe -v error -select_streams v:0 -count_frames -show_entries stream=nb_read_frames,r_frame_rate,width,height -of csv=p=0 "$video_file")
> IFS=',' read -r total_frames frame_rate width height <<< "$video_info"
> 
> # Extract the integer part of total_frames
> total_frames=$(echo "$total_frames" | bc)
> 
> # Check if total_frames was found
> if [-z "$total_frames"] || ! [["$total_frames" =~ ^[0-9]+$ ]]; then
> echo "Could not determine the total number of frames. Please check the video file."
> exit 1
> fi
> 
> # Convert fractional frame rate to a single number
> frame_rate=$(echo "$frame_rate" | bc)
> 
> echo "Total frames: $total_frames"
> echo "Frame rate: $frame_rate"
> echo "Video resolution: ${width}x${height}"
> 
> # Calculate the time interval between screenshots
> interval=$(bc <<< "scale=6; $frames_to_skip / $frame_rate")
> 
> # Take screenshots at original resolution
> ffmpeg -i "$video_file" -vf "select='not(mod(n,$frames_to_skip))'" -vsync vfr "$output_dir/frame_%d.png"
> 
> echo "Screenshots taken and saved in $output_dir"
> 
> ```

> **Unison Sync Operations + Fish Alias**
>
> This script is kind of redundant, but I created it anyway. It runs Unison in a terminal and runs one-way syncs from one folder to the next based on user specified folders in the script. It is coupled with a Fish alias “`uni $argv`”, where “$argv” is a short name for a directory, like the ones below.
> 
> Again, this is redundant because unison can do this via commandline on its own, but I find it useful the same way I find `yay` or `paru` useful. - Yes `pacman` can do it, but the helpers “feel” better.
> 
> Anyway, create a Bash script, “unison.sh” and make it executable:
> 
> ```auto
> #!/bin/bash
> 
> # Unison one-way sync script (root1 to root2)
> # This script performs one-way synchronization from a source directory (root1)
> # to a destination directory (root2) using Unison.
> # This is useful for backup syncs only.
> # Use it in a terminal in conjunction with an alias like "uni $argv",
> # where "$argv" is a short name for a directory, like the ones below.
> 
> # Function to run unison with common options for one-way sync
> run_unison_oneway() { unison "$1" "$2" -batch -auto -times -perms 0 -force "$1" -ignore "Path .DS_Store" -ignore "Path Thumbs.db"; }
> 
> # Sync operations
> # This case statement allows for easy addition of new sync profiles
> case "$1" in
> "ff-wu")
> # Sync Firefox profile
> run_unison_oneway "/home/user/.mozilla/firefox" "/mnt/backup/firefox"
> ;;
> "docs")
> # Sync Documents folder
> run_unison_oneway "/home/user/Documents" "/mnt/backup/Documents"
> ;;
> "pics")
> # Sync Pictures folder
> run_unison_oneway "/home/user/Pictures" "/mnt/external/Photos/"
> ;;
> "code")
> # Sync code projects
> run_unison_oneway "/home/user/Projects" "/mnt/backup/Code"
> ;;
> "music")
> # Sync Music folder
> run_unison_oneway "/home/user/Music" "/mnt/nas/Music/"
> ;;
> *)
> # Display usage information if an invalid option is provided
> echo "Usage: $0 {ff-wu|docs|pics|code|music}"
> exit 1
> ;;
> esac
> 
> # Inform the user that the sync operation has completed
> echo "One-way sync completed for $1 (root1 to root2)"
> 
> ```
> 
> Then, create an alias/function in Fish:
> 
> ```auto
> ### Function to run Unison sync operations
> function uni
> path/to/script/unison.sh $argv
> end
> 
> ```

* * *

* * *

## Nemo Actions

> **Convert to MP3**
>
> Got a video file that doesn’t need to be a video anymore? Convert it to MP3.
> 
> Here’s a nemo action which does this using `ffmpeg`:
> 
> Create a file called something like “convert2mp3.sh”.
> 
> ```auto
> #!/bin/bash
> for file in "$@"; do
> ffmpeg -i "$file" -vn -acodec libmp3lame -q:a 0 "${file%.*}.mp3"
> done
> 
> ```
> 
> Create another file called something like “convert2mp3.nemo\_action” but make sure to place it in `~/local/share/nemo/actions`.
> 
> ```auto
> [Nemo Action]
> Name=Convert to MP3
> Comment=Convert video file to MP3
> Exec=/path/to/script/convert2mp3.sh %F
> Icon-Name=audio-x-generic
> Selection=any
> Extensions=mp4;avi;webm;mkv;mov;wmv;flv;f4v;
> 
> ```
> 
> Note: For whatever reason, the script may need to “warm up” before actually working, so you may need to run the action once to “warm it up”, and a second time to actually convert the file. It’s weird.

> **Convert to FLAC**
>
> Got a video file that doesn’t need to be a video anymore? Convert it to FLAC.
> 
> Here’s a nemo action which does this using `ffmpeg`:
> 
> Create a file called something like “convert2flac.sh”.
> 
> ```auto
> #!/bin/bash
> for file in "$@"; do
> ffmpeg -i "$file" -vn -c:a flac -compression_level 12 "${file%.*}.flac"
> done
> 
> ```
> 
> Create another file called something like “convert2flac.nemo\_action” but make sure to place it in `~/local/share/nemo/actions`.
> 
> ```auto
> [Nemo Action]
> Name=Convert to FLAC
> Comment=Convert video file to FLAC
> Exec=/path/to/script/convert2flac.sh %F
> Icon-Name=audio-x-generic
> Selection=any
> Extensions=mp4;avi;webm;mkv;mov;wmv;flv;f4v;
> 
> ```

> **Convert to JPEG**
>
> Got a WEBP image, but prefer JPEGs, use this script. That said, it works on other common image types specific in the Nemo action, like raw and hi-def image types.
> 
> Create a file called something like “convert2JPEG.sh”.
> 
> ```auto
> #!/bin/bash
> 
> # Check if ImageMagick is installed
> if ! command -v convert &> /dev/null; then
> notify-send "Error" "ImageMagick is not installed. Please install it first."
> exit 1
> fi
> 
> # Function to generate unique filename
> generate_unique_filename() {
> local base_name="${1%.*}"
> local extension="${1##*.}"
> local counter=1
> local new_name="$base_name.jpg"
> 
> while [-e "$new_name"]; do
> new_name="${base_name}_$(printf "%03d" $counter).jpg"
> ((counter++))
> done
> 
> echo "$new_name"
> }
> 
> # Convert images to JPEG
> converted_count=0
> for file in "$@"; do
> if [-f "$file"]; then
> output_file=$(generate_unique_filename "$file")
> if convert "$file" -quality 90 "$output_file"; then
> ((converted_count++))
> fi
> fi
> done
> 
> # Notify user of conversion result
> if [$converted_count -eq 0]; then
> notify-send "Conversion Failed" "No images were converted to JPEG."
> elif [$converted_count -eq 1]; then
> notify-send "Conversion Successful" "1 image was converted to JPEG."
> else
> notify-send "Conversion Successful" "$converted_count images were converted to JPEG."
> fi
> 
> ```
> 
> Create another file called something like “convert2JPEG.nemo\_action” but make sure to place it in `~/local/share/nemo/actions`.
> 
> ```auto
> [Nemo Action]
> Name=Convert to JPEG
> Comment=Convert selected images to jpeg format
> Exec=/path/to/convert2jpeg.sh %F
> Icon-Name=image-x-generic
> Selection=any
> Extensions=jpg;jpeg;bmp;tiff;webp;heic;heif;svg;nef;
> 
> ```

> **Convert to DOCX**
>
> I’ve been using Obsidian more often, which means more Markdown files. However, the people I work with need DOCX files for review purposes. As they don’t actually want to edit the files, I don’t need to worry too much about formatting, so `pandoc` does what I need.
> 
> I will probably try to find a way to ensure the conversion comes out better, but this is okay for them at the moment.
> 
> Create a script called “convert2docx.sh”.
> 
> ```auto
> #!/bin/bash
> 
> # Check if a file is passed as an argument
> if [-z "$1"]; then
> echo "No file provided."
> exit 1
> fi
> 
> # Get the input file and output file names
> input_file="$1"
> output_file="${input_file%.md}.docx"
> 
> # Convert Markdown to DOCX using Pandoc
> pandoc -s -o "$output_file" "$input_file"
> 
> # Notify the user of completion
> notify-send "Conversion Complete" "Converted '$input_file' to '$output_file'"
> 
> ```
> 
> Then create another file called “convert2docx.nemo\_action” in `~/local/share/nemo/actions`.
> 
> ```auto
> [Nemo Action]
> Name=Convert Markdown to DOCX
> Comment=Convert selected Markdown files to DOCX format
> Exec=/path/to/script/convert2docx.sh %F
> Icon-Name=document-save
> Extensions=md;
> Selection=NotNone
> 
> ```

> **ImageMagick Grid/Collage From Selected Images**
>
> Use ImageMagick and Python to quickly create a grid with the selected images.  
> Works better with an even number of images. So, 2, 4, 6, 8, etc.
> 
> _ **Also, the script does not resize the images** _, so if you want to save disk space, this script doesn’t do that. In fact, you are likely to use more space by using this script. If you have 4 images that are 1000x1000, you will end up with a new image that is 4020x4020. _ **This is intentional** _.
> 
> **Lastly** : I’ve only tested this with `jpg;jpeg;png;webp` files since that’s all I had. But, it should work with other image files: bmp, tiff, raw, etc. I didn’t add these file types because they are a bit rare nowadays. _ **You** _ may add what _ **you** _ need.
> 
> Create a script: “`imagemagick_grid.sh`”
> 
> ```auto
> #!/bin/bash
> 
> # Get the selected files
> files=("$@")
> 
> # Get the directory of the first file
> output_dir=$(dirname "${files[0]}")
> 
> # Extract the base name of the first file (without extension)
> base_name=$(basename "${files[0]}" | sed 's/\.[^.]*$//')
> 
> # Set the output filename
> output_file="$output_dir/${base_name}_grid.jpg"
> 
> # Check if the output file already exists
> if [-f "$output_file"]; then
> # Append current date and time to the filename
> current_datetime=$(date +"%Y-%m-%d_%H-%M-%S")
> output_file="$output_dir/${base_name}_grid_$current_datetime.jpg"
> fi
> 
> # Calculate the number of files
> num_files=${#files[@]}
> 
> # Function to calculate the optimal grid dimensions
> optimal_grid() {
> python3 -c "
> import math
> n = $1
> aspect_ratio = 16/9
> for cols in range(1, n+1):
> rows = math.ceil(n / cols)
> if rows / cols <= aspect_ratio:
> print(f'{cols}x{rows}')
> break
> "
> }
> 
> # Calculate the optimal grid dimensions
> tile=$(optimal_grid $num_files)
> 
> # Use ImageMagick to create the grid
> montage "${files[@]}" -background "rgba(0,0,0,0.8)" -geometry +0+0 -tile $tile "$output_file"
> 
> # Send a notification
> notify-send "Image Grid Created" "Grid saved as $output_file"
> 
> ```
> 
> Create a Nemo Action: “`imagemagick_grid.nemo_action`”
> 
> ```auto
> [Nemo Action]
> Active=true
> Name=Create Grid with ImageMagick
> Comment=Arrange selected images in a grid using ImageMagick
> Exec=/path/to/script/imagemagick_grid.sh %F
> Icon-Name=imagemagick
> Selection=notnone
> Extensions=jpg;jpeg;png;webp;jxl;
> 
> ```

> **Merge Selected Images Horizontally Using ImageMagick**
>
> Create a script: “`imagemagick_merge_h.sh`”
> 
> ```auto
> #!/bin/bash
> 
> # Script: merge_images_horizontal.sh
> # Description: Merges selected images horizontally using ImageMagick with an 80% black background and centers the images.
> 
> # Check if ImageMagick is installed
> if ! command -v convert &> /dev/null; then
> echo "ImageMagick is not installed. Please install it first."
> exit 1
> fi
> 
> # Get the selected files
> files=("$@")
> 
> # Check if files were selected
> if [${#files[@]} -eq 0 ]; then
> echo "No files selected. Please select at least two image files."
> exit 1
> fi
> 
> # Generate output filename
> output_dir=$(dirname "${files[0]}")
> base_name=$(basename "${files[0]}" | cut -f 1 -d '.')
> output_file="${output_dir}/${base_name}_merged_h.jpg"
> 
> # Append date and time if file already exists
> if [-f "$output_file"]; then
> timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
> output_file="${output_dir}/${base_name}_merged_h_${timestamp}.jpg"
> fi
> 
> # Merge images horizontally with an 80% black background and center align them
> convert -background "rgba(0, 0, 0, 0.8)" -gravity Center "${files[@]}" +append "$output_file"
> 
> # Check if merge was successful
> if [$? -eq 0]; then
> notify-send "Horizontal Image Merge Complete" "Images merged successfully. Output: $output_file"
> else
> echo "Failed to merge images horizontally. Please check the selected files."
> fi
> 
> ```
> 
> Create a Nemo Action: “`imagemagick_merge_h.nemo_action`”
> 
> ```auto
> [Nemo Action]
> Active=true
> Name=Merge Images Horizontally
> Comment=Merge selected images using ImageMagick
> Exec=/path/to/script/imagemagick_merge_h.sh %F
> Icon-Name=image-x-generic
> Selection=m
> Extensions=png;jpg;jpeg;gif;webp;jxl;heic;heif;
> 
> ```

> **Merge Selected Images Vertically Using ImageMagick**
>
> Create a script: “`imagemagick_merge_v.sh`”
> 
> ```auto
> #!/bin/bash
> 
> # Script: merge_images_vertical.sh
> # Description: Merges selected images vertically using ImageMagick with an 80% black background and centers the images.
> 
> # Check if ImageMagick is installed
> if ! command -v convert &> /dev/null; then
> echo "ImageMagick is not installed. Please install it first."
> exit 1
> fi
> 
> # Get the selected files
> files=("$@")
> 
> # Check if files were selected
> if [${#files[@]} -eq 0 ]; then
> echo "No files selected. Please select at least two image files."
> exit 1
> fi
> 
> # Generate output filename
> output_dir=$(dirname "${files[0]}")
> base_name=$(basename "${files[0]}" | cut -f 1 -d '.')
> output_file="${output_dir}/${base_name}_merged_v.jpg"
> 
> # Append date and time if file already exists
> if [-f "$output_file"]; then
> timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
> output_file="${output_dir}/${base_name}_merged_v_${timestamp}.jpg"
> fi
> 
> # Merge images vertically with an 80% black background and center align them
> convert -background "rgba(0, 0, 0, 0.8)" -gravity Center "${files[@]}" -append "$output_file"
> 
> # Check if merge was successful
> if [$? -eq 0]; then
> notify-send "Vertical Image Merge Complete" "Images merged successfully. Output: $output_file"
> else
> echo "Failed to merge images vertically. Please check the selected files."
> fi
> 
> ```
> 
> Create a Nemo Action: “`imagemagick_merge_v.nemo_action`”
> 
> ```auto
> [Nemo Action]
> Active=true
> Name=Merge Images Vertically
> Comment=Merge selected images using ImageMagick
> Exec=/path/to/script/imagemagick_merge_v.sh %F
> Icon-Name=image-x-generic
> Selection=m
> Extensions=png;jpg;jpeg;gif;webp;jxl;heic;heif;
> 
> ```

* * *

* * *

## Dolphin Service Menus

The Nemo Actions above can probably all be used in Dolphin. They just have different formatting. Check the examples below for how to create them.

> **ImageMagick Grid/Collage From Selected Images**
>
> Same instructions as the Nemo Action above, except you need a Dolphin Service Menu file here: “`.local/share/kio/servicemenus`”
> 
> Create the file: “`imagemagick_grid.desktop`” and **make it executable**.
> 
> ```auto
> [Desktop Entry]
> Type=Service
> ServiceTypes=KonqPopupMenu/Plugin
> MimeType=image/*; # Adjust this to include/exclude other file types as needed
> Actions=createImageGrid;
> 
> X-KDE-Priority=TopLevel # Remove these two lines
> X-KDE-Submenu=Image Tools # if a submenu is not wanted
> 
> [Desktop Action createImageGrid]
> Name=Create Image Grid
> Exec=$HOME/path/to/script/imagemagick_grid.sh %F
> Icon=image-x-generic
> 
> ```

> **Convert to MP3**
>
> Same instructions as the Nemo Action above, except you need a Dolphin Service Menu file here: “`.local/share/kio/servicemenus`”
> 
> Create the file: “`convert2mp3.desktop`” and **make it executable**.
> 
> ```auto
> [Desktop Entry]
> Type=Service
> ServiceTypes=KonqPopupMenu/Plugin
> Actions=convert_to_mp3
> MimeType=video/*;
> 
> [Desktop Action convert_to_mp3]
> Name=Convert to MP3
> Exec=/path/to/script/convert2mp3.sh %F
> Icon=audio-x-generic
> 
> ```

For Dolphin service menus, add the following lines to ensure an action doesn’t go into a submenu, and to ensure some actions only show with a minimum number of selected files.

```auto
[Desktop Entry]
X-KDE-Priority=TopLevel
X-KDE-MinNumberOfUrls=2

```

The minimum number is particularly useful for the image merge and grid actions. No need to see the actions if only one file is selected, and even more so for the grid action, where I set mine to only show when I have at least 3 images selected since merging vertically or horizontally would do the same as making a grid if only 2 images are selected.

* * *

* * *

Note: You may want to convert from one audio filetype to another, and you should be able to do so with any of the above scripts, but you will need to add those extensions to the list.

Example for Nemo Actions:

```auto
[Nemo Action]
Name=Convert to FLAC
Comment=Convert video file to FLAC
Exec=/path/to/script/convert2flac.sh %F
Icon-Name=audio-x-generic
Selection=any
Extensions=mp4;avi;webm;mkv;mov;wmv;flv;f4v;mp3;m4a;flac;wav

```

In this case, I’ve added 4 extra: “`mp3;m4a;flac;wav`”

You can do the equivalent for Dolphin Service Menus.

* * *

* * *

A few other Nemo Actions I’ve already posted on the forum: [[Wiki] Customising Nemo's Context Menu With Nemo Actions](https://forum.endeavouros.com/t/wiki-customising-nemos-context-menu-with-nemo-actions/54611)

May add a few more scripts, including Nemo Actions and Dolphin Service Menus later.

* * *

* * *

## Terminal Shell Aliases

> **Some of my aliases**
>
> These all work in Fish shell. I was using one or two in Zsh before, but I no longer use Zsh, and I think the “`rnsu`” function only works in Fish. The only real change Zsh/Bash users would need to make is changing the double quotes `"` to single quotes `'` iirc.
> 
> ```auto
> # Update Packages
> ## Pacman and AUR ##
> 
> alias syu="sudo pacman -Syu"
> alias ss="yay -Ss"
> alias rs="sudo pacman -Rs"
> alias rnsu="sudo pacman -Rnsu"
> alias qi="yay -Qi"
> alias si="yay -Si"
> alias yy="yay -Sua"
> alias pu="paru -Sua"
> alias yc="yay -Ycc && yay -Scd"
> alias cr="checkrebuild"
> 
> ## Functions
> 
> ### Function to run Unison sync operations
> function uni
> path/to/script/unison.sh $argv
> end
> 
> ### Function to send checkupdates and paru -Qua to a file then open it in micro
> function cup
> set syu_date_format (date +"%Y-%m-%d_%H-%M-%S")
> set syu_log_name "/path/to/output/file/syu-$syu_date_format.sh"
> 
> # Capture the output of checkupdates and paru -Qua
> set checkupdates_output (checkupdates | sed 's/\x1b\[[0-9;]*m//g')
> set paru_output (paru -Qua)
> 
> # Check if there are any updates
> if test -n "$checkupdates_output" -o -n "$paru_output"
> # If there are updates, create the file and write the output
> printf "%s\n" $checkupdates_output > "$syu_log_name"
> printf "%s\n" $paru_output >> "$syu_log_name"
> sleep 0.1
> micro "$syu_log_name"
> # Remove the last two lines above if you don't need to see the output.
> # They can be replaced with syu && yy / syu && yy && fup to update immediately.
> # This is good for logging the available updates before updating.
> else
> echo "No updates found."
> end
> end
> 
> ### Function to remove a package and its user config files
> function rnsu
> if test (count $argv) -eq 0
> echo "Usage: rnsu package_name"
> return 1
> end
> 
> set package_name $argv[1]
> 
> # Run the pacman command
> sudo pacman -Rnsu $package_name
> 
> # Ask the user if they want to remove the related files
> read -P "Would you like to remove the related configs for \"$package_name\"? (y/n): " response
> 
> if test "$response" = "y"
> set directories ~/.config ~/.cache ~/.local/share
> set found_items 0
> 
> for dir in $directories
> set -l matches (find $dir -maxdepth 2 -iname "*$package_name*")
> if test (count $matches) -gt 0
> set found_items 1
> for match in $matches
> echo "Found: $match"
> end
> end
> end
> 
> if test $found_items -eq 1
> read -P "Do you want to move these items to the trash? (y/n): " confirm
> if test "$confirm" = "y"
> for dir in $directories
> set -l matches (find $dir -maxdepth 2 -iname "*$package_name*")
> for match in $matches
> echo "Moving to trash: $match"
> trash -v $match
> end
> end
> echo "Related files and folders for \"$package_name\" have been moved to the trash."
> else
> echo "No items have been moved to the trash."
> end
> else
> echo "No related files or folders found for \"$package_name\"."
> end
> else
> echo "No files or directories have been removed or sent to the trash."
> end
> end
> 
> ## Flatpak, AppImage, etc. ##
> alias fup="flatpak update"
> 
> ## Git ##
> 
> alias gp="git pull"
> alias gf="cd Appz/GIT_PKGS/"
> alias gl="git log -p"
> alias gitparu="cd Appz/GIT_PKGS/paru-git/; git pull; cd"
> alias gitparup="cd Appz/GIT_PKGS/paru-git/; makepkg -si; cd"
> alias gitqimgv="cd Appz/GIT_PKGS/qimgv/; git pull; cd"
> alias gitqimgvup="cd Appz/GIT_PKGS/qimgv/build/; sudo make install; cd"
> alias gitfsearch="cd Appz/GIT_PKGS/fsearch/; git pull; cd"
> alias gitfsearchup="cd Appz/GIT_PKGS/fsearch/; meson builddir; ninja -C builddir install; cd"
> alias gpa="cd Appz/GIT_PKGS/paru-git/; git pull; cd; cd Appz/GIT_PKGS/qimgv/; git pull; cd; cd Appz/GIT_PKGS/fsearch/; git pull; cd"
> 
> ```

* * *

* * *

## MPV Config

> **MPV can do a lot!!! Here is my config to show some of that.**
>
> My `mpv.conf`:
> 
> ```auto
> volume=25
> volume-max=300
> audio-normalize-downmix=yes
> replaygain=no
> auto-window-resize=no
> geometry=800x480
> keepaspect=yes
> keepaspect-window=no
> --loop-playlist=inf
> --screenshot-template="%F_%wH-%wM-%wS-%wT"
> --screenshot-format=jpg
> --osd-font-size=24
> screenshot-directory=/path/to/screenshots/
> directory-filter-types=video,audio,image/gif,image/webp,image/apng
> 
> ```
> 
> My `input.conf`:
> 
> ```auto
> WHEEL_UP add volume 5
> WHEEL_DOWN add volume -5
> WHEEL_LEFT ignore
> WHEEL_RIGHT ignore
> shift+s screenshot each-frame
> ctrl+RIGHT frame-step
> ctrl+LEFT frame-back-step
> ctrl+UP playlist-shuffle
> ctrl+DOWN playlist-unshuffle
> n playlist-next
> p playlist-prev
> DEL run gio trash "${path}"; playlist-remove current
> 
> ```

* * *

* * *

To see any previous versions for scripts, click the edit history button.

 ![image](https://forum.endeavouros.com/uploads/default/original/3X/6/b/6bf17c993bd1a65a3516d7b4724c77cab6c2ebd9.jpeg)

PS: I’m open to suggestions about efficiency, and questions in general about scripts.

Here is the link to my Codeberg where I will post the the full scripts/code updates. I will comment here to indicate updates, but not to post the full updates.

> **[Bash\_Scripts\_for\_Automation](https://codeberg.org/ddnn/Bash_Scripts_for_Automation)**
>
> These range from auto-renaming and moving files to merging images and converting file formats. Also included are Nemo Actions and Dolphin Service Menus.

---

<div class="post-metadata">

**Author:** ![alama](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@alama](https://forum.endeavouros.com/u/alama)\
**Post date:** [October 4, 2024, 9:13pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/2 "2024-10-04T21:13:18Z")

</div>

It’s wonderful when a few lines of script can replace an app for a task. I use a wallpaper changer written in python:  
`import os
import random
import subprocess
import time`

`
picture_dir = “path_to_wallpaper”
while True:
# Get a list of all the picture files in the directory
picture_files = [f for f in os.listdir(picture_dir) if f.endswith(“.jpg”) or f.endswith(“.png”)]
```
# Choose a random picture from the list
random_picture = os.path.join(picture_dir, random.choice(picture_files))

# Set the desktop background using the feh command
subprocess.run(["feh", "--bg-fill", random_picture])

# Wait for 11 minutes before changing the background again
time.sleep(660)

```
`

that also uses feh. I use it in Openbox. I call it by adding

`python3 ~/.local/bin/change-background.py &
`

to ~/.config/openbox/autostart because I want the action confined to openbox and to execute automatically on login to an openbox session.  
I am totally satisfied, but I’d like to know, ddnn, how I could call your wallpaper script in a similar way to execute automatically on login and similarly confine it to openbox or another WM.  
Thanks for these!

---

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 4, 2024, 9:23pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/3 "2024-10-04T21:23:34Z")

</div>

> [@alama](#):
>
> Thanks for these!

You’re welcome.

* * *

Include this in your autostart:

```auto
bash /path/to/wallpaperScript/auto-wp.sh &

```

I actually call mine using a shortcut, because I share my screen for most of the day.  
So, I use one shortcut for work-friendly wallpapers (just two images in this case), and another for my favourites.

The shortcuts look like this (using `sxhkd`):

```auto
super + shift + r
    pkill -f 'auto-wp'|feh --randomize --bg-fill /path/to/wp/directory

super + alt + r
    /path/to/wallpaperScript/auto-wp.sh

```

One script kills the wallpaper changer then sets a random work-friendly wallpaper, and the other starts the wallpaper changer.

---

<div class="post-metadata">

**Author:** ![thefrog](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/thefrog/32/114250_2.png) [@thefrog](https://forum.endeavouros.com/u/thefrog)\
**Post date:** [October 5, 2024, 12:33am UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/4 "2024-10-05T00:33:27Z")

</div>

> [@anon93652015](#):
>
> `ffmpeg -i "$file" -vn -acodec libmp3lame -q:a 0 "${file%.*}.mp3"`

What bitrate is this?

---

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 5, 2024, 1:11am UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/5 "2024-10-05T01:11:03Z")

</div>

I don’t remember if I considered bitrate when making the script.

However, I just converted a video that showed a variable bitrate from 86-107 kbps. As an audio file, it shows 233-246 kbps.

Not sure if that’s a good thing or bad thing, but there is no drop in audio quality, nor improvement. (Just found out higher bitrate is a good thing)

Actually, I do remember having issues with volume when creating it, but I worked that out, so now the volume is the same.

Update: The `-q:a 0` section outputs the audio at the highest quality.

> - **`-q:a`** : This option sets the quality of the audio encoding. The “`a`” denotes that this is an audio quality setting.
> - **`0`** : This value specifies the highest quality for MP3 encoding. The range typically goes from 0 (highest quality) to 9 (lowest quality).

---

<div class="post-metadata">

**Author:** ![thefrog](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/thefrog/32/114250_2.png) [@thefrog](https://forum.endeavouros.com/u/thefrog)\
**Post date:** [October 5, 2024, 8:00am UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/6 "2024-10-05T08:00:00Z")

</div>

I haven’t done mp3 in several years since I switch everything to flac this was the command I was using and it allowed you to tell it the bitrate you want I choose. Heres the command if you want to play with it.

```auto
for filename in *; do
  original=$filename
  #/ audio name uses cut and rev to remove extention mp4 for ext mp3
  audioname=`echo $original | rev | cut -c 5- | rev`
  echo -e "Now Extracting ${audioname}"
  ffmpeg -i "$original" -vn -ar 44100 -ac 2 -ab 320k -f mp3 "${audioname}.mp3" > /dev/null 2>&1

```

here is the information of a converted file  
 ![codec](https://forum.endeavouros.com/uploads/default/original/3X/0/b/0b0a5ee7a3e0a7c0b97a15b37d95bfad224232d0.png)

I don’t know if there is any difference in the two commands as far as sound quality as I just woke up and havent gotten there.

---

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 5, 2024, 3:51pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/7 "2024-10-05T15:51:41Z")

</div>

I can’t hear a difference from my end.

---

<div class="post-metadata">

**Author:** ![z580c](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/z580c/32/98828_2.png) [@z580c](https://forum.endeavouros.com/u/z580c)\
**Post date:** [October 5, 2024, 4:23pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/8 "2024-10-05T16:23:48Z")

</div>

I’m surprised this script spat out a 192kb/s bitrate file - to me it looks like it’s set up for a CBR at 320kb/s, and I don’t see any switches that would have enabled VBR instead which might have identified itself in the metadata as an average of 192kb/s.

Maybe I’m just rusty on my ffmpeg 😄

---

<div class="post-metadata">

**Author:** ![thefrog](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/thefrog/32/114250_2.png) [@thefrog](https://forum.endeavouros.com/u/thefrog)\
**Post date:** [October 5, 2024, 4:26pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/9 "2024-10-05T16:26:12Z")

</div>

that could be just the wrong picture as I don’t use that anymore. I had just woke up when i posted.

---

<div class="post-metadata">

**Author:** ![z580c](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/z580c/32/98828_2.png) [@z580c](https://forum.endeavouros.com/u/z580c)\
**Post date:** [October 5, 2024, 4:26pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/10 "2024-10-05T16:26:39Z")

</div>

That makes sense, I know the feeling!

---

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 5, 2024, 4:27pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/11 "2024-10-05T16:27:40Z")

</div>

In my test, it was a CBR of 320 kbps. So yeah:

> [@thefrog](#):
>
> that could be just the wrong picture

* * *

 ![image](https://forum.endeavouros.com/uploads/default/original/3X/8/b/8b2a324ab36f5b867799b1228bb30dec3626d150.jpeg)

---

<div class="post-metadata">

**Author:** ![z580c](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/z580c/32/98828_2.png) [@z580c](https://forum.endeavouros.com/u/z580c)\
**Post date:** [October 5, 2024, 4:54pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/12 "2024-10-05T16:54:50Z")

</div>

> [@anon93652015](#):
>
> I don’t remember if I considered bitrate when making the script.
> 
> However, I just converted a video that showed a variable bitrate from 86-107 kbps. As an audio file, it shows 233-246 kbps.
> 
> Not sure if that’s a good thing or bad thing, but there is no drop in audio quality, nor improvement. (Just found out higher bitrate is a good thing)

RE: if this inflated file size is a good thing or a bad thing - it could go either way! It will mostly depend on what format the original audio is in - we’ve come a long way since MP3 was the king of the hill, and modern codecs often produce the same quality of audio at lower bitrates, so you will occasionally find yourself with MP3 encoded tracks that come out bigger than other codecs despite sounding identical.

Theoretically it could a ‘bad thing’ if encoding with CBR - while MP3 encoding is akin to black magic, it can’t create extra quality from a lossy file out of thin air so the inflated filesize from increasing the bitrate won’t be doing anything 😆

However, it’s only bad on paper - with modern storage capacities, it’s not worth worrying about the occasional oversized MP3.

For reference, 320kb/s is the maximum bitrate MP3 encodes in - in a similar vein, using the `-q:a 0` switch as you are here is giving a theoretical best quality while assuming for VBR in order to balance quality against the total file size.

Ultimately if you’re satisfied with it then that’s all that matters, but in technical terms 320kb/s CBR is the ‘best’ quality of audio for encoding an MP3.

---

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 5, 2024, 5:01pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/13 "2024-10-05T17:01:52Z")

</div>

In my case, I created this script for two reasons:

1. TED Talks videos and others that don’t need to be in video form
2. Music uploaded to YouTube that say “Official Audio”

So, in my case, quality is mostly an afterthought.

---

<div class="post-metadata">

**Author:** ![rinwolf1312](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/rinwolf1312/32/100320_2.png) [@rinwolf1312](https://forum.endeavouros.com/u/rinwolf1312)\
**Post date:** [October 5, 2024, 5:09pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/14 "2024-10-05T17:09:15Z")

</div>

Thank you for sharing! Will be running the FreeTube links and DOCX conversions on my system 😃

---

<div class="post-metadata">

**Author:** ![thefrog](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/thefrog/32/114250_2.png) [@thefrog](https://forum.endeavouros.com/u/thefrog)\
**Post date:** [October 6, 2024, 9:03am UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/15 "2024-10-06T09:03:52Z")

</div>

just for you knowledge

instead of downloading videos and then converting them you can just us yt-dlp to do the conversion for you

`yt-dlp -x --audio-format mp3 $URL -o/place/to/store`

---

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 6, 2024, 3:19pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/16 "2024-10-06T15:19:03Z")

</div>

I use JDownloader2, so I usually download the audio files through that. It also allows me to download thumbnails, captions, etc.

However, sometimes the “Official Audio” songs, or the TED Talks videos, etc. have actual video to watch (like visualisers and unorthodox talks), and then I decide I want to keep it, but not in video form. So this little script allows me to just convert it without finding the YT link again and selecting the audio.

* * *

 ![Screenshot_2024-10-06_10-25](https://forum.endeavouros.com/uploads/default/original/3X/4/b/4bbb7e2f1edd9ff440bbb09baca848d2c21610cb.png)

* * *

PS: I actually rarely use this script because most times I download both the audio and video from the start if I think I may want the audio. But, it’s useful when needed.

---

<div class="post-metadata">

**Author:** ![thefrog](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/thefrog/32/114250_2.png) [@thefrog](https://forum.endeavouros.com/u/thefrog)\
**Post date:** [October 6, 2024, 3:48pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/17 "2024-10-06T15:48:30Z")

</div>

> [@anon93652015](#):
>
> I actually rarely use this script because most times I download both the audio and video from the start if I think I may want the audio

I have kept my script for the conversion for those times I may want the audio for a trip. however i find most of the time i can just play the video its not like i have to look at it however i haven’t needed it for my phone in years which is why i originally thought i would need to keep it.

---

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 6, 2024, 3:54pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/18 "2024-10-06T15:54:24Z")

</div>

Yeah, I could just listen to videos without watching them, but I guess it’s also good for saving space. Not that I need to since I have 2 TBs free.

---

<div class="post-metadata">

**Author:** ![anon93652015](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/48db29/32.png) [@anon93652015](https://forum.endeavouros.com/u/anon93652015)\
**Post date:** [October 8, 2024, 12:36am UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/19 "2024-10-08T00:36:58Z")

</div>

Updated the Weekly Reminder script so that the days are more easily modifiable.

```auto
# Days to run the script (1=Monday, 7=Sunday)
ACTIVE_DAYS=(1 2 3 4 5) # Monday to Friday

# Function to check if the current day is in the active days list
is_active_day() {
    local current_day=$1
    for day in "${ACTIVE_DAYS[@]}"; do
        if ["$current_day" -eq "$day"]; then
            return 0 # True
        fi
    done
    return 1 # False
}

```

* * *

Added “Convert to FLAC” Nemo Action. _I may make a submenu._  
Added “ImageMagick Grid/Collage From Selected Images” Nemo Action.  
Added “ImageMagick Grid/Collage From Selected Images” Dolphin instructions.  
Added “Convert to MP3” Dolphin instructions.  
Added “Merge Selected Images Horizontally/Vertically Using ImageMagick”

---

<div class="post-metadata">

**Author:** ![melting\_snowman](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/melting_snowman/32/101415_2.png) [@melting\_snowman](https://forum.endeavouros.com/u/melting_snowman)\
**Post date:** [October 9, 2024, 4:29pm UTC](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327/20 "2024-10-09T16:29:51Z")

</div>

Not scripts, but aliases. Because sometimes a task is so simple an alias will do the job…

First up, you know when you realise you needed to `sudo` your last command? Personally, I just wish I could tell the terminal to just _dewit_. Now I can:

```auto
alias dewit='sudo $(fc -ln -1)'

```

I actually don’t use `ffmpeg` or the default builds of `flac` to convert anything to FLAC format, I use [a build of `flac` that uses multithreading](https://hydrogenaud.io/index.php/topic,124437.msg1029942.html#msg1029942) which goes _very_ fast. Like, stupid fast. Fast as balls. But you do need to remember to tell it to use a bunch of threads and the high compression level, so I just wrote an alias so I don’t have to:

```auto
alias flac='flac -j12 -8p'

```

Not sure if any of this is good practice or not, but it’s very entertaining (if I’m being stupid, don’t hesitate to tell me, I’m always eager to learn). They’re both in my `~/.bashrc`

[Next page](https://forum.endeavouros.com/t/useful-and-use-less-scripts/61327.md?page=2)
