Initial commit : dotfiles setup

This commit is contained in:
SeraphimeZelel
2025-09-05 21:07:00 +07:00
parent 1bf3d416ef
commit 5a689e8849
141 changed files with 5346 additions and 0 deletions

17
.script/cava-pywalsync.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# Paths
CAVA_CONFIG="$HOME/.config/cava/config"
WAL_COLORS="$HOME/.cache/wal/colors.json"
# Take colors from pywal
COLOR1=$(jq -r '.colors.color8' "$WAL_COLORS")
COLOR2=$(jq -r '.colors.color1' "$WAL_COLORS")
# Update colors in CAVA
sed -i "s|^gradient_color_1 = '.*'|gradient_color_1 = '$COLOR1'|" "$CAVA_CONFIG"
sed -i "s|^gradient_color_2 = '.*'|gradient_color_2 = '$COLOR2'|" "$CAVA_CONFIG"
# Auto-Restart CAVA (if it's running)
killall -USR1 cava

14
.script/discord-pywalsync.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
# Path
WALCSS="$HOME/.cache/wal/colors.css"
BDCSS="$HOME/.config/BetterDiscord/data/stable/custom.css"
TEMPLATE="$HOME/.config/bd-template.css"
HEADER="$HOME/.config/bd-header.css"
# Overwrite Better Discord Custom CSS using pywal color palette
cat "$HEADER" > "$BDCSS"
echo "" >> "$BDCSS"
cat "$WALCSS" >> "$BDCSS"
echo "" >> "$BDCSS"
cat "$TEMPLATE" >> "$BDCSS"

2
.script/flameshot-gui.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
flameshot gui

32
.script/normalize-wall.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# normalize_wallpapers.sh
# Renames wallpapers to have _ before trailing numbers
WALLPAPERS="$HOME/Pictures/Wallpaper"
cd "$WALLPAPERS" || { echo "Directory not found: $WALLPAPERS"; exit 1; }
for f in *.png *.jpg *.jpeg *.webp *.bmp; do
[[ -f "$f" ]] || continue
# Remove surrounding quotes if any
clean="${f%\"}"
clean="${clean#\"}"
# Split name and extension
name="${clean%.*}"
ext="${clean##*.}"
# If name ends with number without _, add _
if [[ "$name" =~ ^(.*[^0-9])([0-9]+)$ ]]; then
new_name="${BASH_REMATCH[1]}_${BASH_REMATCH[2]}.$ext"
# Only rename if different
if [[ "$clean" != "$new_name" ]]; then
mv -i "$clean" "$new_name"
echo "Renamed: $clean -> $new_name"
fi
fi
done
echo "✅ All wallpapers normalized in $WALLPAPERS"

128
.script/rain.sh Executable file
View File

@@ -0,0 +1,128 @@
#!/bin/bash
# Let it Rain!
# Copyright (C) 2011, 2013 by Yu-Jie Lin
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# Blog: https://yjlv.blogstpo.com/2013/07/let-it-rain.html
# Gif : https://lh5.googleusercontent.com/-0WJ1vSZcFPs/UdadOwdPEXI/AAAAAAAAE-c/6kuH9hP3cUo/s800/rain.sh.gif
# Clip: https://youtu.be/EssRgAh2w_c
#
# Modified from falling-<3s.sh:
# https://yjlv.blogstpo.com/2011/02/time-to-have-falling-hearts-screensaver.html
RAINS=("|" "│" "┃" "┆" "┇" "┊" "┋" "╽" "╿")
COLORS=("\e[37m" "\e[37;1m")
# More from 256 color mode
for i in {244..255}; do
COLORS=("${COLORS[@]}" "\e[38;5;${i}m")
done
NRAINS=${#RAINS[@]}
NCOLORS=${#COLORS[@]}
NUM_RAIN_METADATA=5
sigwinch() {
TERM_WIDTH=$(tput cols)
TERM_HEIGHT=$(tput lines)
STEP_DURATION=0.025
((MAX_RAINS = TERM_WIDTH * TERM_HEIGHT / 4))
((MAX_RAIN_LENGTH = TERM_HEIGHT < 10 ? 1 : TERM_HEIGHT / 10))
# In percentage
((NEW_RAIN_ODD = TERM_HEIGHT > 50 ? 100 : TERM_HEIGHT * 2))
((NEW_RAIN_ODD = NEW_RAIN_ODD * 75 / 100))
((FALLING_ODD = TERM_HEIGHT > 25 ? 100 : TERM_HEIGHT * 4))
((FALLING_ODD = FALLING_ODD * 90 / 100))
}
do_exit() {
echo -ne "\e[${TERM_HEIGHT};1H\e[0K"
# Show cursor and echo stdin
echo -ne "\e[?25h"
stty echo
exit 0
}
do_render() {
# Clean screen first
for ((idx = 0; idx < num_rains * NUM_RAIN_METADATA; idx += NUM_RAIN_METADATA)); do
X=${rains[idx]}
Y=${rains[idx + 1]}
LENGTH=${rains[idx + 4]}
for ((y = Y; y < Y + LENGTH; y++)); do
(( y < 1 || y > TERM_HEIGHT )) && continue
echo -ne "\e[${y};${X}H "
done
done
for ((idx = 0; idx < num_rains * NUM_RAIN_METADATA; idx += NUM_RAIN_METADATA)); do
if ((100 * RANDOM / 32768 < FALLING_ODD)); then
# Falling
if ((++rains[idx + 1] > TERM_HEIGHT)); then
# Out of screen, bye sweet <3
rains=("${rains[@]:0:idx}"
"${rains[@]:idx+NUM_RAIN_METADATA:num_rains*NUM_RAIN_METADATA}")
((num_rains--))
continue
fi
fi
X=${rains[idx]}
Y=${rains[idx + 1]}
RAIN=${rains[idx + 2]}
COLOR=${rains[idx + 3]}
LENGTH=${rains[idx + 4]}
for ((y = Y; y < Y + LENGTH; y++)); do
(( y < 1 || y > TERM_HEIGHT )) && continue
echo -ne "\e[${y};${X}H${COLOR}${RAIN}"
done
done
}
trap do_exit TERM INT
trap sigwinch WINCH
# No echo stdin and hide the cursor
stty -echo
echo -ne "\e[?25l"
echo -ne "\e[2J"
rains=()
sigwinch
while :; do
read -n 1 -t $STEP_DURATION ch
case "$ch" in
q|Q)
do_exit
;;
esac
if ((num_rains < MAX_RAINS)) && ((100 * RANDOM / 32768 < NEW_RAIN_ODD)); then
# Need new |, 1-based
RAIN="${RAINS[NRAINS * RANDOM / 32768]}"
COLOR="${COLORS[NCOLORS * RANDOM / 32768]}"
LENGTH=$((MAX_RAIN_LENGTH * RANDOM / 32768 + 1))
X=$((TERM_WIDTH * RANDOM / 32768 + 1))
Y=$((1 - LENGTH))
rains=("${rains[@]}" "$X" "$Y" "$RAIN" "$COLOR" "$LENGTH")
((num_rains++))
fi
# Let rain fall!
do_render
done

66
.script/reales-scale.sh Executable file
View File

@@ -0,0 +1,66 @@
#!/bin/bash
# Path for output
OUTPUT_DIR="$HOME/Pictures/Realesrgan"
REALES="$HOME/.realesrgan/realesrgan-ncnn-vulkan"
# Create output directory if not exists
mkdir -p "$OUTPUT_DIR"
# Default to current directory
INPUT_DIR="$(pwd)"
# Count files (jpg/jpeg/png only)
FILE_COUNT=$(find "$INPUT_DIR" -maxdepth 1 -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | wc -l)
# Confirm
read -rp "Initiating RealESRGAN to process $FILE_COUNT files in $INPUT_DIR, are you sure? [y/N]: " confirm
case "$confirm" in
[yY][eE][sS]|[yY]) ;;
*) echo "Aborted."; exit 1 ;;
esac
# Model
MODEL="realesr-animevideov3"
# Force NVIDIA GPU (index 1)
GPU_INDEX=1
# Scale options
echo "Choose scale factor:"
echo "1) 2x"
echo "2) 3x"
echo "3) 4x"
read -rp "Select scale (1-3): " scale_choice
case $scale_choice in
1) SCALE=2 ;;
2) SCALE=3 ;;
3) SCALE=4 ;;
*) echo "Invalid choice, defaulting to 2x"; SCALE=2 ;;
esac
echo "Processing $FILE_COUNT images in $INPUT_DIR with model=$MODEL, scale=${SCALE}x, GPU=$GPU_INDEX..."
COUNT=0
# Process each file
for file in "$INPUT_DIR"/*.{jpg,jpeg,png}; do
[ -e "$file" ] || continue
COUNT=$((COUNT + 1))
filename=$(basename "$file")
base="${filename%.*}" # name without extension
output_file="$OUTPUT_DIR/${base}.png"
# Ensure no overwrite (add _1, _2, etc.)
i=1
while [ -f "$output_file" ]; do
output_file="$OUTPUT_DIR/${base}_$i.png"
i=$((i + 1))
done
echo "[$COUNT/$FILE_COUNT] Processing: $filename -> $(basename "$output_file")"
$REALES -i "$file" -o "$output_file" -n "$MODEL" -s "$SCALE" -g "$GPU_INDEX" >/dev/null 2>&1
done
echo "✅ All files processed. Output saved in $OUTPUT_DIR"

73
.script/scaler-wallpaper.sh Executable file
View File

@@ -0,0 +1,73 @@
#!/bin/bash
# PATH
WALLPAPERS="$HOME/Pictures/Wallpaper"
BACKUP="$HOME/Pictures/.backup"
# Make dirs if they don't exist
mkdir -p "$BACKUP"
cd "$WALLPAPERS" || exit 1
# Process all images
for img in *.{jpg,jpeg,png,webp,bmp}; do
[[ -f "$img" ]] || continue
# Check resolution
read width height <<< $(identify -format "%w %h" "$img")
if [[ "$width" -eq 1920 && "$height" -eq 1080 ]]; then
continue
fi
base="${img%.*}"
ext="png" # Converted wallpaper extension
orig_ext="${img##*.}" # Original extension for backup
# --- Determine next available name in wallpaper folder ---
max=0
for f in "$base"_*.${ext} "$base".${ext}; do
[[ -f "$f" ]] || continue
if [[ "$f" =~ ${base}_([0-9]+)\.${ext}$ ]]; then
(( ${BASH_REMATCH[1]} > max )) && max=${BASH_REMATCH[1]}
elif [[ "$f" == "$base.$ext" ]]; then
(( max < 1 )) && max=1
fi
done
# Choose new file name
if [[ $max -eq 0 ]]; then
new_name="$base.$ext"
else
new_name="${base}_$((max + 1)).$ext"
fi
# Convert image
if magick "$img" -resize 1920x1080^ -gravity center -extent 1920x1080 "$new_name"; then
echo "Converted: $img -> $new_name"
# --- Move original to backup with incremental name and original extension ---
backup_base="$BACKUP/$base"
backup_max=0
for f in "$backup_base"_*.$orig_ext "$backup_base".$orig_ext; do
[[ -f "$f" ]] || continue
if [[ "$f" =~ ${backup_base}_([0-9]+)\.${orig_ext}$ ]]; then
(( ${BASH_REMATCH[1]} > backup_max )) && backup_max=${BASH_REMATCH[1]}
elif [[ "$f" == "$backup_base.$orig_ext" ]]; then
(( backup_max < 1 )) && backup_max=1
fi
done
if [[ $backup_max -eq 0 ]]; then
backup_name="$BACKUP/$base.$orig_ext"
else
backup_name="$BACKUP/${base}_$((backup_max + 1)).$orig_ext"
fi
mv "$img" "$backup_name"
echo "Moved original to backup: $backup_name"
else
echo "❌ Failed to convert: $img"
fi
done
echo "✅ All Wallpapers has been processed $WALLPAPERS"

72
.script/sort-file.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/bash
# Directory you want to organize (default: current directory)
DIR="${1:-.}"
DIR="$(realpath "$DIR")"
# Ask for confirmation
read -p "Sort the files in $DIR ? [y/N]: " confirm
case "$confirm" in
[yY][eE][sS]|[yY])
echo "Sorting files in $DIR..."
;;
*)
echo "Aborted."
exit 0
;;
esac
# Define groups of extensions
photos=("jpg" "jpeg" "png" "gif" "bmp" "tiff" "webp")
videos=("mp4" "mkv" "avi" "mov" "flv" "wmv" "webm")
documents=("doc" "docx" "odt" "pdf" "txt" "rtf" "xlsx" "xls" "ppt" "pptx" "csv")
compressed=("zip" "tar" "gz" "rar" "7z" "bz2")
audio=("mp3" "wav" "flac" "aac" "ogg" "m4a")
# Create function to check if value in array
in_array() {
local e match="$1"; shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
# Loop through files
for file in "$DIR"/*; do
[ -f "$file" ] || continue
ext="${file##*.}"
ext=$(echo "$ext" | tr '[:upper:]' '[:lower:]') # normalize lowercase
target_dir="Others" # default group
if in_array "$ext" "${photos[@]}"; then
target_dir="Media/Photos"
elif in_array "$ext" "${videos[@]}"; then
target_dir="Media/Videos"
elif in_array "$ext" "${documents[@]}"; then
target_dir="Documents"
elif in_array "$ext" "${compressed[@]}"; then
target_dir="Compressed"
elif in_array "$ext" "${audio[@]}"; then
target_dir="Media/Audio"
fi
mkdir -p "$DIR/$target_dir"
# Generate new filename if already exists
base_name="$(basename "$file")"
dest="$DIR/$target_dir/$base_name"
if [ -e "$dest" ]; then
name="${base_name%.*}"
ext_only="${base_name##*.}"
n=1
while [ -e "$DIR/$target_dir/${name}_$n.$ext_only" ]; do
((n++))
done
dest="$DIR/$target_dir/${name}_$n.$ext_only"
fi
mv "$file" "$dest"
echo "Moved: $(basename "$file")$target_dir/$(basename "$dest")"
done

108
.script/wallpaper-picker.sh Executable file
View File

@@ -0,0 +1,108 @@
#!/bin/bash
# Config and Path
WALLPAPERS="$HOME/Pictures/Wallpaper"
CACHE_DIR="$HOME/.cache/wallpaper-picker"
THUMB_WIDTH="250"
THUMB_HEIGHT="141"
THEMES="$HOME/.config/wal/themes"
WAL_BIN="$HOME/.local/bin/wal"
HOOKS="$HOME/.config/wal/hooks/hooks.sh"
FASTFETCH_CFG="$HOME/.config/fastfetch/config.jsonc"
# Make the thumb dir if it's not exist
mkdir -p "$CACHE_DIR"
# Generate thumbnail
generate_thumbnail(){
local input="$1"
local output="$2"
magick "$input" -thumbnail "${THUMB_WIDTH}x${THUMB_HEIGHT}^" \
-gravity center -extent "${THUMB_WIDTH}x${THUMB_HEIGHT}" "$output"
}
# Generate menu with thumbnails
generate_menu(){
# Find all images and sort naturally
while IFS= read -r img; do
[[ -f "$img" ]] || continue
thumb="$CACHE_DIR/$(basename "${img%.*}").png"
# Generate thumbnail if missing or outdated
if [[ ! -f "$thumb" ]] || [[ "$img" -nt "$thumb" ]]; then
generate_thumbnail "$img" "$thumb"
fi
# Output for wofi
echo -en "img:$thumb\x00info:$(basename "$img")\x1f$img\n"
done < <(find "$WALLPAPERS" -maxdepth 1 -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) | sort -V)
}
# Run wofi with thumbnails
CHOICE=$(generate_menu | wofi --show dmenu \
--cache-file /dev/null \
--define "image-size=${THUMB_WIDTH}x${THUMB_HEIGHT}" \
--columns 3 \
--allow-images \
--insensitive \
--sort-order=default \
--prompt "Select Wallpaper" \
--conf ~/.config/wofi/wallpaper
)
[ -z "$CHOICE" ] && exit 0
WAL_NAME=$(basename "$CHOICE")
SELECTED="$WALLPAPERS/$WAL_NAME"
# Extract THEME name
BASENAME=$(basename "$SELECTED")
THEME="${BASENAME%%_*}"
# Default
WIFENAME=$(echo "$BASENAME" | awk -F '[_.]' '{print $2}' | sed 's/[0-9]*$//')
LOGO_PATH="$HOME/.config/fastfetch/logo/${THEME,,}_small.png"
# Mapping manual
if [[ "$THEME" =~ "Endfield" ]]; then
LOGO_PATH="$HOME/.config/fastfetch/logo/john_endfield.png"
elif [[ "$THEME" =~ "Arknight" ]]; then
LOGO_PATH="$HOME/.config/fastfetch/logo/john_arknights.png"
elif [[ "$THEME" =~ "Wuthering" ]]; then
LOGO_PATH="$HOME/.config/fastfetch/logo/john_wuthering.png"
elif [[ "$THEME" =~ "Genshin" ]]; then
LOGO_PATH="$HOME/.config/fastfetch/logo/john_genshin.png"
elif [[ "$THEME" =~ "StarRail" ]]; then
LOGO_PATH="$HOME/.config/fastfetch/logo/john_starrail.png"
elif [[ "$THEME" =~ "Zenless" ]]; then
LOGO_PATH="$HOME/.config/fastfetch/logo/john_zenless.png"
else
LOGO_PATH="$HOME/.config/fastfetch/logo/john_wuthering.png"
fi
# Apply theme
THEME_FILE="$THEMES/$THEME.json"
if [ -f "$THEME_FILE" ]; then
"$WAL_BIN" --theme "$THEME_FILE"
else
"$WAL_BIN" -i "$SELECTED"
fi
# Update GNOME wallpaper
gsettings set org.gnome.desktop.background picture-uri-dark "file://$SELECTED"
gsettings set org.gnome.desktop.screensaver picture-uri "file://$SELECTED"
# Update fastfetch config
tmpfile=$(mktemp)
jq --arg logo "$LOGO_PATH" \
--arg wife "$WIFENAME" \
'
.logo.source = $logo
| (.modules[] | select(.key? == "wife ").format) = $wife
' "$FASTFETCH_CFG" > "$tmpfile" && mv "$tmpfile" "$FASTFETCH_CFG"
touch "$HOME/.config/fastfetch/.reload_flag"
# Run pywal hooks
$HOOKS
$HOME/.local/bin/pywalfox update

20
.script/wlogout-pywalsync.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Path
WALLPAPER=$(gsettings get org.gnome.desktop.background picture-uri-dark \
| sed -E "s/^'file:\/\///; s/^\"file:\/\///; s/'$//; s/\"$//")
WALL_DIR="$HOME/Pictures/Wallpaper"
WALL_NAME="$(basename "$WALLPAPER")"
BLUR_BG="$HOME/.config/wlogout/images/wallpaper_blurred.png"
WALCSS="$HOME/.cache/wal/colors-waybar.css"
WL_TEMPLATE="$HOME/.config/wlogout/style-template.css"
WLCSS="$HOME/.config/wlogout/style.css"
mkdir -p "$(dirname "$BLUR_BG")"
# Generate Blurred Wallpaper
magick "$WALL_DIR/$WALL_NAME" -resize 1920x1080^ -gravity center -extent 1920x1080 -blur 0x8 -fill black -colorize 65% "$BLUR_BG"
# === UPDATE STYLE.CSS ===
cat "$WL_TEMPLATE" > "$WLCSS"