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.
"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
:
#!/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. But basically, if you copy a YouTube link, and you have FreeTube installed, this script will open the link in FreeTube.
#!/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:
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.
#!/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.
#!/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.
#!/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…
#!/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:
#!/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:
### 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”.
#!/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
.
[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”.
#!/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
.
[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”.
#!/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
.
[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”.
#!/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
.
[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
”
#!/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
”
[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
”
#!/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
”
[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
”
#!/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
”
[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.
[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.
[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.
[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:
[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
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.
# 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
:
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/
My input.conf
:
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.
PS: I’m open to suggestions about efficiency, and questions in general about scripts.