From ae144dceeb50b08b9b1a09a1876b6b2765ed79b2 Mon Sep 17 00:00:00 2001 From: Massaki Archambault Date: Sat, 12 Apr 2025 19:36:16 -0400 Subject: [PATCH] Add home/.local/bin/dump-args Add home/.local/bin/import-gsettings Add home/.local/bin/tozip Add home/.local/bin/vortex --- home/dot_local/bin/executable_dump-args | 4 + .../dot_local/bin/executable_import-gsettings | 15 ++ home/dot_local/bin/executable_tozip | 128 ++++++++++++++++++ home/dot_local/bin/executable_vortex | 2 + 4 files changed, 149 insertions(+) create mode 100644 home/dot_local/bin/executable_dump-args create mode 100644 home/dot_local/bin/executable_import-gsettings create mode 100644 home/dot_local/bin/executable_tozip create mode 100644 home/dot_local/bin/executable_vortex diff --git a/home/dot_local/bin/executable_dump-args b/home/dot_local/bin/executable_dump-args new file mode 100644 index 0000000..4f5a775 --- /dev/null +++ b/home/dot_local/bin/executable_dump-args @@ -0,0 +1,4 @@ +#!/bin/bash + +echo $@ &>/tmp/dump_args.last.log +exec $@ diff --git a/home/dot_local/bin/executable_import-gsettings b/home/dot_local/bin/executable_import-gsettings new file mode 100644 index 0000000..967620f --- /dev/null +++ b/home/dot_local/bin/executable_import-gsettings @@ -0,0 +1,15 @@ +#!/bin/sh + +# usage: import-gsettings +config="${XDG_CONFIG_HOME:-$HOME/.config}/gtk-3.0/settings.ini" +if [ ! -f "$config" ]; then exit 1; fi + +gnome_schema="org.gnome.desktop.interface" +gtk_theme="$(grep 'gtk-theme-name' "$config" | sed 's/.*\s*=\s*//')" +icon_theme="$(grep 'gtk-icon-theme-name' "$config" | sed 's/.*\s*=\s*//')" +cursor_theme="$(grep 'gtk-cursor-theme-name' "$config" | sed 's/.*\s*=\s*//')" +font_name="$(grep 'gtk-font-name' "$config" | sed 's/.*\s*=\s*//')" +gsettings set "$gnome_schema" gtk-theme "$gtk_theme" +gsettings set "$gnome_schema" icon-theme "$icon_theme" +gsettings set "$gnome_schema" cursor-theme "$cursor_theme" +gsettings set "$gnome_schema" font-name "$font_name" diff --git a/home/dot_local/bin/executable_tozip b/home/dot_local/bin/executable_tozip new file mode 100644 index 0000000..29b338c --- /dev/null +++ b/home/dot_local/bin/executable_tozip @@ -0,0 +1,128 @@ +#!/bin/bash + +print_help() { + echo "" + echo "Convert an archive to the zip format, or create a new archive" + echo "" + echo "Usage: tozip [options] ...files" + echo "" + echo "Options:" + echo " -h, --help Print this help text" + echo " -d, --delete-old Delete converted file" + echo " -f, --force Replace the file with the converted file even if the file exists" + echo " -r, --rezip Extract and archive again even if the converted file is already a zip archive" + echo " -t, --thread Set the number of threads for archive extraction and creation (default: $thread_count)" + echo "" +} + +short_args=hdfrt: +long_args=help,delete-old,force,rezip,thread: + +# default +rezip= +delete_old= +force= +thread_count=8 +params="" + +# Parse arguments +parsed_args=$(getopt --options $short_args --longoptions $long_args --name "$0" -- "$@") +if [[ $? -ne 0 ]]; then + echo "Failed to parse arguments" + exit 2 +fi +eval set -- "$parsed_args" +while true; do + case "$1" in + -h|--help) + print_help + exit 0 + ;; + -d|--delete-old) + delete_old=y + shift + ;; + -f|--force) + force=y + shift + ;; + -r|--rezip) + rezip=y + shift + ;; + -t|--thread) + thread_count="$2" + shift 2 + ;; + --) + shift + break + ;; + *) + break + ;; + esac +done + +out_dir="$PWD" + +for f in "$@"; do + tmp_dir="$(mktemp -d "$PWD/tozip.XXX")" + output="$(echo "$f" | sed -E 's/\.(zip|rar|7z)$//g').zip" + backup_file="$output".backup + do_backup= + + if [[ ! -r "$f" ]]; then + echo "$f : No such file or directory" + continue + fi + + echo "$f -> $output" + + if [[ -f "$output" ]]; then + if [[ -n "$force" ]] || [[ "$f" =~ .zip$ && -n "$rezip" ]]; then + do_backup=y + else + echo "$output : file exists, refusing to continue (-f to force)" + continue + fi + fi + + if [[ "$f" =~ \.tar|gz|bz2|zip|7z$ ]]; then + if ! 7z e -mmt="$thread_count" -o"$tmp_dir" "$f" >/dev/null; then + echo "$f : extract failed" + continue + fi + elif [[ "$f" =~ \.rar$ ]]; then + if ! unrar x "$f" "$tmp_dir" >/dev/null; then + echo "$f : unrar failed" + continue + fi + else + cp -r "$f" "$tmp_dir" + fi + + if [[ -n "$do_backup" ]]; then + mv "$output" "$backup_file" + fi + + pushd "$tmp_dir" >/dev/null + 7z a -tzip -mmt="$thread_count" "$out_dir/$output" >/dev/null + return_val=$? + popd >/dev/null + if [[ $return_val -eq 0 ]]; then + if [[ -n "$do_backup" ]]; then + rm -r "$backup_file" + elif [[ -n "$delete_old" ]]; then + rm -r "$f" + fi + else + if [[ -n "$do_backup" ]]; then + mv "$backup_file" "$output" + fi + echo "$f : zip archive failed" + fi + + rm -r "$tmp_dir" +done + diff --git a/home/dot_local/bin/executable_vortex b/home/dot_local/bin/executable_vortex new file mode 100644 index 0000000..371f01b --- /dev/null +++ b/home/dot_local/bin/executable_vortex @@ -0,0 +1,2 @@ +#!/bin/bash +protontricks-launch --appid 611670 '/data/marchambault/Games/steamapps/compatdata/611670/pfx/drive_c/Program Files/Black Tree Gaming Ltd/Vortex/Vortex.exe'