From c9fc47670d20d1be11b2181d2148350f3bb75791 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 3 Apr 2025 14:32:47 +0100 Subject: [PATCH] Updates --- .config/Code - OSS/User/settings.json | 15 +++++-- .config/zsh/.zshrc | 2 +- .local/bin/fa_dd_download | 62 +++++++++++++++++++++++++++ .local/bin/fa_token_download | 3 +- .local/bin/joplinbookedit | 10 ----- .local/bin/joplinedit | 22 ---------- .local/bin/rssadd | 18 -------- 7 files changed, 76 insertions(+), 56 deletions(-) create mode 100755 .local/bin/fa_dd_download delete mode 100755 .local/bin/joplinbookedit delete mode 100755 .local/bin/joplinedit delete mode 100755 .local/bin/rssadd diff --git a/.config/Code - OSS/User/settings.json b/.config/Code - OSS/User/settings.json index 87fb790..5b63c05 100644 --- a/.config/Code - OSS/User/settings.json +++ b/.config/Code - OSS/User/settings.json @@ -1,5 +1,9 @@ { - "editor.rulers": [80, 100, 120], + "editor.rulers": [ + 80, + 100, + 120 + ], "editor.fontLigatures": true, "files.watcherExclude": { "**/.bloop": true, @@ -18,7 +22,6 @@ "editor.codeLensFontFamily": "FiraCode", "metals.enableIndentOnPaste": true, "editor.detectIndentation": false, - "editor.defaultFormatter": "esbenp.prettier-vscode", "vetur.format.options.tabSize": 4, "monkeyC.developerKeyPath": "/home/chris/.config/connectiq/developer_key", "monkeyC.typeCheckLevel": "Off", @@ -31,5 +34,9 @@ "files.trimTrailingWhitespace": false }, "editor.formatOnPaste": true, - "editor.formatOnSave": true, -} + "[php]": { + "editor.defaultFormatter": "DEVSENSE.phptools-vscode" + }, + "prettier.tabWidth": 4, + "prettier.enable": false +} \ No newline at end of file diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 35a6897..34247f4 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -167,4 +167,4 @@ set -o ignoreeof # Stop CTRL-D from quitting # Load syntax highlighting; should be last. source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null -[ -f /etc/profile.d/autojump.sh ] && source /etc/profile.d/autojump.sh +[[ -s /etc/profile.d/autojump.sh ]] && source /etc/profile.d/autojump.sh diff --git a/.local/bin/fa_dd_download b/.local/bin/fa_dd_download new file mode 100755 index 0000000..b0efb55 --- /dev/null +++ b/.local/bin/fa_dd_download @@ -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 diff --git a/.local/bin/fa_token_download b/.local/bin/fa_token_download index d5e6038..9d9ac8f 100755 --- a/.local/bin/fa_token_download +++ b/.local/bin/fa_token_download @@ -3,7 +3,8 @@ target_dir="/home/chris/Foundry/FA" download_dir="/home/chris/Downloads" -for file in $download_dir/(FA_|Creature_Tokens)*.zip; do +for file in $download_dir/(Creature_Tokens|Adversaries_|Epic_Creatures_)*.zip; do + echo "Unzipping ${file}" dir=$(mktemp -d) unzip -qq $file -d $dir diff --git a/.local/bin/joplinbookedit b/.local/bin/joplinbookedit deleted file mode 100755 index 2e3c447..0000000 --- a/.local/bin/joplinbookedit +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash - -notebook="$(joplin ls / --sort updated_time | dmenu -i -l 30)" - -[ -z "$notebook" ] && exit 1; - -joplin use "$notebook" - -joplin - diff --git a/.local/bin/joplinedit b/.local/bin/joplinedit deleted file mode 100755 index 095059d..0000000 --- a/.local/bin/joplinedit +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/bash - -notebook="$(joplin ls / --sort updated_time | dmenu -i -l 30)" - -[ -z "$notebook" ] && exit 1; - -joplin use "$notebook" - -notes="$(joplin ls --sort updated_time --long)" - -index="$(echo "$notes" | cut -d" " -f4- | dmenu -n -ix -i -l 30 || exit 1)" - -[ -z "$index" ] && exit 1; - -line="$(($index + 1))" - -id="$(echo "$notes" | sed "${line}q;d")" - -echo "$id" - -joplin edit "$id" - diff --git a/.local/bin/rssadd b/.local/bin/rssadd deleted file mode 100755 index fb60be8..0000000 --- a/.local/bin/rssadd +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -if echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null; then - url="$1" -else - url="$(grep -Eom1 '<[^>]+(rel="self"|application/[a-z]+\+xml)[^>]+>' "$1" | - sed -E 's_^.*href="(https?://[^"]+)".*$_\1_')" - - ! grep "https*://\S\+\.[A-Za-z]\+\S*" <<<"$url" && - notify-send "That doesn't look like a full URL." && exit 1 -fi - -RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls" -if awk '{print $1}' "$RSSFILE" | grep "^$url$" >/dev/null; then - notify-send "You already have this RSS feed." -else - echo "$url" >> "$RSSFILE" && notify-send "RSS feed added." -fi