summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2023-11-24 16:19:59 -0500
committerMitsuo Tokumori <[email protected]>2023-11-24 16:19:59 -0500
commitedbe323e1df0173d1d945d69b7c2e20a5614224d (patch)
tree4520d56261507bebbc37770699d6978ff549ef67
parent55bbf64b2cd05b93aa2288769515df9a8c2ed1bd (diff)
downloaddotfiles-edbe323e1df0173d1d945d69b7c2e20a5614224d.tar.gz
dotfiles-edbe323e1df0173d1d945d69b7c2e20a5614224d.tar.bz2
dotfiles-edbe323e1df0173d1d945d69b7c2e20a5614224d.zip
Add custom scripts for desktop
-rw-r--r--local/bin/README.txt3
-rwxr-xr-xlocal/bin/rename_pictures.sh62
-rwxr-xr-xlocal/bin/setup-default-apps.sh31
3 files changed, 42 insertions, 54 deletions
diff --git a/local/bin/README.txt b/local/bin/README.txt
index 74c981b..b9207a4 100644
--- a/local/bin/README.txt
+++ b/local/bin/README.txt
@@ -2,3 +2,6 @@ My Linux executable scripts.
Notes:
* Beware of not leaking personal information
+
+I also use other people's awesome scrips. I store them in `~/code` and then
+slink the ones I use in `~/.local/bin`.
diff --git a/local/bin/rename_pictures.sh b/local/bin/rename_pictures.sh
index f2f5004..a3f2463 100755
--- a/local/bin/rename_pictures.sh
+++ b/local/bin/rename_pictures.sh
@@ -1,62 +1,16 @@
#!/bin/bash
-# Credit:
-# Mitsuo, GPT4
-# 2023年 11月 8日 水曜日 15:46:55 -05
+# Very specific script to bulk rename pictures with some format
+# (complex script for a simple task)
-# Check for proper number of command line args.
-expected_args=3
-if [ $# -ne $expected_args ]; then
- echo "Usage: $1 {prefix} {date in yyyy-mm-dd format} {file extension, e.g., jpg}"
- exit 1
-fi
+exit # just in case
-# Assign command line args to variables
-prefix=$1
-current_date=$2
-extension=$3
-
-# Validations
-if ! [[ $current_date =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
- echo "Date format is invalid. Please use yyyy-mm-dd format."
- exit 1
-fi
-
-if [[ $extension == .* ]]; then
- echo "Please provide the file extension without a leading period."
- exit 1
-fi
-
-if [[ -z $prefix ]]; then
- echo "Please provide a non-empty prefix."
- exit 1
-fi
-
-
-# Loop through all files with the given extension in the current directory
-#
-# By default, if you use a pattern that doesn't match any filenames (like *.jpg
-# when there are no .jpg files), bash will pass the pattern itself as an
-# argument to commands. For example, if there are no .jpg files in your
-# directory and you use the *.jpg pattern in a loop or command, the loop or
-# command will receive *.jpg as an input, which is probably not what you want.
shopt -s nullglob
-i=1
-for file in *$extension; do
- # Skip if the file is not a regular file
- if [[ ! -f $file ]]; then
- continue
- fi
-
- # Generate the correlative number with leading zeros
- printf -v suffix "%02d" $i
+for file in ss_*.png; do
+ date_part="${file:3:8}"
+ time_part="${file:12:6}"
+ new_name="ss-${date_part}T${time_part}0500.png"
- # Rename the file (-- is end of command line options)
- mv -- "$file" "${prefix}-${current_date}_${suffix}.${extension}"
-
- # Increment the counter
- ((i++))
+ mv "$file" "$new_name"
done
-
shopt -u nullglob
-echo "Renaming complete!"
diff --git a/local/bin/setup-default-apps.sh b/local/bin/setup-default-apps.sh
new file mode 100755
index 0000000..809824f
--- /dev/null
+++ b/local/bin/setup-default-apps.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# Set defaults for xdg-open
+#
+# For a list of MIME types see https://www.iana.org/assignments/media-types/media-types.xhtml
+
+# Useful commands:
+# xdg-mime query filetype FILE
+# xdg-mime query default MIMETYPE
+
+# File
+#pcmanfm
+
+# Image
+xdg-mime default nsxiv.desktop image/bmp image/gif image/jpeg image/jpg image/png image/tiff image/x-bmp image/x-portable-anymap image/x-portable-bitmap image/x-portable-graymap image/x-tga image/x-xpixmap image/webp image/heic image/svg+xml application/postscript image/jp2 image/jxl image/avif image/heif
+
+# Video
+#xdg-mime default mpv.desktop A_LOT_OF_MIME_TYPES
+
+# Mail
+#thunderbird
+
+# Office
+xdg-mime default org.pwmt.zathura.desktop application/pdf application/postscript image/vnd.djvu
+#libreoffice
+
+# Text
+xdg-mime default nvim.desktop text/plain
+
+# Net
+xdg-mime default org.qbittorrent.qBittorrent.desktop application/x-bittorrent x-scheme-handler/magnet