Organising

This commit is contained in:
2026-03-08 18:24:38 +00:00
parent ca7d4accb9
commit 6240282513
71 changed files with 0 additions and 1099 deletions

45
.local/bin/nixos-todo/enp Executable file
View File

@@ -0,0 +1,45 @@
#! /usr/bin/zsh
pwdpath="/tmp/pwd.gpg"
pinpath="${XDG_DATA_HOME:-$HOME/.local/share}/pin.gpg"
if [ -f "$pwdpath" ]
then
PIN="$(dmenupass "PIN")"
export MASTERPW="$(gpg --batch --yes --passphrase "$PIN" --decrypt "$pwdpath" 2&>/dev/null)"
elif [ -f "$pinpath" ]
then
export MASTERPW="$(dmenupass "Password")"
PIN="$(gpg --batch --yes --passphrase "$MASTERPW" --decrypt "$pinpath" 2&>/dev/null)"
echo "$MASTERPW" | gpg --symmetric --batch --yes --passphrase "$PIN" --output "$pwdpath"
else
export MASTERPW="$(dmenupass "Password")"
PIN="$(dmenupass "PIN")"
echo "$PIN" | gpg --symmetric --batch --yes --passphrase "$MASTERPW" --output "$pinpath"
echo "$MASTERPW" | gpg --symmetric --batch --yes --passphrase "$PIN" --output "$pwdpath"
fi
[ -z "$MASTERPW" ] && exit 1;
choices="$(enpasscli -vault="$HOME/Documents/Enpass/Vaults/primary" -sort show 2>&1 | sed -n '/level=info/p')"
awkcommand='
{
if (length($3)) {
$line = $2" ("$3")"; # If username exists wrap it in brackets
} else {
$line = $2; # Otherwise just show title
}
print $line;
}
'
chosen="$(echo "$choices" | awk -F '\\s*(title|login|pass|cat\\.)\\s*:\\s*' "$awkcommand" | dmenu -i -ix -l 30)"
linenumber="$((chosen + 1))"
line="$(echo "$choices" | sed "${linenumber}q;d")"
# echo $line
echo $line | sed -n 's/.*\? pass : \(.\+\?\)"$/\1/p' | xclip -selection clipboard -i -loops 1

View File

@@ -0,0 +1,62 @@
#! /bin/zsh
target_dir="/home/chris/.local/share/Dungeondraft/asset_packs"
download_dir="/home/chris/Downloads"
for file in $download_dir/FA_(Objects|Textures)_*.zip; do
dir=$(mktemp -d)
unzip -qq $file -d $dir
extracted=$(find "$dir" -type f -name "*.dungeondraft_pack")
if [[ -z "$extracted" ]]; then
echo "No .dungeondraft_pack file found in the ZIP."
rm -rf "$dir"
exit 1
fi
echo "Extracted file: $extracted"
# Extract the version number from the filename
file=$(basename "$extracted")
basename=$(echo "$file" | grep -oP '^FA_[^_]+_[^_]+')
version_rx="v([0-9]+\.[0-9]+)"
if [[ "$file" =~ v([0-9]+\.[0-9]+) ]]; then
new_version=${match[1]}
else
echo "Could not extract version number from filename."
rm -rf "$fir"
continue
fi
echo "New version detected: $new_version"
# Check for an existing file in the target directory
existing=$(ls "$target_dir"/"${basename}"_v*.dungeondraft_pack 2>/dev/null | head -n 1)
if [[ -n "$existing" ]]; then
existing_filename=$(basename "$existing")
if [[ "$existing_filename" =~ v([0-9]+\.[0-9]+) ]]; then
existing_version=${match[1]}
fi
echo "Existing file found: $existing_filename (Version: $existing_version)"
if [[ "$existing_version" == "$new_version" ]]; then
echo "Same version already exists. No action taken."
rm -rf "$dir"
exit 0
else
echo "Different version detected. Removing old version."
rm -f "$existing"
fi
fi
# Move the new file to the target directory
mv "$extracted" "$target_dir"
echo "File moved to $target_dir: $filename"
# Clean up
rm -rf "$dir"
done

View File

@@ -0,0 +1,15 @@
#! /bin/zsh
target_dir="/home/chris/Foundry/FA"
download_dir="/home/chris/Downloads"
for file in $download_dir/(Creature_Tokens|Adversaries_|Epic_Creatures_)*.zip; do
echo "Unzipping ${file}"
dir=$(mktemp -d)
unzip -qq $file -d $dir
if [[ -d "$dir/FA_Tokens" ]]
then
rsync -az "$dir/FA_Tokens/" "$target_dir/Tokens"
fi
done

40
.local/bin/nixos-todo/initwacom Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
for i in $(seq 10); do
if xsetwacom list devices | grep -q Wacom; then
break
fi
sleep 1
done
list=$(xsetwacom list devices)
column=$((echo "$list" | grep "\(WL\)" >/dev/null) && echo 9 || echo 8)
pad=$(echo "${list}" | awk "/pad/{print \$$column}")
stylus=$(echo "${list}" | awk "/stylus/{print \$$column}")
eraser=$(echo "${list}" | awk "/eraser/{print \$$column}")
if [ -z "${pad}" ]; then
exit 0
fi
first_display="$(xrandr | grep -oP "([^\s]+)(?=\sconnected)" | head -1)"
xsetwacom set "${stylus}" MapToOutput "${first_display}"
xsetwacom set "${eraser}" MapToOutput "${first_display}"
first_resolution="$(xrandr | grep -oP "(\d+x\d+)(?=[^*]+\*)" | head -1)"
IFS='x'
read -ra resolution <<< "$first_resolution"
width=31496
height="$(bc -l <<< "ratio=${resolution[0]}/${resolution[1]}; scale=0; $width/ratio")"
xsetwacom set "${stylus}" Area "0 0 $width $height"
xsetwacom set "${eraser}" Area "0 0 $width $height"
xsetwacom set "${pad}" Button 11 "key +ctrl z -ctrl"
xsetwacom set "${pad}" Button 10 "key +shift"
xsetwacom set "${pad}" Button 9 "key +ctrl"
xsetwacom set "${pad}" Button 1 "button +15"
#xsetwacom set "${pad}" Button 4 "key 0xffad"
#xsetwacom set "${pad}" Button 4 "button +5"

View File

@@ -0,0 +1,33 @@
#! /bin/bash
zip=$1
dir=$(mktemp -d)
unzip -qq $zip -d $dir
file_count=$(ls "$dir" | wc -l)
if [ $file_count = "1" ] && [ -d $(ls -d $dir/*) ]; then
dir="$dir/$(ls "$dir")"
fi
for file in $(ls "$dir"); do
if [[ $file =~ \.x86_64 ]]; then
chmod +x "$dir/$file"
fi
if [ -x "$dir/$file" ] && [ -f "$dir/$file" ]; then
exe_name="$file"
break
fi
done
if [ -n "$exe_name" ]; then
basename="${exe_name%.*}"
dest="/opt/$basename"
[ -d $dest ] && sudo rm -rf "$dest"
sudo mv -f "$dir" "$dest"
sudo chmod 755 "$dest"
exe=$(echo "$basename" | tr '[:upper:]' '[:lower:]')
sudo ln -fs "$dest/$exe_name" "/usr/bin/$exe"
fi

12
.local/bin/nixos-todo/rotdir Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# When I open an image from the file manager in sxiv (the image viewer), I want
# to be able to press the next/previous keys to key through the rest of the
# images in the same directory. This script "rotates" the content of a
# directory based on the first chosen file, so that if I open the 15th image,
# if I press next, it will go to the 16th etc. Autistic, I know, but this is
# one of the reasons that sxiv is great for being able to read standard input.
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
base="$(basename "$1")"
ls "$PWD" | awk -v BASE="$base" 'BEGIN { lines = ""; m = 0; } { if ($0 == BASE) { m = 1; } } { if (!m) { if (lines) { lines = lines"\n"; } lines = lines""$0; } else { print $0; } } END { print lines; }'

44
.local/bin/nixos-todo/setbg Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/sh
# This script does the following:
# Run by itself, set the wallpaper (at X start).
# If given a file, set that as the new wallpaper.
# If given a directory, choose random file in it.
# If wal is installed, also generates a colorscheme.
# Location of link to wallpaper link.
bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
trueloc="$(readlink -f "$1")" &&
case "$(file --mime-type -b "$trueloc")" in
image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" ;;
inode/directory ) trueloc=$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1) && ln -sf "$trueloc" "$bgloc" ;;
*) notify-send "Error" "Not a valid image." ; exit 1;;
esac
[ -z "$trueloc" ] && trueloc="$(readlink -f "$bgloc")"
# If pywal is installed, use it.
# command -v wal >/dev/null 2>&1 &&
# wal -i "$trueloc" -n -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1 &&
# dwmc xrdb
xwallpaper --no-randr --zoom "$bgloc"
parent_dir=$(dirname "$trueloc")
filename=$(basename "$trueloc")
filename_without_extension=${filename%.*}
split_dir="${parent_dir}_split"
left_image="${split_dir}/${filename_without_extension}_left.jpg"
right_image="${split_dir}/${filename_without_extension}_right.jpg"
# Check if left and right images exist
if [ -e "$left_image" ] && [ -e "$right_image" ]; then
kwriteconfig5 --file "$HOME/.config/plasma-org.kde.plasma.desktop-appletsrc" \
--group 'Containments' --group '127' --group 'Wallpaper' --group 'org.kde.image' \
--group 'General' --key 'Image' "$left_image"
kwriteconfig5 --file "$HOME/.config/plasma-org.kde.plasma.desktop-appletsrc" \
--group 'Containments' --group '94' --group 'Wallpaper' --group 'org.kde.image' \
--group 'General' --key 'Image' "$right_image"
fi

27
.local/bin/nixos-todo/shortcuts Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/sh
bmdirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs"
bmfiles="${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-files"
# Output locations. Unactivated progs should go to /dev/null.
shell_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
zsh_named_dirs="${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
lf_shortcuts="${XDG_CONFIG_HOME:-$HOME/.config}/lf/shortcutrc"
# Remove, prepare files
rm -f "$lf_shortcuts" "$zsh_named_dirs" 2>/dev/null
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
# Format the `directories` file in the correct syntax and sent it to all three configs.
eval "echo \"$(cat "$bmdirs")\"" | \
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
printf(\"%s=\42cd %s && ls\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
printf(\"map C%s cd \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" }"
# Format the `files` file in the correct syntax and sent it to both configs.
eval "echo \"$(cat "$bmfiles")\"" | \
awk "!/^\s*#/ && !/^\s*\$/ {gsub(\"\\\s*#.*$\",\"\");
printf(\"%s=\42\$EDITOR %s\42 \\\\\n\",\$1,\$2) >> \"$shell_shortcuts\" ;
printf(\"hash -d %s=%s \n\",\$1,\$2) >> \"$zsh_named_dirs\" ;
printf(\"map E%s \$\$EDITOR \42%s\42 \n\",\$1,\$2) >> \"$lf_shortcuts\" }"

29
.local/bin/nixos-todo/splitbg Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
input_dir="$1" # Replace with your input directory path
output_dir="$2" # Replace with your output directory path
# Ensure the output directory exists or create it
mkdir -p "$output_dir"
# Loop through all JPEG files in the input directory
for file in "$input_dir"/*.jpg; do
if [ -e "$file" ]; then
filename=$(basename "$file")
filename_without_extension="${filename%.*}"
output_file1="$output_dir/${filename_without_extension}_left.jpg"
output_file2="$output_dir/${filename_without_extension}_right.jpg"
# Get the width of the image
width=$(identify -format "%w" "$file")
# Use ImageMagick to split the image in half
convert "$file" -crop "50%x100%+0+0" "$output_file1"
convert "$file" -crop "50%x100%+$((width / 2))+0" "$output_file2"
echo "Split $filename into $output_file1 and $output_file2"
fi
done
echo "Splitting completed."

View File

@@ -0,0 +1,9 @@
#! /bin/bash
newzip=$1
file="$HOME/Stardust/Resources/Applications/dungeondraft.zip"
mv -f $1 $file
installzip $file