diff options
Diffstat (limited to 'ar/.local')
27 files changed, 308 insertions, 305 deletions
diff --git a/ar/.local/bin/bookmarks b/ar/.local/bin/bookmarks index 4387966..dd5f969 100755 --- a/ar/.local/bin/bookmarks +++ b/ar/.local/bin/bookmarks @@ -163,16 +163,16 @@ openinbrowser() { } geturls() { - URLS=$(cat ~/.config/qutebrowser/quickmarks ~/.config/qutebrowser/bookmarks/urls ~/.local/share/thesiah/snippets ~/.local/share/thesiah/urls 2>/dev/null) - CHOICE=$(echo "$URLS" | grep -v -e '^#' -e '^$' | awk ' + urls=$(cat ~/.config/qutebrowser/quickmarks ~/.config/qutebrowser/bookmarks/urls ~/.local/share/thesiah/snippets ~/.local/share/thesiah/urls 2>/dev/null) + CHOICE=$(echo "$urls" | grep -v -e '^#' -e '^$' | awk ' { if ($1 ~ /^https?:\/\//) { alias = substr($0, index($0, $2)) } # Case 2: URL first else { alias = substr($0, 1, length($0) - length($NF) - 1) } # Case 1: URL last print alias }' | dmenu -i -l 50 -p "Choose an alias $1:") - [ -z "$CHOICE" ] && exit - URL=$(echo "$URLS" | grep -v -e '^#' -e '^$' | awk -v choice="$CHOICE" ' + [ -z "$choice" ] && exit + url=$(echo "$urls" | grep -v -e '^#' -e '^$' | awk -v choice="$choice" ' { if ($1 ~ /^https?:\/\//) { url = $1; alias = substr($0, index($0, $2)) } # Case 2 else { alias = substr($0, 1, length($0) - length($NF) - 1); url = $NF } # Case 1 @@ -182,16 +182,16 @@ geturls() { copytoclipboard() { if command -v xclip >/dev/null 2>&1; then - printf "%s" "$URL" | xclip -selection clipboard + printf "%s" "$url" | xclip -selection clipboard elif command -v clipcopy >/dev/null 2>&1; then - printf "%s" "$URL" | clipcopy + printf "%s" "$url" | clipcopy elif command -v xsel >/dev/null 2>&1; then - printf "%s" "$URL" | xsel --clipboard --input + printf "%s" "$url" | xsel --clipboard --input else echo "Clipboard utility not found. Install xclip, clipcopy, or xsel." >&2 exit 1 fi - notify-send "'$CHOICE' copied in clipbaord" "$URL" + notify-send "'$choice' copied in clipbaord" "$url" } [ $# -eq 0 ] && usage && exit 1 @@ -204,7 +204,7 @@ while getopts "abchopstv" opt; do o) geturls "to open in $BROWSER" && openwindow ;; p) geturls "to open in private $BROWSER" && openwindow private ;; s) openinbrowser "history" ;; - t) geturls "to type under cursor" && xdotool type "$URL" ;; + t) geturls "to type under cursor" && xdotool type "$url" ;; v) openinbrowser "private bookmark" ;; h | *) usage && exit 0 ;; esac diff --git a/ar/.local/bin/browse b/ar/.local/bin/browse index 5deffdd..976e2a4 100755 --- a/ar/.local/bin/browse +++ b/ar/.local/bin/browse @@ -14,8 +14,8 @@ usage() { } # Set default values -SEARCH_TOOL="web" -SEARCH_ENGINE="searx" +search_tool="web" +search_engine="searx" # Determine the open command based on the operating system case "$(uname -s)" in @@ -35,35 +35,35 @@ case "$1" in echo "Error: ddgr is not installed." >&2 exit 1 fi - SEARCH_TOOL="ddgr" + search_tool="ddgr" shift # Remove this argument from the list ;; -h | --help | help) usage && exit 0 ;; bing | duckduckgo | google | naver | yahoo | youtube) - SEARCH_ENGINE="$1" + search_engine="$1" shift # Remove the search engine from the list ;; esac # Store the remaining arguments as the search query -SEARCH_QUERY="$*" +search_query="$*" # Ensure a search query is provided; if not, show usage -[ -z "$SEARCH_QUERY" ] && usage && exit 1 +[ -z "$search_query" ] && usage && exit 1 # Execute the corresponding search tool using case -case $SEARCH_TOOL in +case $search_tool in ddgr) # Run DuckDuckGo search in the terminal - setsid -f "$TERMINAL" -e ddgr "$SEARCH_QUERY" + setsid -f "$TERMINAL" -e ddgr "$search_query" ;; web) # Construct the URL based on the search engine - case "$SEARCH_ENGINE" in + case "$search_engine" in bing | google | yahoo | youtube) - base_url="https://www.${SEARCH_ENGINE}.com/search?q=" + base_url="https://www.${search_engine}.com/search?q=" ;; duckduckgo) base_url="https://duckduckgo.com/?q=" @@ -77,10 +77,10 @@ web) esac # Encode the search query - SEARCH_QUERY_ENCODED=$(echo "$SEARCH_QUERY" | sed 's/ /+/g') + search_query_encoded=$(echo "$search_query" | sed 's/ /+/g') # Open the search URL in the default browser - $open_cmd "${base_url}${SEARCH_QUERY_ENCODED}" + $open_cmd "${base_url}${search_query_encoded}" ;; *) usage && exit 1 diff --git a/ar/.local/bin/browserprofile b/ar/.local/bin/browserprofile index 525eed4..c66f183 100755 --- a/ar/.local/bin/browserprofile +++ b/ar/.local/bin/browserprofile @@ -1,9 +1,9 @@ #!/bin/sh # Define the profile paths -WORK_PROFILE="$USER.work" -HOME_PROFILE="$USER.default" -TMUX_PROFILE="$USER.tmux" +work_profile="$USER.work" +home_profile="$USER.default" +tmux_profile="$USER.tmux" usage() { echo "Update the default profile in profiles.ini for Firefox or Librewolf." @@ -18,9 +18,9 @@ usage() { echo " -l/librewolf" echo " <profile_type> : (Optional) If not specified, the default profile will be used." echo " Accepted values:" - echo " work: Sets the work profile ($WORK_PROFILE)" - echo " default: Sets the home profile ($HOME_PROFILE)" - echo " tmux: Sets the home profile ($TMUX_PROFILE)" + echo " work: Sets the work profile ($work_profile)" + echo " default: Sets the home profile ($home_profile)" + echo " tmux: Sets the home profile ($tmux_profile)" echo "" echo "Examples:" echo " ${0##*/} -f -w # Set the work profile for Firefox" @@ -84,13 +84,13 @@ update_profile() { # Set the profile based on the input case "$profile_type" in -w | --work | work) - update_profiles_ini "$browser" "$WORK_PROFILE" + update_profiles_ini "$browser" "$work_profile" ;; -d | --default | default) - update_profiles_ini "$browser" "$HOME_PROFILE" + update_profiles_ini "$browser" "$home_profile" ;; -t | --tmux | tmux) - update_profiles_ini "$browser" "$TMUX_PROFILE" + update_profiles_ini "$browser" "$tmux_profile" ;; *) echo "Invalid profile type. Please use 'work' or 'default'." diff --git a/ar/.local/bin/cron/crontog b/ar/.local/bin/cron/crontog index 9ebab9c..70e7cf1 100755 --- a/ar/.local/bin/cron/crontog +++ b/ar/.local/bin/cron/crontog @@ -3,7 +3,7 @@ # Toggles all cronjobs off/on. # Stores disabled crontabs in ~/.config/crons until restored. -CRON_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/crons" +cron_file="${XDG_CONFIG_HOME:-$HOME/.config}/crons" # Check if there are any active cronjobs if crontab -l 2>/dev/null | grep -q '^[^#[:space:]]'; then @@ -13,9 +13,9 @@ if crontab -l 2>/dev/null | grep -q '^[^#[:space:]]'; then notify-send "⏰ Cronjobs saved and disabled." else # If no active cronjobs are found, try re-enabling from saved file - if [ -f "$CRON_FILE" ]; then - crontab - <"$CRON_FILE" - rm "$CRON_FILE" + if [ -f "$cron_file" ]; then + crontab - <"$cron_file" + rm "$cron_file" notify-send "🕓 Cronjobs re-enabled." else notify-send "🕰️ No saved cronjobs to re-enable." diff --git a/ar/.local/bin/dmenubrowse b/ar/.local/bin/dmenubrowse index 8d481eb..f894491 100755 --- a/ar/.local/bin/dmenubrowse +++ b/ar/.local/bin/dmenubrowse @@ -1,44 +1,44 @@ #!/bin/sh # Use dmenu to choose a search option -SEARCH_TOOL=$(printf "Searx\nDuckDuckGo\nWebsite\nYouTube" | dmenu -i -p "Which option?") +search_tool=$(printf "Searx\nDuckDuckGo\nWebsite\nYouTube" | dmenu -i -p "Which option?") # Exit if no option is selected -[ -z "$SEARCH_TOOL" ] && exit 1 +[ -z "$search_tool" ] && exit 1 # Determine the command to execute based on the search tool -case "$SEARCH_TOOL" in +case "$search_tool" in "Searx") # Searx can be run directly in the browser - TOOL="browse" + tool="browse" ;; "DuckDuckGo") # For DuckDuckGo, run ddgr in the terminal - TOOL="$TERMINAL -e browse -d" + tool="$TERMINAL -e browse -d" ;; "Website") # Ask the user for the website - SITE=$(printf "bing\ngoogle\nnaver\nyahoo\nyoutube" | dmenu -i -p "Which site?") + site=$(printf "bing\ngoogle\nnaver\nyahoo\nyoutube" | dmenu -i -p "Which site?") # Exit if no site is provided - [ -z "$SITE" ] && exit 1 + [ -z "$site" ] && exit 1 # For website searches, run ddgr in the terminal with the website option - TOOL="$TERMINAL -e browse $SITE" + tool="$TERMINAL -e browse $site" ;; "YouTube") - TOOL="browse -y" + tool="browse -y" ;; *) - TOOL="browse" + tool="browse" ;; esac # Get the search query from the user -SEARCH_QUERY=$(echo | dmenu -i -p "Search: ") +search_query=$(echo | dmenu -i -p "Search: ") # Exit if no search query is provided -[ -z "$SEARCH_QUERY" ] && exit 1 +[ -z "$search_query" ] && exit 1 # Execute the command -$TOOL "$SEARCH_QUERY" +$tool "$search_query" diff --git a/ar/.local/bin/dmenuvirt b/ar/.local/bin/dmenuvirt index 615c557..bc90680 100755 --- a/ar/.local/bin/dmenuvirt +++ b/ar/.local/bin/dmenuvirt @@ -1,28 +1,28 @@ #!/bin/sh # Select action -CHOICE=$(printf "virt-manager\nstart\nshutdown" | dmenu -i -p "Choose an action:") -[ -z "$CHOICE" ] && exit 1 +choice=$(printf "virt-manager\nstart\nshutdown" | dmenu -i -p "Choose an action:") +[ -z "$choice" ] && exit 1 # Get list of VMs based on state -case "$CHOICE" in +case "$choice" in virt-manager) setsid -f virt-manager && exit ;; -start) VMLIST=$(virsh --connect qemu:///system list --all | awk '/shut off/ {print $2}') ;; -shutdown) VMLIST=$(virsh --connect qemu:///system list --all | awk '/running/ {print $2}') ;; +start) vmlist=$(virsh --connect qemu:///system list --all | awk '/shut off/ {print $2}') ;; +shutdown) vmlist=$(virsh --connect qemu:///system list --all | awk '/running/ {print $2}') ;; *) exit 1 ;; esac # Select a VM from the list -VM=$(printf "%s\n" "$VMLIST" | dmenu -i -p "$CHOICE which VM?") -[ -z "$VM" ] && exit 1 +vm=$(printf "%s\n" "$vmlist" | dmenu -i -p "$choice which VM?") +[ -z "$vm" ] && exit 1 # Perform the action -case "$CHOICE" in +case "$choice" in start) - virsh --connect qemu:///system start "$VM" && - setsid -f virt-viewer --connect qemu:///system "$VM" >/dev/null 2>&1 + virsh --connect qemu:///system start "$vm" && + setsid -f virt-viewer --connect qemu:///system "$vm" >/dev/null 2>&1 ;; shutdown) - virsh --connect qemu:///system shutdown "$VM" + virsh --connect qemu:///system shutdown "$vm" ;; esac diff --git a/ar/.local/bin/ecrypt b/ar/.local/bin/ecrypt index 67b705d..e13c033 100755 --- a/ar/.local/bin/ecrypt +++ b/ar/.local/bin/ecrypt @@ -1,8 +1,8 @@ #!/bin/sh mount_encrypted() { - ! mount | grep -q " $1 " && echo "$PASSPHRASE" | sudo mount -t ecryptfs "$1" "$2" \ - -o ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_passthrough=no,ecryptfs_enable_filename_crypto=yes,ecryptfs_sig=$ECRYPTFS_SIG,ecryptfs_fnek_sig=$FNEK_SIG,key=passphrase:passphrase_passwd=$(printf '%s' "$PASSPHRASE") + ! mount | grep -q " $1 " && echo "$passphrase" | sudo mount -t ecryptfs "$1" "$2" \ + -o ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_passthrough=no,ecryptfs_enable_filename_crypto=yes,ecryptfs_sig=$ecryptfs_sig,ecryptfs_fnek_sig=$fnek_sig,key=passphrase:passphrase_passwd=$(printf '%s' "$passphrase") } attempt_mount() { @@ -13,10 +13,10 @@ attempt_mount() { notify-send "❗ Unable to lock" "Mounted: $3" fi else - ECRYPTFS_SIG=$(pass show encryption/ecryptfs-sig-"$4") - FNEK_SIG=$ECRYPTFS_SIG - PASSPHRASE=$(pass show encryption/ecryptfs) - [ -z "$PASSPHRASE" ] && { + ecryptfs_sig=$(pass show encryption/ecryptfs-sig-"$4") + fnek_sig=$ecryptfs_sig + passphrase=$(pass show encryption/ecryptfs) + [ -z "$passphrase" ] && { notify-send "❌ Failed to retrieve passphrase." exit 1 } diff --git a/ar/.local/bin/emojiupdate b/ar/.local/bin/emojiupdate index 861c9b0..7185a4d 100755 --- a/ar/.local/bin/emojiupdate +++ b/ar/.local/bin/emojiupdate @@ -1,34 +1,18 @@ #!/bin/sh -## -## For fontawesome icons update, run the command block in terminal. -## -# curl -sSL -o icons_raw.json "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/metadata/icons.json" && -# jq -r 'to_entries[] | select(.value.unicode) | .value.unicode + " " + .key' "icons_raw.json" | -# while read -r hex name; do -# hex_uc=$(printf '%s' "$hex" | tr '[:lower:]' '[:upper:]') -# if [ "${#hex_uc}" -le 4 ]; then -# unicode="\\u$hex_uc" -# else -# unicode="\\U$(printf '%08X' "0x$hex_uc")" -# fi -# -# printf "%b %s; %s\n" "$unicode" "$name" "$hex" -# done > "${XDG_DOTFILES_DIR:-$HOME/.dotfiles}/global/.local/share/thesiah/chars/icons" - # Define input and output files -URL="https://unicode.org/Public/emoji/latest/emoji-test.txt" -INPUT_FILE="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/.local/share/thesiah/chars/emoji_raw" -TEMP_FILE="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/.local/share/thesiah/chars/emoji_temp" -OUTPUT_FILE="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/.local/share/thesiah/chars/emoji" +url="https://unicode.org/Public/emoji/latest/emoji-test.txt" +input_file="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/.local/share/thesiah/chars/emoji_raw" +temp_file="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/.local/share/thesiah/chars/emoji_temp" +output_file="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/.local/share/thesiah/chars/emoji" # Create the directory for output files if it doesn't exist -mkdir -p "$(dirname "$INPUT_FILE")" +mkdir -p "$(dirname "$input_file")" # Download the emoji file echo "Downloading emoji-test.txt from Unicode..." -if curl -o "$INPUT_FILE" -L "$URL"; then - echo "Download complete! File saved to: $INPUT_FILE" +if curl -o "$input_file" -L "$url"; then + echo "Download complete! File saved to: $input_file" else echo "Failed to download emoji" exit 1 @@ -49,7 +33,7 @@ awk ' # Print valid lines { print } -' "$INPUT_FILE" >"$TEMP_FILE" +' "$input_file" >"$temp_file" # Second stage: Extract emoji and description awk -F'#' ' @@ -75,7 +59,7 @@ awk -F'#' ' print emoji, description } } -' "$TEMP_FILE" >"$OUTPUT_FILE" +' "$temp_file" >"$output_file" -rm -rf "$INPUT_FILE" "$TEMP_FILE" -echo "Processing complete! File saved to: $OUTPUT_FILE" +rm -rf "$input_file" "$temp_file" +echo "Processing complete! File saved to: $output_file" diff --git a/ar/.local/bin/fzfpass b/ar/.local/bin/fzfpass index 7180e6d..5190f8e 100755 --- a/ar/.local/bin/fzfpass +++ b/ar/.local/bin/fzfpass @@ -26,14 +26,14 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then usage fi -PASSDIR=${PASSWORD_STORE_DIR:-$HOME/.local/share/.password-store} -cd "$PASSDIR" +passdir=${PASSWORD_STORE_DIR:-$HOME/.local/share/.password-store} +cd "$passdir" # Unlock the password for this session pass show "$(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g' | sed 's/^..//' | head -n 1)" >/dev/null # Main fzf session -PASSFILE=$( +passfile=$( tree -Ffi | grep '.gpg' | sed 's/.gpg$//g' | sed 's/^..//' | fzf-tmux \ --header="🔑 Password Manager" \ @@ -57,27 +57,27 @@ fi' < /dev/tty > /dev/tty 2>&1)+reload(tree -Ffi | grep '.gpg' | sed 's/.gpg$//g --bind="tab:replace-query" ) -SHOW_PASSDATA=false +show_passdata=false if [ "$1" = "-i" ]; then - SHOW_PASSDATA=true + show_passdata=true shift fi -if [ "$SHOW_PASSDATA" = true ]; then - PASSDATA="$(pass "$PASSFILE")" - echo "$PASSDATA" +if [ "$show_passdata" = true ]; then + passdata="$(pass "$passfile")" + echo "$passdata" else - PASSWORD="$(pass show "$PASSFILE" | head -n 1)" - echo "$PASSWORD" + password="$(pass show "$passfile" | head -n 1)" + echo "$password" - if [ -n "$PASSWORD" ]; then + if [ -n "$password" ]; then case "$(uname)" in Darwin*) - printf "%s" "$PASSWORD" | pbcopy # Use pbcopy on macOS + printf "%s" "$password" | pbcopy # Use pbcopy on macOS ;; Linux*) - printf "%s" "$PASSWORD" | xclip -selection clipboard # Use xclip on Linux + printf "%s" "$password" | xclip -selection clipboard # Use xclip on Linux ;; *) echo "Unsupported operating system" diff --git a/ar/.local/bin/getbib b/ar/.local/bin/getbib index c90d864..1eb0731 100755 --- a/ar/.local/bin/getbib +++ b/ar/.local/bin/getbib @@ -1,10 +1,10 @@ #!/bin/sh -BIB_FILE="${HOME}/latex/uni.bib" -[ -f "${BIB_FILE}" ] || BIB_FILE="${2:-$(find "${HOME}" -path "${HOME}/.*" \ +bib_file="${HOME}/latex/uni.bib" +[ -f "${bib_file}" ] || bib_file="${2:-$(find "${HOME}" -path "${HOME}/.*" \ -prune -o -type "f" -name "*.bib" -print -quit)}" -{ [ -f "${BIB_FILE}" ] || [ "${2}" ]; } || { +{ [ -f "${bib_file}" ] || [ "${2}" ]; } || { printf "%s\n" "Create a .bib file or provide as \$2." && exit "1" } @@ -50,11 +50,11 @@ doi2bib() { return "1" } - grep -iFq "doi = {${doi}}" "${BIB_FILE}" 2>"/dev/null" && { + grep -iFq "doi = {${doi}}" "${bib_file}" 2>"/dev/null" && { printf "%s\n" "Bibtex entry for DOI: ${doi} already exists in the file." } || { - [ -s "${BIB_FILE}" ] && printf "\n" >>"${BIB_FILE}" - printf "%s\n" "${entry}" >>"${BIB_FILE}" + [ -s "${bib_file}" ] && printf "\n" >>"${bib_file}" + printf "%s\n" "${entry}" >>"${bib_file}" printf "%s\n" "Added bibtex entry for DOI: ${doi}" } } diff --git a/ar/.local/bin/iconupdate b/ar/.local/bin/iconupdate new file mode 100755 index 0000000..0a1aebb --- /dev/null +++ b/ar/.local/bin/iconupdate @@ -0,0 +1,19 @@ +#!/bin/bash + +icons="${XDG_DOTFILES_DIR:-$HOME/.dotfiles}/global/.local/share/thesiah/chars/icons" +tmpfile="$(mktemp)" + +curl -sSL -o "$tmpfile" "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/metadata/icons.json" || exit 1 + +while read -r hex name; do + hex_uc=$(printf '%s' "$hex" | tr '[:lower:]' '[:upper:]') + if [[ ${#hex_uc} -le 4 ]]; then + unicode="\\u$hex_uc" + else + unicode="\\U$(printf '%08X' "0x$hex_uc")" + fi + printf "%b %s; %s\n" "$unicode" "$name" "$hex" +done < <(jq -r 'to_entries[] | select(.value.unicode) | .value.unicode + " " + .key' "$tmpfile") >"$icons" + +rm -f "$tmpfile" +echo "Processing complete! icons saved to: $icons" diff --git a/ar/.local/bin/iwaf b/ar/.local/bin/iwaf index 7e3aad3..89b10b2 100755 --- a/ar/.local/bin/iwaf +++ b/ar/.local/bin/iwaf @@ -1,38 +1,38 @@ #!/bin/sh _check_wine() { - WINE_EXE="$1" + wine_exe="$1" - ls "${WINE_EXE}" >/dev/null 2>/dev/null + ls "${wine_exe}" >/dev/null 2>/dev/null } _exec_wine() { - WINE_EXE="$1" - WINE_EXE2="${WINE_EXE%/*}" - WINE_EXE2="${WINE_EXE2}/SOOPStreamer.exe" + wine_exe="$1" + wine_exe2="${wine_exe%/*}" + wine_exe2="${wine_exe2}/SOOPStreamer.exe" echo 'Executing Soop...' - wine "${WINE_EXE}" - # wine "${WINE_EXE2}" + wine "${wine_exe}" + # wine "${wine_exe2}" } _install_wine() { # Source URL for the SOOPStreamer installer - SRC_URL='https://creatorup.sooplive.co.kr/SOOPStreamer_installer.exe' + src_url='https://creatorup.sooplive.co.kr/SOOPStreamer_installer.exe' # Create a temporary file for the installer - DST_FILE="$(mktemp)" + dst_file="$(mktemp)" # Ensure the temporary file is removed after the script finishes - trap 'rm -f "$DST_FILE"' EXIT + trap 'rm -f "$dst_file"' EXIT # Set a temporary HOME for the Wine process to avoid conflicts - HOME_ORIGIN="$HOME" - HOME_PATCH="$WINEPREFIX/tmp" - export HOME="$HOME_PATCH" + home_origin="$HOME" + home_patch="$WINEPREFIX/tmp" + export HOME="$home_patch" # Download the installer echo 'Downloading SOOP Streamer installer...' - curl -s "$SRC_URL" -o "$DST_FILE" || { + curl -s "$src_url" -o "$dst_file" || { echo "Failed to download installer!" exit 1 } @@ -58,14 +58,14 @@ _install_wine() { # Run the SOOP Streamer installer without sudo echo 'Running the SOOP Streamer installer...' - wine "$DST_FILE" /S >/dev/null 2>&1 && success=true || success=false + wine "$dst_file" /S >/dev/null 2>&1 && success=true || success=false # Clean up temporary Wine HOME directory echo 'Cleaning up...' - rm -rf "$HOME_PATCH" + rm -rf "$home_patch" # Restore original HOME and WINEARCH variables - export HOME="$HOME_ORIGIN" + export HOME="$home_origin" # Check success status and print the result if $success; then @@ -84,13 +84,13 @@ main() { export WINEPREFIX="${WINEPREFIX:-${XDG_DATA_HOME:-${HOME}/.local/share}/wine}/soop" # Install - WINE_EXE="${WINEPREFIX}/drive_c/users/$(whoami)/AppData/Local/SOOP/SOOPPackage.exe" - if ! _check_wine "${WINE_EXE}"; then - _install_wine "${WINE_EXE}" + wine_exe="${WINEPREFIX}/drive_c/users/$(whoami)/AppData/Local/SOOP/SOOPPackage.exe" + if ! _check_wine "${wine_exe}"; then + _install_wine "${wine_exe}" fi # Exec - _exec_wine "${WINE_EXE}" + _exec_wine "${wine_exe}" } main diff --git a/ar/.local/bin/mpdmenu b/ar/.local/bin/mpdmenu index e6634fd..126a876 100755 --- a/ar/.local/bin/mpdmenu +++ b/ar/.local/bin/mpdmenu @@ -1,7 +1,7 @@ #!/bin/bash all_name='[ALL]' -PLAYLIST_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}/mpd/playlists" +playlist_dir="${XDG_CONFIG_HOME:-${HOME}/.config}/mpd/playlists" # Functions d_artist() { @@ -31,7 +31,7 @@ d_title() { } d_playlist() { - playlists=$(find "$PLAYLIST_DIR" \( -type f -o -type l \) -name "*.m3u" -exec basename {} .m3u \;) + playlists=$(find "$playlist_dir" \( -type f -o -type l \) -name "*.m3u" -exec basename {} .m3u \;) selected_playlist=$(echo "$playlists" | sort | dmenu -i -p "Select Playlist:" "${dmenu_args[@]}") diff --git a/ar/.local/bin/mpvplay b/ar/.local/bin/mpvplay index 61c613e..08d43ed 100755 --- a/ar/.local/bin/mpvplay +++ b/ar/.local/bin/mpvplay @@ -1,11 +1,11 @@ #!/bin/sh -MOUNT_SCRIPT="${XDG_SCRIPTS_HOME:-${HOME}/.local/bin}/ecrypt" -DB_PATH="$HOME/.local/share/history/mpv.sqlite" +mount_script="${XDG_SCRIPTS_HOME:-${HOME}/.local/bin}/ecrypt" +db_path="$HOME/.local/share/history/mpv.sqlite" -check_mount() { findmnt "$HOME/Private" >/dev/null || $MOUNT_SCRIPT; } +check_mount() { findmnt "$HOME/Private" >/dev/null || $mount_script; } -check_unmount() { findmnt "$HOME/Private" >/dev/null && $MOUNT_SCRIPT; } +check_unmount() { findmnt "$HOME/Private" >/dev/null && $mount_script; } loginurl() { notify-send "🔑 Authentication required" @@ -36,12 +36,12 @@ play_media() { if grep -q "/home/$USER/Private" "$playlist_file"; then mpv "$@" && check_unmount || exit else - $MOUNT_SCRIPT && mpv "$@" || exit + $mount_script && mpv "$@" || exit fi elif echo "$1" | grep -q "/home/$USER/Private"; then mpv "$@" && check_unmount || exit else - $MOUNT_SCRIPT && mpv "$@" || exit + $mount_script && mpv "$@" || exit fi } @@ -61,8 +61,8 @@ tmp_playlist() { list_and_play() { dir=$1 - CHOICE=$(printf "List files\nEnter filenames" | dmenu -i -p "Choose an option:") - case "$CHOICE" in + choice=$(printf "List files\nEnter filenames" | dmenu -i -p "Choose an option:") + case "$choice" in "Enter filenames") search_term=$(echo | dmenu -i -p "File names:") [ -z "$search_term" ] && echo "Invalid search term \"$search_term\"" && exit @@ -82,11 +82,11 @@ list_and_play() { files_with_paths=$(find "$dir" -mindepth 1 -maxdepth 1 \ -type f \( -iname "*.mp4" -o -iname "*.mkv" -o -iname "*.mov" -o -iname "*.flv" -o -iname "*.wmv" -o -iname "*.webm" -o -iname "*.mpeg" -o -iname "*.mpg" -o -iname "*.avi" -o -iname "*.ts" -o -iname "*.3gp" -o -iname "*.rmvb" \) | sort) - SELECTED_FILE=$(printf "All files\n%s" "$files_with_paths" | sed 's|.*/||' | dmenu -i -l 21 -p "Select a file:") - [ -z "$SELECTED_FILE" ] && echo "No file selected." && exit - [ "$SELECTED_FILE" = "All files" ] && tmp_playlist "$dir" && return - FULL_PATH="$(echo "$files_with_paths" | grep -F "$SELECTED_FILE")" - [ -f "$FULL_PATH" ] && play_media "$FULL_PATH" && return + selected_file=$(printf "All files\n%s" "$files_with_paths" | sed 's|.*/||' | dmenu -i -l 21 -p "Select a file:") + [ -z "$selected_file" ] && echo "No file selected." && exit + [ "$selected_file" = "All files" ] && tmp_playlist "$dir" && return + full_path="$(echo "$files_with_paths" | grep -F "$selected_file")" + [ -f "$full_path" ] && play_media "$full_path" && return ;; *) return ;; esac @@ -94,14 +94,14 @@ list_and_play() { history_play() { # Check if the database exists - if [ ! -f "$DB_PATH" ]; then - echo "Error: SQLite database not found at $DB_PATH" >&2 + if [ ! -f "$db_path" ]; then + echo "Error: SQLite database not found at $db_path" >&2 exit 1 fi # Query the database for the latest distinct files by path, formatting time_pos as HH:MM:SS - HISTORY=$( - sqlite3 "$DB_PATH" <<EOF + history=$( + sqlite3 "$db_path" <<EOF WITH LatestFiles AS ( SELECT path, title, time_pos, MAX(date) AS max_date FROM loaded_items @@ -130,80 +130,80 @@ EOF ) # Check if there are any results - if [ -z "$HISTORY" ]; then + if [ -z "$history" ]; then echo "No history items found in the database." >&2 exit 1 fi # Create a temporary file for filtered results - TEMP_FILE=$(mktemp) + temp_file=$(mktemp) # Filter out entries with non-existing files - echo "$HISTORY" | while IFS= read -r line; do - FILE_PATH=$(printf '%s\n' "$line" | awk -F ' \\| ' '{print $1}') - if [ -f "$FILE_PATH" ]; then - printf '%s\n' "$line" >>"$TEMP_FILE" + echo "$history" | while IFS= read -r line; do + file_path=$(printf '%s\n' "$line" | awk -F ' \\| ' '{print $1}') + if [ -f "$file_path" ]; then + printf '%s\n' "$line" >>"$temp_file" fi done # Check if there are valid entries after filtering - if [ ! -s "$TEMP_FILE" ]; then + if [ ! -s "$temp_file" ]; then echo "No valid history items found (all files missing)." >&2 - rm -f "$TEMP_FILE" + rm -f "$temp_file" exit 1 fi # Display results in dmenu and get the user's choice - CHOSEN=$(dmenu -i -l 20 -p "Choose a file to play:" <"$TEMP_FILE") - rm -f "$TEMP_FILE" + chosen=$(dmenu -i -l 20 -p "Choose a file to play:" <"$temp_file") + rm -f "$temp_file" # Check if the user made a selection - if [ -z "$CHOSEN" ]; then + if [ -z "$chosen" ]; then echo "No file selected." >&2 exit 1 fi # Extract the file path and formatted time position from the selected item - FILE_PATH=$(printf '%s\n' "$CHOSEN" | awk -F ' \\| ' '{print $1}') - FORMATTED_TIME=$(printf '%s\n' "$CHOSEN" | awk -F ' \\| ' '{print $3}') + file_path=$(printf '%s\n' "$chosen" | awk -F ' \\| ' '{print $1}') + formatted_time=$(printf '%s\n' "$chosen" | awk -F ' \\| ' '{print $3}') # Convert the formatted time back to seconds for mpv - TIME_POS=$(printf '%s\n' "$FORMATTED_TIME" | awk -F: '{print ($1 * 3600) + ($2 * 60) + $3}') + time_pos=$(printf '%s\n' "$formatted_time" | awk -F: '{print ($1 * 3600) + ($2 * 60) + $3}') # Play the file with mpv, resuming from the saved time position - if [ "$TIME_POS" -gt 0 ]; then - mpv --start="$TIME_POS" "$FILE_PATH" + if [ "$time_pos" -gt 0 ]; then + mpv --start="$time_pos" "$file_path" else - mpv "$FILE_PATH" + mpv "$file_path" fi } -CONTENT_CHOICE=$(printf "URL\nLocal Files\nPlaylist\nHistory" | dmenu -i -p "Choose media source:") -case "$CONTENT_CHOICE" in +content_choice=$(printf "URL\nLocal Files\nPlaylist\nHistory" | dmenu -i -p "Choose media source:") +case "$content_choice" in "URL") play_url ;; "Playlist") - PLAYLIST=$(find "$HOME/.config/mpv/playlists" -maxdepth 1 -type f -name "*.m3u" -exec basename {} .m3u \; | dmenu -i -p "Select a playlist:") - [ -z "$PLAYLIST" ] && exit - play_playlist "$HOME/.config/mpv/playlists/$PLAYLIST.m3u" + playlist=$(find "$HOME/.config/mpv/playlists" -maxdepth 1 -type f -name "*.m3u" -exec basename {} .m3u \; | dmenu -i -p "Select a playlist:") + [ -z "$playlist" ] && exit + play_playlist "$HOME/.config/mpv/playlists/$playlist.m3u" ;; "Local Files") check_mount printf "%s\n%s\n%s\n%s\n%s\n%s\n" "$HOME/Downloads" "$HOME/Private" "$HOME/Torrents/complete" "$HOME/Videos" "/media/$USER" "/mnt/second" | dmenu -i -p "Choose your initial directory:" | { read -r init_dir - [ -z "$init_dir" ] && $MOUNT_SCRIPT && exit - SELECTED_DIR="$init_dir" + [ -z "$init_dir" ] && $mount_script && exit + selected_dir="$init_dir" while true; do - SUBDIR_OPTIONS="$(find "$SELECTED_DIR" -mindepth 1 -maxdepth 1 -type d ! -name ".*" -printf "%P\n" | sort)" - [ -z "$SUBDIR_OPTIONS" ] && list_and_play "$SELECTED_DIR" && break - OPTIONS="All files\n$SUBDIR_OPTIONS" - SELECTED_RELATIVE_DIR="$(printf "%b" "$OPTIONS" | dmenu -i -p "Select a directory or 'All files':")" - [ -z "$SELECTED_RELATIVE_DIR" ] && echo "No relative directory." && exit - [ "$SELECTED_RELATIVE_DIR" = "All files" ] && list_and_play "$SELECTED_DIR" && break - SELECTED_DIR="$SELECTED_DIR/$SELECTED_RELATIVE_DIR" + subdir_options="$(find "$selected_dir" -mindepth 1 -maxdepth 1 -type d ! -name ".*" -printf "%P\n" | sort)" + [ -z "$subdir_options" ] && list_and_play "$selected_dir" && break + options="All files\n$subdir_options" + selected_relative_dir="$(printf "%b" "$options" | dmenu -i -p "Select a directory or 'All files':")" + [ -z "$selected_relative_dir" ] && echo "No relative directory." && exit + [ "$selected_relative_dir" = "All files" ] && list_and_play "$selected_dir" && break + selected_dir="$selected_dir/$selected_relative_dir" done } ;; -"History") history_play ;; +"history") history_play ;; *) exit ;; esac diff --git a/ar/.local/bin/opentasktui b/ar/.local/bin/opentasktui index fa9ec5c..1db6bef 100755 --- a/ar/.local/bin/opentasktui +++ b/ar/.local/bin/opentasktui @@ -4,7 +4,7 @@ current_session=$(tmux display-message -p '#S') # Parse the task description from the argument -TASK_DESCRIPTION="$1" +task_description="$1" # Create a new tmux session named 'new-task-session' and run 'tui -r current' tmux new-session -d -s new-task-session "taskwarrior-tui -r current" @@ -13,7 +13,7 @@ tmux new-session -d -s new-task-session "taskwarrior-tui -r current" sleep 0.1 # Send the keystrokes needed to filter tasks by description to the target pane -tmux send-keys -t new-task-session:1.1 "/description:$TASK_DESCRIPTION" C-m +tmux send-keys -t new-task-session:1.1 "/description:$task_description" C-m # Attach to the new session tmux switch-client -t new-task-session diff --git a/ar/.local/bin/qndl b/ar/.local/bin/qndl index 8e30dba..f762568 100755 --- a/ar/.local/bin/qndl +++ b/ar/.local/bin/qndl @@ -1,12 +1,12 @@ #!/bin/sh -YTDL_CMD_BASE="yt-dlp --continue --embed-metadata --ignore-errors --no-force-overwrites --no-playlist --verbose" +ytdl_cmd_base="yt-dlp --continue --embed-metadata --ignore-errors --no-force-overwrites --no-playlist --verbose" case "$BROWSER" in *firefox*) cookies="firefox" ;; esac -[ -n "$cookies" ] && YTDL_CMD_BASE="$YTDL_CMD_BASE --cookies-from-browser $cookies" +[ -n "$cookies" ] && ytdl_cmd_base="$ytdl_cmd_base --cookies-from-browser $cookies" shift $((OPTIND - 1)) @@ -14,62 +14,62 @@ shift $((OPTIND - 1)) # [url] [type] [cmd] if [ $# -eq 1 ]; then type="$1" - URL="$(xclip -selection clipboard -o)" + url="$(xclip -selection clipboard -o)" elif [ $# -eq 2 ]; then if echo "$1" | grep -qE "https?://"; then - URL="$1" + url="$1" elif echo "$2" | grep -qE "https?://"; then type="$1" - URL="$2" + url="$2" fi fi # Process command-line options for download type case $type in -m | --music | m | music) - DOWNLOAD_TYPE="music" - OUTPUT_DIR="${XDG_MUSIC_DIR:-${HOME}/Music}" - ARCHIVE_FILE="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/Music/.music.txt" - YTDL_OUTPUT_FORMAT="${OUTPUT_DIR}/%(artist|)s%(artist& - |)s%(title)s.%(ext)s" - YTDL_CMD_BASE="$YTDL_CMD_BASE --audio-format best --audio-quality 0 --download-archive \"$ARCHIVE_FILE\" --extract-audio --recode-video mp3" + download_type="music" + output_dir="${XDG_MUSIC_DIR:-${HOME}/Music}" + archive_file="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/Music/.music.txt" + ytdl_output_format="${output_dir}/%(artist|)s%(artist& - |)s%(title)s.%(ext)s" + ytdl_cmd_base="$ytdl_cmd_base --audio-format best --audio-quality 0 --download-archive \"$archive_file\" --extract-audio --recode-video mp3" ;; -r | --restore | r | restore) - OUTPUT_DIR="${XDG_MUSIC_DIR:-${HOME}/Music}" - ARCHIVE_FILE="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/Music/.music.txt" - YTDL_OUTPUT_FORMAT="${OUTPUT_DIR}/%(artist|)s%(artist& - |)s%(title)s.%(ext)s" - YTDL_CMD_BASE="$YTDL_CMD_BASE --audio-format best --audio-quality 0 --extract-audio --recode-video mp3" - YTDL_CMD="$YTDL_CMD_BASE --output \"$YTDL_OUTPUT_FORMAT\"" - [ ! -f "$ARCHIVE_FILE" ] && exit 1 + output_dir="${XDG_MUSIC_DIR:-${HOME}/Music}" + archive_file="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/global/Music/.music.txt" + ytdl_output_format="${output_dir}/%(artist|)s%(artist& - |)s%(title)s.%(ext)s" + ytdl_cmd_base="$ytdl_cmd_base --audio-format best --audio-quality 0 --extract-audio --recode-video mp3" + ytdl_cmd="$ytdl_cmd_base --output \"$ytdl_output_format\"" + [ ! -f "$archive_file" ] && exit 1 while read -r line; do video_id=$(echo "$line" | awk '{print $2}') - YTDL_CMD="$YTDL_CMD_BASE --output \"$YTDL_OUTPUT_FORMAT\" \"https://www.youtube.com/watch?v=$video_id\"" - idnum=$(tsp bash -c "$YTDL_CMD") + ytdl_cmd="$ytdl_cmd_base --output \"$ytdl_output_format\" \"https://www.youtube.com/watch?v=$video_id\"" + idnum=$(tsp bash -c "$ytdl_cmd") pkill -RTMIN+21 "${STATUSBAR:-dwmblocks}" - done <"$ARCHIVE_FILE" + done <"$archive_file" exit 0 ;; -v | --video | v | video) - DOWNLOAD_TYPE="video" - OUTPUT_DIR="${XDG_VIDEOS_DIR:-${HOME}/Videos}" - YTDL_OUTPUT_FORMAT="${OUTPUT_DIR}/%(title)s [%(id)s].%(ext)s" - VIDEO_EXT=$(printf "best\n60fps\n30fps\nmp4\nmkv" | dmenu -i -p "Choose an encoding (default: 1080p)") || exit - case $VIDEO_EXT in + download_type="video" + output_dir="${XDG_VIDEOS_DIR:-${HOME}/Videos}" + ytdl_output_format="${output_dir}/%(title)s [%(id)s].%(ext)s" + video_ext=$(printf "best\n60fps\n30fps\nmp4\nmkv" | dmenu -i -p "Choose an encoding (default: 1080p)") || exit + case $video_ext in best) - VIDEO_FORMATS="--format bestvideo+bestaudio/best" + video_formats="--format bestvideo+bestaudio/best" ;; 60fps) - VIDEO_FORMATS='--format "((bv*[fps=60]/bv*)[height<=1080]/(wv*[fps=60]/wv*)) + ba / (b[fps=60]/b)[height<=1080]/(w[fps=60]/w)"' + video_formats='--format "((bv*[fps=60]/bv*)[height<=1080]/(wv*[fps=60]/wv*)) + ba / (b[fps=60]/b)[height<=1080]/(w[fps=60]/w)"' ;; 30fps) - VIDEO_FORMATS='--format "((bv*[fps=30]/bv*)[height<=1080]/(wv*[fps=30]/wv*)) + ba / (b[fps=30]/b)[height<=1080]/(w[fps=30]/w)"' + video_formats='--format "((bv*[fps=30]/bv*)[height<=1080]/(wv*[fps=30]/wv*)) + ba / (b[fps=30]/b)[height<=1080]/(w[fps=30]/w)"' ;; *) - VIDEO_FORMATS="--format bestvideo+bestaudio/best" - VIDEO_OPTIONS="--recode-video $VIDEO_EXT" + video_formats="--format bestvideo+bestaudio/best" + video_options="--recode-video $video_ext" ;; esac - YTDL_CMD_BASE="$YTDL_CMD_BASE --buffer-size 1M --embed-thumbnail $VIDEO_FORMATS --no-sponsorblock $VIDEO_OPTIONS" - YTDL_CMD_BASE="${YTDL_CMD_BASE%* }" + ytdl_cmd_base="$ytdl_cmd_base --buffer-size 1M --embed-thumbnail $video_formats --no-sponsorblock $video_options" + ytdl_cmd_base="${ytdl_cmd_base%* }" ;; *) notify-send "⛔ Invalid option: -$OPTARG" @@ -77,49 +77,49 @@ case $type in ;; esac -[ -z "$URL" ] && notify-send "⛔ No URL provided and clipboard is empty or does not contain a valid URL." && exit 1 +[ -z "$url" ] && notify-send "⛔ No URL provided and clipboard is empty or does not contain a valid URL." && exit 1 # Validate the URL format -! echo "$URL" | grep -qE '^https?://[a-zA-Z0-9.-]+(/[a-zA-Z0-9./?&%=_-]*)?$' && notify-send "⛔ Invalid URL format: $URL" && exit 1 +! echo "$url" | grep -qE '^https?://[a-zA-Z0-9.-]+(/[a-zA-Z0-9./?&%=_-]*)?$' && notify-send "⛔ Invalid URL format: $url" && exit 1 # Validate URL accessibility -! curl --head --silent --fail "$URL" >/dev/null && notify-send "⛔ URL is not accessible: $URL" && exit 1 +! curl --head --silent --fail "$url" >/dev/null && notify-send "⛔ URL is not accessible: $url" && exit 1 -case $URL in +case $url in *playlist* | *list=*) - PL_DOWNLOAD_CHOICE=$(printf "playlist\na content" | dmenu -i -p "Download entire playlist or just this content?") - [ "$PL_DOWNLOAD_CHOICE" = "playlist" ] && - YTDL_CMD_BASE=$(echo "$YTDL_CMD_BASE" | sed 's/ --no-playlist//') && - YTDL_CMD_BASE="$YTDL_CMD_BASE --yes-playlist" && + pl_download_choice=$(printf "playlist\na content" | dmenu -i -p "Download entire playlist or just this content?") + [ "$pl_download_choice" = "playlist" ] && + ytdl_cmd_base=$(echo "$ytdl_cmd_base" | sed 's/ --no-playlist//') && + ytdl_cmd_base="$ytdl_cmd_base --yes-playlist" && echo >/tmp/qplaylist - [ "$DOWNLOAD_TYPE" = "video" ] && - CHANNEL=$(yt-dlp --print "%(channel)s" "$URL" | head -n 1 | sed 's/, /,/g;s/[\/:*?"<>| ]/-/g' | tr '[:upper:]' '[:lower:]') && - PLAYLIST=$(yt-dlp --print "%(playlist_title)s" "$URL" | head -n 1 | sed 's/, /,/g;s/[\/:*?"<>| ]/-/g' | tr '[:upper:]' '[:lower:]') && - SUBDIR="${CHANNEL}/${PLAYLIST}" && - mkdir -p "${OUTPUT_DIR}/${SUBDIR}" && - YTDL_OUTPUT_FORMAT="${OUTPUT_DIR}/${SUBDIR}/%(playlist_index)02d_%(title)s [%(id)s].%(ext)s" + [ "$download_type" = "video" ] && + channel=$(yt-dlp --print "%(channel)s" "$url" | head -n 1 | sed 's/, /,/g;s/[\/:*?"<>| ]/-/g' | tr '[:upper:]' '[:lower:]') && + playlist=$(yt-dlp --print "%(playlist_title)s" "$url" | head -n 1 | sed 's/, /,/g;s/[\/:*?"<>| ]/-/g' | tr '[:upper:]' '[:lower:]') && + subdir="${channel}/${playlist}" && + mkdir -p "${output_dir}/${subdir}" && + ytdl_output_format="${output_dir}/${subdir}/%(playlist_index)02d_%(title)s [%(id)s].%(ext)s" ;; esac -SIMULATION_CMD="yt-dlp --simulate --print %(filename)s $URL" -YTDL_CMD="$YTDL_CMD_BASE --output \"$YTDL_OUTPUT_FORMAT\" \"$URL\"" +simulation_cmd="yt-dlp --simulate --print %(filename)s $url" +ytdl_cmd="$ytdl_cmd_base --output \"$ytdl_output_format\" \"$url\"" # Notify and perform simulation to get filename (feedback to user) -echo "$SIMULATION_CMD" | while IFS= read -r line; do +echo "$simulation_cmd" | while IFS= read -r line; do filename=$(basename "$line") - notify-send "📥 Queuing $DOWNLOAD_TYPE to download:" "$filename" + notify-send "📥 Queuing $download_type to download:" "$filename" done # Enqueue the download task with tsp -FILENAME=$($SIMULATION_CMD 2>/dev/null) +filename=$($simulation_cmd 2>/dev/null) [ -f /tmp/qplaylist ] && rm -rf /tmp/qplaylist -notify-send "⏳ Downloading $DOWNLOAD_TYPE:" "$FILENAME" -idnum=$(tsp bash -c "$YTDL_CMD") +notify-send "⏳ Downloading $download_type:" "$filename" +idnum=$(tsp bash -c "$ytdl_cmd") pkill -RTMIN+21 "${STATUSBAR:-dwmblocks}" # Notify upon completion -tsp -D "$idnum" notify-send "✅ $DOWNLOAD_TYPE download complete:" "$URL" || - notify-send "❌ Faild to download:" "$URL" +tsp -D "$idnum" notify-send "✅ $download_type download complete:" "$url" || + notify-send "❌ Faild to download:" "$url" # Conditionally update the music database if the download type is music -[ "$DOWNLOAD_TYPE" = "music" ] && tsp -D "$idnum" bash -c "mpc update" +[ "$download_type" = "music" ] && tsp -D "$idnum" bash -c "mpc update" diff --git a/ar/.local/bin/rbackup b/ar/.local/bin/rbackup index 17c7bf0..d2dc610 100755 --- a/ar/.local/bin/rbackup +++ b/ar/.local/bin/rbackup @@ -6,7 +6,7 @@ dot_path="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}" git_path="$HOME/Private/repos" pass_path="${PASSWORD_STORE_DIR:-${XDG_DATA_HOME:-${HOME}/.local/share}/.password-store}/exported_keys" suck_path="${XDG_SOURCES_HOME:-${HOME}/.local/src}/suckless" -USER_HOME=$(eval echo ~"$USER") +user_home=$(eval echo ~"$USER") # targets bash_path="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}/ar/.config/bash" @@ -37,10 +37,10 @@ error() { mount_luks() { if ! mount | grep -q " /mnt/second "; then - SIZE_NVME0=$(sudo blockdev --getsize64 /dev/nvme0n1p1) - SIZE_NVME1=$(sudo blockdev --getsize64 /dev/nvme1n1p1) - [ "$SIZE_NVME1" -lt "$SIZE_NVME0" ] && TARGET_DEVICE="/dev/nvme0n1p1" || TARGET_DEVICE="/dev/nvme1n1p1" - ${TERMINAL:-st} -n floatterm -g 60x1 -e sudo cryptsetup open "$TARGET_DEVICE" "second" + size_nvme0=$(sudo blockdev --getsize64 /dev/nvme0n1p1) + size_nvme1=$(sudo blockdev --getsize64 /dev/nvme1n1p1) + [ "$size_nvme1" -lt "$size_nvme0" ] && target_device="/dev/nvme0n1p1" || target_device="/dev/nvme1n1p1" + ${TERMINAL:-st} -n floatterm -g 60x1 -e sudo cryptsetup open "$target_device" "second" sudo -A mount "/dev/mapper/second" "/mnt/second" -o uid="$(id -u)",gid="$(id -g)" 2>/dev/null || sudo -A mount "/dev/mapper/second" "/mnt/second" fi } @@ -70,11 +70,11 @@ sync_root() { shortcuts >/dev/null 2>&1 # Modify root's Bash and LF configuration to include user-specific settings - echo "[ -f \"$USER_HOME/.config/shell/shortcutrc\" ] && source \"$USER_HOME/.config/shell/shortcutrc\"" | sudo tee -a /root/.config/bash/bashrc >/dev/null 2>&1 - echo "[ -f \"$USER_HOME/.config/shell/zshnameddirrc\" ] && source \"$USER_HOME/.config/shell/zshnameddirrc\"" | sudo tee -a /root/.config/bash/bashrc >/dev/null 2>&1 - sudo sed -i "s|source[[:space:]]*\"\?~/.config/lf/shortcutrc\"\?|source \"$USER_HOME/.config/lf/shortcutrc\"|" /root/.config/lf/lfrc >/dev/null 2>&1 + echo "[ -f \"$user_home/.config/shell/shortcutrc\" ] && source \"$user_home/.config/shell/shortcutrc\"" | sudo tee -a /root/.config/bash/bashrc >/dev/null 2>&1 + echo "[ -f \"$user_home/.config/shell/zshnameddirrc\" ] && source \"$user_home/.config/shell/zshnameddirrc\"" | sudo tee -a /root/.config/bash/bashrc >/dev/null 2>&1 + sudo sed -i "s|source[[:space:]]*\"\?~/.config/lf/shortcutrc\"\?|source \"$user_home/.config/lf/shortcutrc\"|" /root/.config/lf/lfrc >/dev/null 2>&1 sudo grep -q "source \"\?/root/.config/lf/rootshortcutrc\"\?" /root/.config/lf/lfrc || - sudo sed -i "\|source \"\?$USER_HOME/.config/lf/shortcutrc\"\?|a source \"/root/.config/lf/rootshortcutrc\"" /root/.config/lf/lfrc + sudo sed -i "\|source \"\?$user_home/.config/lf/shortcutrc\"\?|a source \"/root/.config/lf/rootshortcutrc\"" /root/.config/lf/lfrc # Final ownership and link adjustments sudo chown -R root:root /root/.config/ >/dev/null 2>&1 diff --git a/ar/.local/bin/restartnvim b/ar/.local/bin/restartnvim index 74d57c3..ab040ab 100755 --- a/ar/.local/bin/restartnvim +++ b/ar/.local/bin/restartnvim @@ -13,13 +13,13 @@ if [ -z "$TMUX" ]; then fi # Get the current tmux pane ID -TMUX_PANE=$(tmux display-message -p '#D') +tmux_pane=$(tmux display-message -p '#D') # Send Escape, :wq, and Enter to Neovim in the tmux pane -tmux send-keys -t "$TMUX_PANE" Escape C-m ':wq' C-m +tmux send-keys -t "$tmux_pane" Escape C-m ':wq' C-m # Wait to ensure Neovim exits sleep 0.5 # Detach the script from Neovim and wait a bit to ensure Neovim exits -(nohup sh -c "sleep 0.5; tmux send-keys -t \"$TMUX_PANE\" 'nvim -c \"execute \\\"edit \\\" . v:oldfiles[0] | normal '\''0\"' C-m" >/dev/null 2>&1 &) +(nohup sh -c "sleep 0.5; tmux send-keys -t \"$tmux_pane\" 'nvim -c \"execute \\\"edit \\\" . v:oldfiles[0] | normal '\''0\"' C-m" >/dev/null 2>&1 &) diff --git a/ar/.local/bin/rssadd b/ar/.local/bin/rssadd index 9e68650..a49c5f8 100755 --- a/ar/.local/bin/rssadd +++ b/ar/.local/bin/rssadd @@ -10,9 +10,9 @@ else 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 +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." + echo "$url" >>"$rssfile" && notify-send "RSS feed added." fi diff --git a/ar/.local/bin/sshadd b/ar/.local/bin/sshadd index 76797ba..ea389b9 100755 --- a/ar/.local/bin/sshadd +++ b/ar/.local/bin/sshadd @@ -1,11 +1,11 @@ #!/bin/sh -SSH_KEY_DIR="${PASSWORD_STORE_DIR:-${HOME}/.local/share/.password-store}" +ssh_key_dir="${PASSWORD_STORE_DIR:-${HOME}/.local/share/.password-store}" temp_private_keys_list=$(mktemp) # Ensure that filenames with spaces or other special characters are handled correctly. -find "$SSH_KEY_DIR" -name "*.pub" | while IFS= read -r pub_file_path; do +find "$ssh_key_dir" -name "*.pub" | while IFS= read -r pub_file_path; do private_key_path="${pub_file_path%.pub}" if [ -f "$private_key_path" ]; then echo "$(basename "$private_key_path")" >>"$temp_private_keys_list" diff --git a/ar/.local/bin/statusbar/sb-clock b/ar/.local/bin/statusbar/sb-clock index 331c62f..a5992a5 100755 --- a/ar/.local/bin/statusbar/sb-clock +++ b/ar/.local/bin/statusbar/sb-clock @@ -43,11 +43,11 @@ else fi # Shows the current moon phase. -LOCATION=$(curl -s http://ip-api.com/json | jq -r '[.regionName, .countryCode] | join(",")') +location=$(curl -s http://ip-api.com/json | jq -r '[.regionName, .countryCode] | join(",")') moonfile="${XDG_DATA_HOME:-${HOME}/.local/share}/wallpapers/moonphase" if [ ! -s "$moonfile" ] || [ "$(stat -c %y "$moonfile" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ]; then - moon=$(curl -sf "wttr.in/$LOCATION?format=%m") + moon=$(curl -sf "wttr.in/$location?format=%m") [ -n "$moon" ] && grep -vq 'Unknown location' "$moon" && echo "$moon" >"$moonfile" fi diff --git a/ar/.local/bin/statusbar/sb-forecast b/ar/.local/bin/statusbar/sb-forecast index 8ac571b..d9dded0 100755 --- a/ar/.local/bin/statusbar/sb-forecast +++ b/ar/.local/bin/statusbar/sb-forecast @@ -3,7 +3,7 @@ # Displays today's snow chance (🏂), precipication chance (☔), humidity (💧), wind speed (🎐), and current (feel like) temperature (🌞). # Usually intended for the statusbar. -LOCATION=$(curl -s http://ip-api.com/json | jq -r '[.regionName, .countryCode] | join(",")') +location=$(curl -s http://ip-api.com/json | jq -r '[.regionName, .countryCode] | join(",")') url="${WTTRURL:-wttr.in}" weatherreport="${XDG_CACHE_HOME:-${HOME}/.cache}/weatherreport" @@ -17,13 +17,13 @@ error() { # Get a weather report from 'wttr.in' and save it locally. getweatherreport() { - (timeout --signal=1 10s curl -sf "$url/$LOCATION" >"$weatherreport" && + (timeout --signal=1 10s curl -sf "$url/$location" >"$weatherreport" && printf "\nUpdated: %s\n" "$(date '+%Y-%m-%d %H:%M:%S')" >>"$weatherreport") || error "report" } getweatherreportjson() { - timeout --signal=1 10s curl -sf "$url/$LOCATION?format=j1" >"$weatherreportjson" || + timeout --signal=1 10s curl -sf "$url/$location?format=j1" >"$weatherreportjson" || error "reportjson" } diff --git a/ar/.local/bin/statusbar/sb-repos b/ar/.local/bin/statusbar/sb-repos index 2b936c7..2c259ba 100755 --- a/ar/.local/bin/statusbar/sb-repos +++ b/ar/.local/bin/statusbar/sb-repos @@ -3,16 +3,16 @@ pidof transmission-daemon >/dev/null && exit # Directories containing Git repositories -DOTFILES_REPOS="$HOME/.dotfiles" -SUCKLESS_REPOS="$HOME/.local/src/suckless" -PRIVATE_REPOS="$HOME/Private/repos" -PUBLIC_REPOS="$HOME/Public/repos" +dotfiles_repos="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}" +suckless_repos="${XDG_SOURCES_HOME:-${HOME}/.local/src}/suckless" +private_repos="$HOME/Private/repos" +public_repos="${XDG_PUBLICSHARE_DIR:-${HOME}/Public}/repos" # Icon indicators -DOTFILES_ICON="⚙️" -SUCKLESS_ICON="🛠" -PRIVATE_ICON="🏠" -PUBLIC_ICON="🏢" +dotfiles_icon="⚙️" +suckless_icon="🛠" +private_icon="🏠" +public_icon="🏢" # Function to parse Git status and format symbols get_git_status_symbols() { @@ -91,17 +91,17 @@ check_single_repo_status() { } # Check statuses for repositories -dotfiles_status=$(check_single_repo_status "$DOTFILES_REPOS" "$DOTFILES_ICON" | awk -F' ' '{print $1}') -dotfiles_changes=$(check_single_repo_status "$DOTFILES_REPOS" "$DOTFILES_ICON" | awk -F' ' '{print $2}') +dotfiles_status=$(check_single_repo_status "$dotfiles_repos" "$dotfiles_icon" | awk -F' ' '{print $1}') +dotfiles_changes=$(check_single_repo_status "$dotfiles_repos" "$dotfiles_icon" | awk -F' ' '{print $2}') -suckless_status=$(check_single_repo_status "$SUCKLESS_REPOS" "$SUCKLESS_ICON" | awk -F' ' '{print $1}') -suckless_changes=$(check_single_repo_status "$SUCKLESS_REPOS" "$SUCKLESS_ICON" | awk -F' ' '{print $2}') +suckless_status=$(check_single_repo_status "$suckless_repos" "$suckless_icon" | awk -F' ' '{print $1}') +suckless_changes=$(check_single_repo_status "$suckless_repos" "$suckless_icon" | awk -F' ' '{print $2}') -private_status=$(check_multi_repo_status "$PRIVATE_REPOS" "$PRIVATE_ICON" | awk -F' ' '{print $1}') -private_changes=$(check_multi_repo_status "$PRIVATE_REPOS" "$PRIVATE_ICON" | awk -F' ' '{print $2}') +private_status=$(check_multi_repo_status "$private_repos" "$private_icon" | awk -F' ' '{print $1}') +private_changes=$(check_multi_repo_status "$private_repos" "$private_icon" | awk -F' ' '{print $2}') -public_status=$(check_multi_repo_status "$PUBLIC_REPOS" "$PUBLIC_ICON" | awk -F' ' '{print $1}') -public_changes=$(check_multi_repo_status "$PUBLIC_REPOS" "$PUBLIC_ICON" | awk -F' ' '{print $1}') +public_status=$(check_multi_repo_status "$public_repos" "$public_icon" | awk -F' ' '{print $1}') +public_changes=$(check_multi_repo_status "$public_repos" "$public_icon" | awk -F' ' '{print $1}') [ -f /tmp/gitsync ] && rm -f /tmp/gitsync diff --git a/ar/.local/bin/statusbar/sb-ticker b/ar/.local/bin/statusbar/sb-ticker index f68b6bd..ce25a6e 100755 --- a/ar/.local/bin/statusbar/sb-ticker +++ b/ar/.local/bin/statusbar/sb-ticker @@ -24,9 +24,9 @@ checkprice() { getchange() { mapfile -t changes < <(sed -e 's/ / /g' "$pricefile" | grep -oe '[m-]\+[0-9]\+\.[0-9]\+' | sed 's/[m ]/;/g') - IFS=',' read -ra TICKER <<<"$tickers" - for idx in "${!TICKER[@]}"; do - printf "%s: %s%%\n" "${TICKER[$idx]}" "${changes[$idx]//;/}" + IFS=',' read -ra ticker <<<"$tickers" + for idx in "${!ticker[@]}"; do + printf "%s: %s%%\n" "${ticker[$idx]}" "${changes[$idx]//;/}" done } diff --git a/ar/.local/bin/task/taskwarrior-tui/taskopen-line b/ar/.local/bin/task/taskwarrior-tui/taskopen-line index 832b30e..379a2af 100755 --- a/ar/.local/bin/task/taskwarrior-tui/taskopen-line +++ b/ar/.local/bin/task/taskwarrior-tui/taskopen-line @@ -7,43 +7,43 @@ current_session=$(tmux display-message -p '#S') sleep 0.1 # Extract the line number and file path from the input string -LINE_NUMBER=$(echo "$1" | awk -F ':' '{print $2}') -FILE_PATH=$(echo "$1" | awk -F ':' '{print $3}') +line_number=$(echo "$1" | awk -F ':' '{print $2}') +file_path=$(echo "$1" | awk -F ':' '{print $3}') # Resolve the file path if it's a symlink -if [ -L "$FILE_PATH" ]; then - FILE_PATH=$(readlink -f "$FILE_PATH") +if [ -L "$file_path" ]; then + file_path=$(readlink -f "$file_path") fi -# Use all arguments beyond the first one as the TASK_DESCRIPTION +# Use all arguments beyond the first one as the task_description shift -TASK_DESCRIPTION="$*" +task_description="$*" # If a task description is provided, search for the line number containing that description -if [ -n "$TASK_DESCRIPTION" ]; then - NEW_LINE_NUMBER=$(grep -n -F "$TASK_DESCRIPTION" "$FILE_PATH" | awk -F ':' '{print $1}' | head -n 1) - if [ -n "$NEW_LINE_NUMBER" ]; then - LINE_NUMBER=$NEW_LINE_NUMBER +if [ -n "$task_description" ]; then + new_line_number=$(grep -n -F "$task_description" "$file_path" | awk -F ':' '{print $1}' | head -n 1) + if [ -n "$new_line_number" ]; then + line_number=$new_line_number fi fi # Capture the file name from the file path without the extension -FILE_NAME=$(basename "$FILE_PATH" | awk -F '.' '{print $1}') -DIR_NAME=$(dirname "$FILE_PATH") +file_name=$(basename "$file_path" | awk -F '.' '{print $1}') +dir_name=$(dirname "$file_path") # Check if directory exists -if [ ! -d "$DIR_NAME" ]; then +if [ ! -d "$dir_name" ]; then exit 1 fi # Create a new tmux session which opens the file with neovim at the specific line number -cd "$DIR_NAME" && tmux new-session -d -s "$FILE_NAME" "nvim +$LINE_NUMBER $FILE_PATH" +cd "$dir_name" && tmux new-session -d -s "$file_name" "nvim +$line_number $file_path" # Attach to the new session -tmux switch-client -t "$FILE_NAME" +tmux switch-client -t "$file_name" # Wait for the session to be closed, either by the user or some other way -while tmux has-session -t "$FILE_NAME" 2>/dev/null; do +while tmux has-session -t "$file_name" 2>/dev/null; do sleep 1 done diff --git a/ar/.local/bin/tmuxopen b/ar/.local/bin/tmuxopen index 42c9968..5362215 100755 --- a/ar/.local/bin/tmuxopen +++ b/ar/.local/bin/tmuxopen @@ -30,14 +30,14 @@ wrapper() { # Cleanup on exit trap "rm -f $tmp_files $tmp_content_query" EXIT - RG_FIXED_BIND="ctrl-g:transform-query( + rg_fixed_bind="ctrl-g:transform-query( echo {q} > $tmp_content_query; echo {q} )+reload( rm -f $tmp_files; rg --line-number --follow --fixed-strings --hidden --no-heading --color=always --smart-case --glob '!**/.git/**' --glob '!node_modules/**' {q} 2>/dev/null || true )" - FILE_BIND="ctrl-f:transform-query( + file_bind="ctrl-f:transform-query( current_query={q}; if [ ! -s $tmp_content_query ]; then echo \$current_query > $tmp_content_query; @@ -59,9 +59,9 @@ wrapper() { fi )" if command -v fd >/dev/null 2>&1; then - DIR_BIND="ctrl-d:change-prompt(📁 )+reload(fd --follow --type d --hidden --absolute-path --color never --exclude .git --exclude node_modules --search-path \"\$PWD\")" + dir_bind="ctrl-d:change-prompt(📁 )+reload(fd --follow --type d --hidden --absolute-path --color never --exclude .git --exclude node_modules --search-path \"\$PWD\")" else - DIR_BIND="ctrl-d:change-prompt(📁 )+reload(find \"\$PWD\" -L -type d -name node_modules -prune -o -name .git -prune -o -type d -print)" + dir_bind="ctrl-d:change-prompt(📁 )+reload(find \"\$PWD\" -L -type d -name node_modules -prune -o -name .git -prune -o -type d -print)" fi rg --line-number --follow --no-heading --color=always --smart-case --glob '!**/.git/**' --glob '!LICENSE' '' 2>/dev/null | @@ -71,9 +71,9 @@ wrapper() { --print-query \ --preview 'bat --style=numbers --color=always --highlight-line {2} {1} 2>/dev/null || bat --color=always {} 2>/dev/null || ls -la {} 2>/dev/null || echo "Preview is not available."' \ --preview-window 'right,55%,border-bottom,+{2}+3/3,~3' \ - --bind "$FILE_BIND" \ - --bind "$RG_FIXED_BIND" \ - --bind "$DIR_BIND" \ + --bind "$file_bind" \ + --bind "$rg_fixed_bind" \ + --bind "$dir_bind" \ --bind 'ctrl-c:abort' \ --header "^f filenames | ^g contents | ^d directories" \ --prompt "🔎 " diff --git a/ar/.local/bin/vipy b/ar/.local/bin/vipy index ac30f30..8e0e3cb 100755 --- a/ar/.local/bin/vipy +++ b/ar/.local/bin/vipy @@ -1,7 +1,7 @@ #!/bin/sh # Create a new notebook JSON structure -NOTEBOOK='{ +notebook='{ "cells": [ { "cell_type": "code", @@ -36,7 +36,7 @@ NOTEBOOK='{ [ -z "$1" ] && echo "Enter a file name!" && exit # Write the JSON to a new .ipynb file -echo "$NOTEBOOK" >"$1.ipynb" +echo "$notebook" >"$1.ipynb" # Check if the file was created successfully [ -f "$1.ipynb" ] && echo "$1.ipynb created successfully." || echo "Failed to create a Jupyter Notebook." |
