diff options
Diffstat (limited to 'scriptlets')
41 files changed, 959 insertions, 0 deletions
diff --git a/scriptlets/adbor.sh b/scriptlets/adbor.sh new file mode 100755 index 0000000..ed060f8 --- /dev/null +++ b/scriptlets/adbor.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# if not this, keep prompting in loop +# adb devices | grep device$ + +MODE="$1" + +[[ ! $( echo "$MODE" | grep -e "^add$" -e "^remove$" ) ]] && echo -e "usage: $0 add/remove" && exit -3 + +while ! adb devices | grep -iq "device$" ; do + + echo "No authorized devices found." + for i in {1..5}; do + echo "Recheck in ${i}..." + sleep 1 + done +done + +DEVICE="$( adb devices | grep -i device$ | awk '{print $1}' | fzf -1 --prompt "Device: " )" +[[ -z "$DEVICE" ]] && echo "No device selected. Exiting." && exit 0 + +if echo "$MODE" | grep -iqF "remove" ; then + + PACKAGE=$( adb -s "${DEVICE}" shell "pm list packages" | sed -r "s|^package:||" | fzf --prompt "[Device: ${DEVICE}] Package to remove: " ) + [[ -z "$PACKAGE" ]] && echo "No package selected. Exiting." && exit 0 + + read -p "Are you sure you want to uninstall package \"${PACKAGE}\"? [Y/n] " -n 1 + # if [[ $REPLY =~ ^[Yy]$ ]] + if [[ $REPLY =~ ^[Nn]$ ]]; then + echo "Uninstall aborted." && exit -1 + fi + adb -s "${DEVICE}" shell "pm uninstall -k --user 0 ${PACKAGE}" && echo "Package uninstalled." && exit 1 + +elif echo "$MODE" | grep -iqF "add" ; then + + PACKAGE=$( comm -13 <(adb -s "${DEVICE}" shell "pm list packages" | sort) <(adb -s "${DEVICE}" shell "pm list packages -u" | sort) | sed -r "s|^package:||" | fzf --prompt "[Device: ${DEVICE}] Package to add: " ) + [[ -z "$PACKAGE" ]] && echo "No package selected. Exiting." && exit 1 + + read -p "Are you sure you want to reinstall package \"${PACKAGE}\"? [Y/n] " -n 1 + # if [[ $REPLY =~ ^[Yy]$ ]] + if [[ $REPLY =~ ^[Nn]$ ]]; then + echo "Reinstall aborted." && exit -2 + fi + + adb -s "${DEVICE}" shell "pm install-existing ${PACKAGE}" && echo "Package reinstalled." && exit 2 + +else + echo -e "usage: $0 add/remove" && exit -3 +fi diff --git a/scriptlets/androidmount.sh b/scriptlets/androidmount.sh new file mode 100755 index 0000000..0686b4a --- /dev/null +++ b/scriptlets/androidmount.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +MOUNTDIR="$HOME/1Misc/mnt" +[[ ! -d "$MOUNTDIR" ]] && mkdir -p "$MOUNTDIR" +[[ -z "$(jmtpfs -l)" ]] && exit +[[ "$1" == "-u" && -n "$( grep "jmtpfs $MOUNTDIR" "/etc/mtab" )" ]] && fusermount -u "$MOUNTDIR" +[[ -z "$1" && -z "$( grep "jmtpfs $MOUNTDIR" "/etc/mtab" )" ]] && jmtpfs "$MOUNTDIR" + diff --git a/scriptlets/backup_rotation.sh b/scriptlets/backup_rotation.sh new file mode 100755 index 0000000..891933a --- /dev/null +++ b/scriptlets/backup_rotation.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +BACKUP_ROOT="/home/jay/Downloads/Snapshots" +BACKUP_REGEX='.*[0-9]+-[0-9]+-[0-9]+_[0-9]+:[0-9]+:[0-9]+' +RETAIN_NUM=30 + +[[ ! -d "$BACKUP_ROOT" ]] && echo "[$(date '+%Y-%m-%d_%H:%M:%S')] ERROR. Root backup directory '$BACKUP_ROOT' not found. Exiting..." && exit -1 + +BACKUP_SITES=() +while IFS= read -r -d $'\0'; do + BACKUP_SITES+=("$REPLY") +done < <(find "$BACKUP_ROOT" -maxdepth 1 -mindepth 1 -type d -print0) + +[[ ${#BACKUP_SITES[@]} -eq 0 ]] && echo "[$(date '+%Y-%m-%d_%H:%M:%S')] Error. No backup sites found in root directory '$BACKUP_ROOT'. Exiting..." && exit -1 + +for SITE in ${BACKUP_SITES[@]}; do + + TOTAL_NUM=$(ls -1 "$SITE" | grep -cE "$BACKUP_REGEX") + DELETE_NUM=$((TOTAL_NUM - RETAIN_NUM)) + + if [ $DELETE_NUM -gt 0 ]; then + + old_backups=$(ls -1 "$SITE" | grep -E "$BACKUP_REGEX" | sort | head -n $DELETE_NUM) + for old_backup in ${old_backups[@]}; do + rm -rf "$SITE/$old_backup" + echo "[$(date '+%Y-%m-%d_%H:%M:%S')] Removed old backup: $SITE/$old_backup" + done + else + echo "[$(date '+%Y-%m-%d_%H:%M:%S')] Amount of stored backups in '$SITE' does not exceed retention policy [$RETAIN_NUM]. No old backups removed" + fi +done diff --git a/scriptlets/ct_file_handler.sh b/scriptlets/ct_file_handler.sh new file mode 100755 index 0000000..2e34b1c --- /dev/null +++ b/scriptlets/ct_file_handler.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if [[ $1 == *.sh ]] +then + chmod +x "$1" && xfce4-terminal --hold --geometry=80x24 -e "/bin/bash -c $1" && chmod -x "$1" + +elif [[ $1 == *.py ]] +then + xfce4-terminal --hold --geometry=80x24 -e "/bin/python3 $1" & +else + xdg-open "$1" & +fi
\ No newline at end of file diff --git a/scriptlets/ct_self_linker.sh b/scriptlets/ct_self_linker.sh new file mode 100755 index 0000000..b0e9198 --- /dev/null +++ b/scriptlets/ct_self_linker.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +link=$(readlink -- "$0") + +if [ -n "$link" ]; then + echo "$link" +else + echo "gweh" +fi diff --git a/scriptlets/die-panel.sh b/scriptlets/die-panel.sh new file mode 100755 index 0000000..f20fc9c --- /dev/null +++ b/scriptlets/die-panel.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Dependencies: bash>=3.2, coreutils, file + +# Makes the script more portable +readonly DIR="$HOME/stuf/customization/" + +# Optional icon to display before the text +# Insert the absolute path of the icon +# Recommended size is 24x24 px +declare -r ICON_ARRAY=( + "${DIR}/icons/dice/inverted-dice-1.png" + "${DIR}/icons/dice/inverted-dice-2.png" + "${DIR}/icons/dice/inverted-dice-3.png" + "${DIR}/icons/dice/inverted-dice-4.png" + "${DIR}/icons/dice/inverted-dice-5.png" + "${DIR}/icons/dice/inverted-dice-6.png" +) + +# Compute random die +DIE=$(( RANDOM % 6 )) + +# Panel +if [[ $(file -b "${ICON_ARRAY[DIE]}") =~ PNG|SVG ]]; then + INFO="<img>${ICON_ARRAY[DIE]}</img><click>xfce4-panel --plugin-event=genmon-14:refresh:bool:true</click>" +fi + +# Tooltip +MORE_INFO="<tool>" +MORE_INFO+="$(( DIE + 1 ))" +MORE_INFO+="</tool>" + +# Panel Print +echo -e "${INFO}" + +# Tooltip Print +echo -e "${MORE_INFO}" diff --git a/scriptlets/dl_helper_helper.sh b/scriptlets/dl_helper_helper.sh new file mode 100755 index 0000000..33953e9 --- /dev/null +++ b/scriptlets/dl_helper_helper.sh @@ -0,0 +1,17 @@ +#!/bin/bash + + +KEYBOARD=9 +KEYS="(37|72)" + +# ctrl=37, f6-72 +# find out the rest via xinput query-state <ID OF KEYBOARD> + +while [[ $( xinput query-state "$KEYBOARD" | grep -E "key\[${KEYS}\]=down" | wc -l ) -gt 0 ]] ; do + sleep 0.1 +done + +xdotool sleep 0.1 key shift+Down sleep 0.1 key shift+Up +$HOME/stuf/scripts/dl_helper.sh "$(xclip -o -sel primary)" ; $HOME/stuf/scripts/notification_wrapper.sh $? "DLHELPER" + +# alternatively : xclip -sel clip < /dev/null diff --git a/scriptlets/drun.sh b/scriptlets/drun.sh new file mode 100755 index 0000000..5e9b46f --- /dev/null +++ b/scriptlets/drun.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +ROFI_THEME="ErikaScythe" + +rofi -show drun -display-drun "" -theme "$ROFI_THEME" diff --git a/scriptlets/extractfiles.sh b/scriptlets/extractfiles.sh new file mode 100755 index 0000000..8263103 --- /dev/null +++ b/scriptlets/extractfiles.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +find $(pwd) -type f -exec mv '{}' . \;
\ No newline at end of file diff --git a/scriptlets/feh_action3.sh b/scriptlets/feh_action3.sh new file mode 100755 index 0000000..d45de39 --- /dev/null +++ b/scriptlets/feh_action3.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +ROFI_THEME="ErikaScythe2" + +NEW_IMAGE="$1" +NEW_IMAGE_SIZE="$( du -sh "$NEW_IMAGE" | cut -f1 )" +FILELIST="$2" +[[ $( wc -l $FILELIST | cut -d' ' -f1 ) -ne 2 ]] && notify-send "ERROR: FILE LIST DOESN'T HAVE TWO FILES" && exit +OLD_IMAGE="$( cat "$FILELIST" | grep -v "$NEW_IMAGE" | sort | head -n1 )" +OLD_IMAGE_SIZE="$( du -sh "$OLD_IMAGE" | cut -f1 )" + +CHOICE=$(echo -e "Yes\nNo" \ +| rofi -dmenu -i -no-custom -p "$( echo -e "Replace image\n$OLD_IMAGE (${OLD_IMAGE_SIZE})\nwith\n$NEW_IMAGE (${NEW_IMAGE_SIZE})?" )" -theme "$ROFI_THEME" -async-pre-read 2 -no-click-to-exit ) + +if [[ "$CHOICE" == "Yes" ]]; then + NEW_EXTENSION="${NEW_IMAGE##*.}" + OLD_BASE="${OLD_IMAGE%.*}" + NEW_FINAL="${OLD_BASE}.${NEW_EXTENSION}" + gio trash "$OLD_IMAGE" && mv "${NEW_IMAGE}" "${NEW_FINAL}" +fi diff --git a/scriptlets/find_papes.sh b/scriptlets/find_papes.sh new file mode 100755 index 0000000..812c0f6 --- /dev/null +++ b/scriptlets/find_papes.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +scale=5 +DIR="$( readlink -f "$1" )" +[[ -d "$DIR" ]] || { echo "NEED DIRECTORY NAME"; exit -1; } + +while true; do + read -p "Enter resolution of pape (WxH, e.g. 1920x1080): " res + + [[ "$res" =~ [0-9]+x[0-9]+ ]] && break + + echo "Wrong input" +done + +X=${res%x*} +Y=${res#*x} + +[[ $X -eq 0 || $Y -eq 0 ]] && echo "Don't fuck around" && exit +res=$( echo "scale = $scale; $X / $Y" | bc ) +upper=$( echo "scale = $scale; $res + 0.05" | bc ) +lower=$( echo "scale = $scale; $res - 0.05" | bc ) + +echo "$upper --- $lower" + +candidates="$( mktemp --tmpdir=$HOME/Desktop )" + +find "$DIR" -type f -iregex ".*\.\(bmp\|gif\|jpg\|jpeg\|png\)$" -print0 | while read -d $'\0' pic; do + + res=$( identify "$pic" | grep -o --extended-regexp --ignore-case "[0-9]+x[0-9]+" | head -1 | sed -r "s|x|\ / |; s|^|scale = $scale; |" | bc ) + if (( $(echo "$upper >= $res" | bc -l) && $(echo "$lower <= $res" | bc -l) )); then echo "$pic" >> $candidates; fi + +done + +monitor="$( xfconf-query -c xfce4-desktop -l | grep "workspace0/last-image" | dmenu -l 5 )" + +feh --info "printf '%S %wx%h'" --zoom max --scale-down -g 1280x720 -B black -d --action1 "cp %F $HOME/Desktop" --action2 "nohup gimp -a %F >/dev/null 2>&1 &" --action3 "xfconf-query -c xfce4-desktop -p $monitor -s %F" -f "$candidates" + +rm "$candidates" diff --git a/scriptlets/findlast.sh b/scriptlets/findlast.sh new file mode 100755 index 0000000..32d5c92 --- /dev/null +++ b/scriptlets/findlast.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# THUNAR CUSTOM ACTION + +# Name: Set Art lookup directory +# Description: Set the current directory as the one findlast.sh will check + +# Command: $HOME/stuf/scripts/scriptlets/findlast.sh --set-artdir +# Keyboard Shortcut: Shift+F2 +# Icon: shupogaki.png + +# Appearance Conditions -> Check "Directories **" + +if [[ "$1" = "--set-artdir" ]]; then + echo $(pwd) > $HOME/stuf/artdir.txt + $HOME/stuf/scripts/notification_wrapper.sh "Set $(pwd) as the new artdir." "FINDLAST" +else + ARTDIR="$( head -n1 "$HOME/stuf/artdir.txt" )" + SELECTION="$( xclip -o -sel primary | sed -r "s|\.[a-zA-Z]+||g" )" + [[ -z $SELECTION ]] && exit -1 + + $HOME/stuf/scripts/notification_wrapper.sh "$( find "$ARTDIR" -type f -iregex ".*/${SELECTION}[0-9]+[a-zA-Z]*\.[a-zA-Z]+" | sort -V | tail -n1 )" "FINDLAST" +fi diff --git a/scriptlets/glava_toggler.sh b/scriptlets/glava_toggler.sh new file mode 100755 index 0000000..28ae226 --- /dev/null +++ b/scriptlets/glava_toggler.sh @@ -0,0 +1,6 @@ +#/bin/bash + +command="glava --desktop" +[[ -n $( pgrep -f "$command" ) ]] && pkill -f "$command" || nohup $command > /dev/null 2>&1 & + + diff --git a/scriptlets/ieset.sh b/scriptlets/ieset.sh new file mode 100755 index 0000000..698dbe4 --- /dev/null +++ b/scriptlets/ieset.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +while read LINE; do + + P_AMOUNT="$( echo $line | sed -r "s|\s+([0-9]+) [^ ]+|\1|g" )" + echo "$P_AMOUNT" + +done < <( find "$(pwd)" -type f | sort | sed -r "s|_p[0-9]+||g" | uniq -c ) diff --git a/scriptlets/ikaloop.sh b/scriptlets/ikaloop.sh new file mode 100755 index 0000000..40e6cad --- /dev/null +++ b/scriptlets/ikaloop.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +CLIP="$HOME/1Misc/[DUWANG]_Shinryaku!_Ika_Musume-_01[240p].wmv.avi" + +mpv --loop --no-audio "$CLIP" & disown
\ No newline at end of file diff --git a/scriptlets/make_exceptions.txt b/scriptlets/make_exceptions.txt new file mode 100644 index 0000000..2123225 --- /dev/null +++ b/scriptlets/make_exceptions.txt @@ -0,0 +1 @@ +for file in $(ls | grep -oE "[^_]+_p[1-9]+\..*$" | sed -r "s|_.*||g" | sort | uniq); do ls *$file* | sort | sed -r "s|^|$(pwd)\/|g" | tr "\n" " " >> exceptions.txt ; echo -e "" >> exceptions.txt; done diff --git a/scriptlets/mute_button.sh b/scriptlets/mute_button.sh new file mode 100644 index 0000000..7a693aa --- /dev/null +++ b/scriptlets/mute_button.sh @@ -0,0 +1,3 @@ +#!/bin/bash + + diff --git a/scriptlets/old_cliparmyknife.sh b/scriptlets/old_cliparmyknife.sh new file mode 100755 index 0000000..8636a84 --- /dev/null +++ b/scriptlets/old_cliparmyknife.sh @@ -0,0 +1,295 @@ +#!/bin/bash + +#set -e + +get_clip_params () { + + CLIP_PATH=$( dirname "$1" ) + CLIP_NAME=$( basename "$1" | sed -r "s|\.[^. ]*$||g" ) + CLIP_EXTENSION=$( sed -r "s|^.*\.||g" <<< "$1" ) + CLIP_WIDTH=$( ffprobe -v error -select_streams v:0 -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 "$1" ) + CLIP_HEIGHT=$( ffprobe -v error -select_streams v:0 -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 "$1" ) + CLIP_SAR=$( ffprobe -v error -select_streams v:0 -show_entries stream=sample_aspect_ratio -of default=noprint_wrappers=1:nokey=1 "$1" ) + CLIP_FRAMERATE=$( ffprobe -i "$1" 2>&1 | grep -oP "\d{1,5}\.?\d{1,5} fps" | tail -1 | sed -r "s|\ fps||g" ) + + MOD=1 + + [[ "$CLIP_SAR" != "1:1" ]] && MOD=$( echo "$CLIP_SAR" | sed -r "s|\:|\ \/\ |g; s|^|scale\=5\;\ |g" | bc ) && CLIP_HEIGHT=$( printf "%.0f" $( bc <<< "$CLIP_HEIGHT / $MOD" ) ) + +} + +dump_clip_params () { + + echo -e "\nCLIP NAME: $CLIP_NAME.$CLIP_EXTENSION\nCLIP LOCATION: $CLIP_PATH/\nCLIP DIMENSIONS: ${CLIP_WIDTH}x${CLIP_HEIGHT}\nCLIP FRAMERATE: $CLIP_FRAMERATE\nCLIP SAR: $CLIP_SAR" + +} + +crop () { + + echo -e "-----out_w is the width of the output rectangle-----\n-----out_h is the height of the output rectangle-----\n-----x and y specify the top left corner of the output rectangle-----" + echo -e "-----CURRENT VIDEO DIMENSIONS OF $CLIP_NAME.$CLIP_EXTENSION: ${CLIP_WIDTH}x${CLIP_HEIGHT}" + + + + re='^[0-9]+(\ )+[0-9]+(\ )+[0-9]+(\ )+[0-9]+$' + + declare OUT_W OUT_H X Y CROP_PARAMS + + while read -p "Enter new clip dimensions [FORMAT: out_w out_h x y]: " CROP_PARAMS; do + + CROP_PARAMS=${CROP_PARAMS:-"$CLIP_WIDTH $CLIP_HEIGHT 0 0"} + + if ! [[ $CROP_PARAMS =~ $re ]]; then + echo "error: Invalid crop parameters" >&2; continue + fi + + + + OUT_W=$( echo "$CROP_PARAMS" | tr -s ' ' | cut -d ' ' -f 1 ) + OUT_H=$( echo "$CROP_PARAMS" | tr -s ' ' | cut -d ' ' -f 2 ) + X=$( echo "$CROP_PARAMS" | tr -s ' ' | cut -d ' ' -f 3 ) + Y=$( echo "$CROP_PARAMS" | tr -s ' ' | cut -d ' ' -f 4 ) + + if [[ $( bc <<< "$OUT_W + $X" ) -gt $CLIP_WIDTH || $( bc <<< "$OUT_H + $Y" ) -gt $CLIP_HEIGHT ]]; then + echo "error: Crop parameters go outside clip bounds" >&2; continue + fi + + break + done + + OUT_H_MOD=$( bc <<< "$OUT_H * $MOD" ) + Y_MOD=$( bc <<< "$Y * $MOD" ) + + ffmpeg -i "$1" -filter:v "crop=$OUT_W:$OUT_H_MOD:$X:$Y_MOD" "$CLIP_NAME [cropped $OUT_W:$OUT_H:$X:$Y].$CLIP_EXTENSION" + +} + +join_no_reencode () { + [[ ! -f "join.$CLIP_EXTENSION" ]] && cp "$1" "join.$CLIP_EXTENSION" && return + echo "file 'join.${CLIP_EXTENSION}'" > cliparmyknife_concat.txt + echo "file '$1'" >> cliparmyknife_concat.txt + ffmpeg -y -f concat -safe 0 -i cliparmyknife_concat.txt -c copy join.$CLIP_EXTENSION + rm cliparmyknife_concat.txt +} + +join_yes_reencode () { + + + [[ ! -f "join.$CLIP_EXTENSION" ]] && cp "$1" "join.$CLIP_EXTENSION" && return + JOIN_WIDTH=$( ffprobe -i "join.$CLIP_EXTENSION" 2>&1 | grep -oP "[1-9]\d{1,10}x[1-9]\d{1,10}" | sed -r "s|\ ||g; s|x[0-9]*$||g" ) + JOIN_HEIGHT=$( ffprobe -i "join.$CLIP_EXTENSION" 2>&1 | grep -oP "[1-9]\d{1,10}x[1-9]\d{1,10}" | sed -r "s|\ ||g; s|^[0-9]*x||g" ) + + #ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i boximouto.webm -c:v copy -c:a libopus -shortest boximouto2.webm + #ffprobe -i ikadiabetes2.gif -show_streams -select_streams a -loglevel error + + [[ -z $(ffprobe -i "$1" -show_streams -select_streams a -loglevel error) ]] && ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i "$1" -c:v copy -c:a libopus -shortest "/tmp/clip_treated.$CLIP_EXTENSION" || cp "$1" "/tmp/clip_treated.$CLIP_EXTENSION" + [[ -z $(ffprobe -i "join.$CLIP_EXTENSION" -show_streams -select_streams a -loglevel error) ]] && ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -i "join.$CLIP_EXTENSION" -c:v copy -c:a libopus -shortest "/tmp/join_treated.$CLIP_EXTENSION" || cp "join.$CLIP_EXTENSION" "/tmp/join_treated.$CLIP_EXTENSION" + + + echo "JOIN DIMENSIONS: $JOIN_WIDTH x $JOIN_HEIGHT" + + [[ $JOIN_WIDTH -gt $CLIP_WIDTH ]] && PAD_WIDTH=$JOIN_WIDTH || PAD_WIDTH=$CLIP_WIDTH + [[ $JOIN_HEIGHT -gt $CLIP_HEIGHT ]] && PAD_HEIGHT=$JOIN_HEIGHT || PAD_HEIGHT=$CLIP_HEIGHT + PAD_X=$( bc <<< "($JOIN_WIDTH - $CLIP_WIDTH) / 2" ) + PAD_Y=$( bc <<< "($JOIN_HEIGHT - $CLIP_HEIGHT) / 2" ) + + echo "PAD DIMENSIONS: $PAD_X, $PAD_Y" + + if [[ $PAD_X -ge 0 && $PAD_Y -ge 0 ]]; then + cp "/tmp/join_treated.$CLIP_EXTENSION" "/tmp/join_temp.$CLIP_EXTENSION" + ffmpeg -y -i "/tmp/clip_treated.$CLIP_EXTENSION" -vf "pad=width=$PAD_WIDTH:height=$PAD_HEIGHT:x=$PAD_X:y=$PAD_Y:color=black" "/tmp/clip_temp.$CLIP_EXTENSION" + elif [[ $PAD_X -lt 0 && $PAD_Y -ge 0 ]]; then + ffmpeg -y -i "/tmp/join_treated.$CLIP_EXTENSION" -vf "pad=width=$PAD_WIDTH:height=$PAD_HEIGHT:x=${PAD_X#-}:y=0:color=black" "/tmp/join_temp.$CLIP_EXTENSION" + ffmpeg -y -i "/tmp/clip_treated.$CLIP_EXTENSION" -vf "pad=width=$PAD_WIDTH:height=$PAD_HEIGHT:x=0:y=$PAD_Y:color=black" "/tmp/clip_temp.$CLIP_EXTENSION" + elif [[ $PAD_X -ge 0 && $PAD_Y -lt 0 ]]; then + ffmpeg -y -i "/tmp/join_treated.$CLIP_EXTENSION" -vf "pad=width=$PAD_WIDTH:height=$PAD_HEIGHT:x=0:y=${PAD_Y#-}:color=black" "/tmp/join_temp.$CLIP_EXTENSION" + ffmpeg -y -i "/tmp/clip_treated.$CLIP_EXTENSION" -vf "pad=width=$PAD_WIDTH:height=$PAD_HEIGHT:x=$PAD_X:y=0:color=black" "/tmp/clip_temp.$CLIP_EXTENSION" + elif [[ $PAD_X -lt 0 && $PAD_Y -lt 0 ]]; then + ffmpeg -y -i "/tmp/join_treated.$CLIP_EXTENSION" -vf "pad=width=$PAD_WIDTH:height=$PAD_HEIGHT:x=${PAD_X#-}:y=${PAD_Y#-}:color=black" "/tmp/join_temp.$CLIP_EXTENSION" + cp "/tmp/clip_treated.$CLIP_EXTENSION" "/tmp/clip_temp.$CLIP_EXTENSION" + else + echo "something fucked up" && exit 1 + fi + + + if [[ -n $(ffprobe -i "/tmp/clip_temp.$CLIP_EXTENSION" -show_streams -select_streams a -loglevel error) && -n $(ffprobe -i "/tmp/clip_temp.$CLIP_EXTENSION" -show_streams -select_streams a -loglevel error) ]]; then + ffmpeg -y -i "/tmp/join_temp.$CLIP_EXTENSION" -i "/tmp/clip_temp.$CLIP_EXTENSION" -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" "/tmp/join2.$CLIP_EXTENSION" + else + ffmpeg -y -i "/tmp/join_temp.$CLIP_EXTENSION" -i "/tmp/clip_temp.$CLIP_EXTENSION" -filter_complex "[0:v:0] [1:v:0]concat=n=2:v=1[outv]" -map "[outv]" "/tmp/join2.$CLIP_EXTENSION" + fi + + mv "/tmp/join2.$CLIP_EXTENSION" "join.$CLIP_EXTENSION" + rm "/tmp/join_treated.$CLIP_EXTENSION" "/tmp/clip_treated.$CLIP_EXTENSION" "/tmp/join_temp.$CLIP_EXTENSION" "/tmp/clip_temp.$CLIP_EXTENSION" +} + +join () { + + if [[ "$REENCODE_FLAG" = "true" ]]; then + join_yes_reencode "$1" + elif [[ "$REENCODE_FLAG" = "false" ]]; then + join_no_reencode "$1" + else + + while true; do + read -p "Are the video parameters identical (y/n)? " yn + + case $( tr '[A-Z]' '[a-z]' <<< "$yn" ) in + y|yes) REENCODE_FLAG="false"; join_no_reencode "$1" ; break;; + n|no) REENCODE_FLAG="true"; join_yes_reencode "$1" ; break;; + *) echo "Invalid response." ;; + esac + done + fi +} + +mute () { + + ffmpeg -i "$1" -c copy -an "$CLIP_NAME [no audio].$CLIP_EXTENSION" + +} + +extract_audio () { + + ffmpeg -i "$1" -codec:a libmp3lame "$CLIP_NAME [audio only].mp3" + +} + +scale () { + + echo -e "-----CURRENT VIDEO DIMENSIONS OF $CLIP_NAME.$CLIP_EXTENSION: $CLIP_WIDTH x $CLIP_HEIGHT" + while read -p "Enter scale coefficient [Default: 2; Recommended: $( bc <<< "scale=2; $CLIP_HEIGHT / 360" )]: " SCALE; do + + SCALE=${SCALE:-2} + + re='^[0-9]*([.][0-9]+)?$' + if ! [[ $SCALE =~ $re ]] ; then + echo "error: Not a non-zero number" >&2; continue + fi + + break + done + + ffmpeg -i "$1" -vf scale="-1:$( printf "%.0f" $( bc <<< "scale=5; $CLIP_HEIGHT / $SCALE" ) )" -c:a copy "$CLIP_NAME [$SCALE].$CLIP_EXTENSION" + +} + +reverse () { + + ffmpeg -i "$1" -vf reverse -af areverse "$CLIP_NAME [reversed].$CLIP_EXTENSION" + +} + +clip_to_gif () { + + echo -e "-----CURRENT VIDEO DIMENSIONS OF $CLIP_NAME.$CLIP_EXTENSION: $CLIP_WIDTH x $CLIP_HEIGHT" + while read -p "Enter scale coefficient [Default: 2; Recommended: $( bc <<< "scale=2; $CLIP_HEIGHT / 360" )]: " SCALE; do + + SCALE=${SCALE:-2} + + re='^[0-9]*([.][0-9]+)?$' + if ! [[ $SCALE =~ $re ]] ; then + echo "error: Not a non-zero number" >&2; continue + fi + + break + done + + echo -e "-----CURRENT FRAMERATE OF $CLIP_NAME.$CLIP_EXTENSION: $CLIP_FRAMERATE fps" + while read -p "Enter new framerate [Default: 23.98; Recommended: $( bc <<< "scale=2; $CLIP_FRAMERATE / 2" )]: " RATE; do + + RATE=${RATE:-23.98} + + re='^[1-9][0-9]*([.][0-9]+)?$' + if ! [[ $RATE =~ $re ]] ; then + echo "error: Not a non-zero number" >&2; continue + fi + + break + done + + ffmpeg -y -i "$1" -vf palettegen "/tmp/_tmp_palette_$CLIP_NAME.png" + ffmpeg -y -i "$1" -i "/tmp/_tmp_palette_$CLIP_NAME.png" -filter_complex paletteuse -r "$RATE" "/tmp/tmp_out_$CLIP_NAME.gif" + rm "/tmp/_tmp_palette_$CLIP_NAME.png" + gifsicle --optimize=3 --no-background --output "$CLIP_NAME [$SCALE - $RATE].gif" --resize "$( bc <<< "$CLIP_WIDTH / $SCALE" )x$( bc <<< "$CLIP_HEIGHT / $SCALE" )" "/tmp/tmp_out_$CLIP_NAME.gif" + rm "/tmp/tmp_out_$CLIP_NAME.gif" + +} + +clip_to_webm () { + + echo -e "-----CURRENT VIDEO DIMENSIONS OF $CLIP_NAME.$CLIP_EXTENSION: $CLIP_WIDTH x $CLIP_HEIGHT" + while read -p "Enter scale coefficient [Default: 2; Recommended: $( bc <<< "scale=2; $CLIP_HEIGHT / 360" )]: " SCALE; do + + SCALE=${SCALE:-2} + + re='^[1-9][0-9]*([.][0-9]+)?$' + if ! [[ $SCALE =~ $re ]] ; then + echo "error: Not a non-zero number" >&2; continue + fi + + break + done + + ffmpeg -i "$1" -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -vf scale="-1:$( bc <<< "$CLIP_HEIGHT / $SCALE" )" -c:a libopus "$CLIP_NAME [$SCALE].webm" +} + +webp_to_gif () { + python3 -c "from PIL import Image;Image.open('$1').save('${1%.webp}.gif','gif',save_all=True,optimize=True,background=0)" +} + +FUNCTION="" + +while getopts "hicsrjmxgw" opt; do + case $opt in + h) echo -e "usage: $0 [-h help] [-i get clip info] [-c crop clip] [-s scale/resize clip] [-r reverse clip] [-j join clips] [-m mute clip] [-x extract audio] [-g convert clip to gif] [-w convert clip to webm]"; exit ;; + i) FUNCTION="dump_clip_params"; break;; + c) FUNCTION="crop"; break ;; + s) FUNCTION="scale"; break ;; + r) FUNCTION="reverse"; break ;; + j) FUNCTION="join"; break ;; + m) FUNCTION="mute"; break ;; + x) FUNCTION="extract_audio"; break ;; + g) FUNCTION="convert"; break ;; + w) FUNCTION="clip_to_webm"; break ;; + ?) echo "error: option -$OPTARG is not implemented"; exit ;; + esac +done + +if [ "$#" -lt 2 ]; then + echo "Please insert only one flag and at least one argument" + exit +else + echo -e "\c" +fi + +i=0 + +for file in "${@:2}" +do + re='s|\.[^. ]*$||g' + + ! [[ $file =~ $re ]] && echo "$file NOT A PROPER FILE, IGNORING..." && continue + get_clip_params "$file" + echo "$CLIP_NAME - $CLIP_EXTENSION - $FUNCTION" + + if [[ "$FUNCTION" == "convert" ]]; then + + if [[ "$CLIP_EXTENSION" == "gif" ]]; then + echo -e "$CLIP_NAME.$CLIP_EXTENSION IS ALREADY A GIF. SKIPPING...\n\n-------------------------$file DONE-------------------------\n\n" && continue + elif [[ "$CLIP_EXTENSION" == "webp" ]]; then + FUNCTION="webp_to_gif" + else + FUNCTION="clip_to_gif" + fi + + fi + + $FUNCTION "$file" + [[ "$FUNCTION" =~ ^(clip|webp)_to_gif$ ]] && FUNCTION="convert" + echo -e "\n\n------------------------- $file - DONE -------------------------\n\n" +done + + +# TO ADD: MORE FLEXIBLE FLAG/ARGUMENT PROCESSING, FLAG WHICH MAKES EVERY FUNCTION RESPECT FILEPATHS (I.E. DOESN'T DRAG EVERY OUTPUT TO CURRENT DIRECTORY) + + diff --git a/scriptlets/old_veepeen_toggler.sh b/scriptlets/old_veepeen_toggler.sh new file mode 100755 index 0000000..ad48082 --- /dev/null +++ b/scriptlets/old_veepeen_toggler.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +passentry="shigoto/vpn" +CONN_NAME="cscotun0" + +if [ -n "$(ip address show | grep -iE "^[0-9]+: $CONN_NAME")" ]; then + echo "ALREADY CONNECTED. DISCONNECTING..." + /opt/cisco/anyconnect/bin/vpn disconnect +else + CONN_HOST="$( pass $passentry | grep "url: "| sed -r "s|url: ||g" )" + CONN_CREDS_USERNAME="$( pass $passentry | grep "username: "| sed -r "s|username: ||g" )" + CONN_CREDS_PASSWORD="$( pass $passentry | head -n1 )" + echo "CONNECTING... DON'T FORGET YOUR PHONE VERIFICATION" + printf '%s\n%s' "$CONN_CREDS_USERNAME" "$CONN_CREDS_PASSWORD" | /opt/cisco/anyconnect/bin/vpn -s connect "$CONN_HOST" +fi + +: ' +Note the single quotes instead of double quotes - this is because double quotes tell Bash to interpret certain characters within strings, such as exclamation marks, as Bash history commands. Double quotes will make this command fail with an "event not found" error if the password contains an exclamation mark. Single-quoted strings pass exclamation marks along without interpreting them. + +In case your client does not connect due to certificate validation error Certificate is from an untrusted source, +and you still want to connect then pass a y parameter in the above method so that the command to connect becomes: +printf "y\nUSERNAME\nPASSWORD\ny" | /opt/cisco/anyconnect/bin/vpn -s connect HOST. +Note that do this only in the case that you absolutely trust your connection; +otherwise there might be a middleman sitting in and snooping onto you. +' diff --git a/scriptlets/passmenu b/scriptlets/passmenu new file mode 100755 index 0000000..7b5b908 --- /dev/null +++ b/scriptlets/passmenu @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +# dumb fucking keyboard shortcut won't with my default env variables +PASSWORD_STORE_DIR="$HOME/stuf/password-store" + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + +if [[ -n $WAYLAND_DISPLAY ]]; then + dmenu=dmenu-wl + xdotool="ydotool type --file -" +elif [[ -n $DISPLAY ]]; then + dmenu=dmenu + xdotool="xdotool type --clearmodifiers --file -" +else + echo "Error: No Wayland or X11 display detected" >&2 + exit 1 +fi + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@") + +[[ -n $password ]] || exit + +if [[ $typeit -eq 0 ]]; then + pass show -c "$password" 2>/dev/null +else + pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool +fi diff --git a/scriptlets/passshowcopy.sh b/scriptlets/passshowcopy.sh new file mode 100644 index 0000000..016e492 --- /dev/null +++ b/scriptlets/passshowcopy.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo "under construction..." diff --git a/scriptlets/peak_or_mid.sh b/scriptlets/peak_or_mid.sh new file mode 100755 index 0000000..c5047ab --- /dev/null +++ b/scriptlets/peak_or_mid.sh @@ -0,0 +1,7 @@ +#!/bin/bash + + +DIR="$( readlink -f "$1" )" +[[ -d "$DIR" ]] || { echo "NEED DIRECTORY NAME"; exit -1; } + +feh --sort filename --version-sort --info "printf '%S %wx%h'" --zoom max --scale-down -g 1280x720 -B black -d --action1 "gio trash %F" --action2 "[ -d \"${DIR}/peak\" ] || mkdir \"${DIR}/peak\"; mv %F \"${DIR}/peak\"" --action3 "[ -d \"${DIR}/mid\" ] || mkdir \"${DIR}/mid\"; mv %F \"${DIR}/mid/\"" "$DIR" diff --git a/scriptlets/qemu-android.sh b/scriptlets/qemu-android.sh new file mode 100755 index 0000000..f71e303 --- /dev/null +++ b/scriptlets/qemu-android.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -xe + +IMAGE="$1" + +shift + +qemu-system-x86_64 -boot d \ + -enable-kvm \ + -smp 2 \ + -name linuz \ + -device virtio-gpu-gl,xres=1280,yres=720 \ + -cpu host \ + -device AC97 \ + -m 2048 \ + -display gtk,gl=on \ + -drive file="$IMAGE",if=virtio \ + -object rng-random,id=rng0,filename=/dev/urandom \ + -device virtio-rng-pci,rng=rng0 \ + -device virtio-keyboard \ + -boot menu=off \ + -device virtio-tablet \ + -machine type=q35 \ + -serial mon:stdio \ + -net nic -net user,hostfwd=tcp::4444-:5555 \ + -cdrom "$@" diff --git a/scriptlets/qemu-run.sh b/scriptlets/qemu-run.sh new file mode 100755 index 0000000..b972140 --- /dev/null +++ b/scriptlets/qemu-run.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +set -xe + +IMAGE="$1" + +shift + +qemu-system-x86_64 \ +-accel kvm \ +-M q35 \ +-m 4096 -smp 4 -cpu host \ +-bios /usr/share/ovmf/x64/OVMF.fd \ +-drive file="$IMAGE",if=virtio \ +-usb \ +-device virtio-tablet \ +-device virtio-keyboard \ +-device qemu-xhci,id=xhci \ +-machine vmport=off \ +-device virtio-vga-gl,xres=1280,yres=720 -display sdl,gl=on \ +-audiodev pa,id=snd0 -device AC97,audiodev=snd0 \ +-net nic,model=virtio-net-pci -net user,hostfwd=tcp::4444-:5555 \ +-cdrom "$@" \ + diff --git a/scriptlets/rss_torrent_helper.sh b/scriptlets/rss_torrent_helper.sh new file mode 100755 index 0000000..bea25e4 --- /dev/null +++ b/scriptlets/rss_torrent_helper.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# this helper script is a monument to my personal failings +# a better man would've just modified the parsing in the original script to allow for per-feed downloaders +# but alas + + +CONFIG_DIR="$HOME/.config/shell-rss-torrent" + +for file in $CONFIG_DIR/*.xml; do + $HOME/stuf/scripts/shell-rss-torrent "$file" +done
\ No newline at end of file diff --git a/scriptlets/rxvt_nvim_launcher.sh b/scriptlets/rxvt_nvim_launcher.sh new file mode 100755 index 0000000..c7a7014 --- /dev/null +++ b/scriptlets/rxvt_nvim_launcher.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +FILE="$1" +[[ -z "$1" ]] && echo "NO" && exit -1 + +/usr/bin/urxvt -geometry 160x48 -title "Terminal - Nvim ($FILE)" -e sh -c "/usr/bin/nvim \"$FILE\"" diff --git a/scriptlets/rxvt_yazi_launcher.sh b/scriptlets/rxvt_yazi_launcher.sh new file mode 100755 index 0000000..7bd2824 --- /dev/null +++ b/scriptlets/rxvt_yazi_launcher.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +DIR="$1" +EDITOR=/usr/bin/nvim + +if [[ ! -d "$DIR" ]]; then + /usr/bin/urxvt -geometry 160x48 -e sh -c "/usr/bin/yazi" +else + /usr/bin/urxvt -geometry 160x48 -e sh -c "/usr/bin/yazi ${DIR}" +fi diff --git a/scriptlets/sidebar_toggler.sh b/scriptlets/sidebar_toggler.sh new file mode 100755 index 0000000..8ebdde5 --- /dev/null +++ b/scriptlets/sidebar_toggler.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +PANELNUM=2 +xfconf-query -c xfce4-panel -p "/panels/panel-$PANELNUM/autohide-behavior" -s $(( $( xfconf-query -c xfce4-panel -p "/panels/panel-$PANELNUM/autohide-behavior" ) ^ 2 ))
\ No newline at end of file diff --git a/scriptlets/soundpost_dl.sh b/scriptlets/soundpost_dl.sh new file mode 100755 index 0000000..28947b6 --- /dev/null +++ b/scriptlets/soundpost_dl.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +WORKDIR="$HOME" + +URL="$1" +REGEX="https:\/\/boards\.4chan\.org\/([a-z]+)\/thread\/([0-9]+)#p([0-9]+)" + +if [[ $URL =~ $REGEX ]]; then + BOARD="${BASH_REMATCH[1]}" + THREAD="${BASH_REMATCH[2]}" + POST="${BASH_REMATCH[3]}" +else + echo "ERROR. BAD URL" && exit -1 +fi + +API_CALL="https://a.4cdn.org/${BOARD}/thread/${THREAD}.json" +POST_JSON="$( curl -s "$API_CALL" | jq -c ".posts[] | select( .no == ${POST} )" )" + +video="$( jq --argjson post "$POST_JSON" -n '$post.tim' )$( jq --argjson post "$POST_JSON" -n '$post.ext' | tr -d '"' )" +audio="$( jq --argjson post "$POST_JSON" -n '$post.filename' | sed -r "s|.*files\.catbox\.moe%2F([a-zA-Z0-9%\.]+).*|\1|g" )" + +video_file="/tmp/${video}" +audio_file="/tmp/${audio}" + +video_url="https://i.4cdn.org/${BOARD}/${video}" +audio_url="https://files.catbox.moe/${audio}" + +output="${WORKDIR}/${video}" + +echo -e "\nWriting to ${output}...\n" + +yt-dlp "$video_url" -o "$video_file" && wget "$audio_url" -O "$audio_file" + +ffmpeg -y -v 24 -i "${audio_file}" -c:a libvorbis -q:a 4 "${audio_file%%.*}.ogg" && rm -f "${audio_file}" +ffmpeg -y -v 24 -i "${video_file}" -i "${audio_file%%.*}.ogg" -c:v copy -c:a libvorbis -filter_complex "[1:0]apad" -shortest "${output}" && rm -f "$video_file" && rm -f "$audio_file" + +echo -e "\nDone.\n" + diff --git a/scriptlets/spacebarspam.sh b/scriptlets/spacebarspam.sh new file mode 100755 index 0000000..180e9a1 --- /dev/null +++ b/scriptlets/spacebarspam.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +while : ; do + + sleep 0.05 && xdotool key 'space' + +done + diff --git a/scriptlets/springcleaning.sh b/scriptlets/springcleaning.sh new file mode 100755 index 0000000..781a0b9 --- /dev/null +++ b/scriptlets/springcleaning.sh @@ -0,0 +1,34 @@ +#!/bin/sh + + +# keeping a fresh list of all explicitly installed packages + +pacman -Qqe > "/home/jay/stuf/ARESEES/pkglist.txt" +pacman -Qqen > "/home/jay/stuf/ARESEES/pkglist_native.txt" +pacman -Qqem > "/home/jay/stuf/ARESEES/pkglist_foreign.txt" + +# pacman -S --needed - < pkglist.txt to install them +# pacman -S --needed $(comm -12 <(pacman -Slq | sort) <(sort pkglist.txt)) to filter out the AUR ones +# pacman -Rsu $(comm -23 <(pacman -Qq | sort) <(sort pkglist.txt)) final check to make sure only listed packages are present on the system + +# ----------------------------------------------------------------------------------------------------------------------------- + +# removing all but 3 most recent package versions + +paccache -r +paccache -ruk0 # every version if said package is uninstalled + +# you can enable/start paccache.timer for the first one to happen automatically + +# ----------------------------------------------------------------------------------------------------------------------------- + +# removing orphaned packages + +pacman -Qtdq | pacman -Rns - + +# will throw an error if list is empty, this is fine +# pacman -Qqd | pacman -Rsu --print - does the same as above(?) but also hits circular and excessive dependencies + +# ----------------------------------------------------------------------------------------------------------------------------- + +# figure something out for dotfiles (google: rmshit.py) diff --git a/scriptlets/thunar_batch_opener.sh b/scriptlets/thunar_batch_opener.sh new file mode 100755 index 0000000..04fe54d --- /dev/null +++ b/scriptlets/thunar_batch_opener.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +browser="thunar" +winfile="$HOME/stuf/windows.txt" +mapfile -t < "$winfile" + +SAVEIFS=$IFS + +FLAG=0 +IFS=$'\n' +while IFS= read -r tab +do + + [[ -z "$tab" ]] && FLAG=1 && continue + + if [[ $FLAG -eq 1 ]]; then + FLAG=0 + xfconf-query -c thunar -p /misc-open-new-window-as-tab -s false + else + xfconf-query -c thunar -p /misc-open-new-window-as-tab -s true + fi + "$browser" "$( sed -r "s|\\\$HOME|$HOME|g" <<< "$tab" )" + sleep 0.5 + FLAG=0 +done < "$winfile" +IFS=$SAVEIFS +xfconf-query -c thunar -p /misc-open-new-window-as-tab -s true diff --git a/scriptlets/transmission_bell.sh b/scriptlets/transmission_bell.sh new file mode 100755 index 0000000..284fd05 --- /dev/null +++ b/scriptlets/transmission_bell.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +SOUNDS="$HOME/stuf/customization/sounds" + +nohup play "$SOUNDS/bell.mp3" >/dev/null 2>&1 & + + diff --git a/scriptlets/transmission_dirchooser.sh b/scriptlets/transmission_dirchooser.sh new file mode 100755 index 0000000..d7614ab --- /dev/null +++ b/scriptlets/transmission_dirchooser.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +START_DIR="$HOME/Downloads" +ROFI_THEME="ErikaScythe" +# CHANGE THEME + +DIR="$START_DIR" +FULL_DIR="$DIR" +while [[ -n $DIR && $DIR != "." ]]; do + DIR="$( { echo -e ".\n.."; find "${FULL_DIR}" -mindepth 1 -maxdepth 1 -type d | sed -r "s|^.*\/||g" | sort -V ; } | rofi -dmenu -i -no-custom -p "" -theme "$ROFI_THEME" -async-pre-read 3 -no-click-to-exit )" + FULL_DIR="${FULL_DIR}/${DIR}" +done + +[[ -z "$DIR" ]] && exit -1 + + +for file in "$@"; do + transmission-remote -a "$file" -w "$FULL_DIR" +done + diff --git a/scriptlets/treediff.sh b/scriptlets/treediff.sh new file mode 100755 index 0000000..3537e1f --- /dev/null +++ b/scriptlets/treediff.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +rsync -r --ignore-existing -i -n "$1" "$2" diff --git a/scriptlets/truth.sh b/scriptlets/truth.sh new file mode 100755 index 0000000..257c6a7 --- /dev/null +++ b/scriptlets/truth.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +TEXT="$(xclip -o -sel clip)" +TRUTH="" + +REDTRUTH='\e[2;31m' +BLUETRUTH='\e[2;34m' +GOLDENTRUTH='\e[2;33m' + +while getopts "hrbg" opt; do + case $opt in + h) echo -e "usage: $0 [-h help] [-r red truth] [-b blue truth] [-g golden truth]" ;; + r) TRUTH='```ansi\n'${REDTRUTH}${TEXT}'\e[0m\n```' ;; + b) TRUTH='```ansi\n'${BLUETRUTH}${TEXT}'\e[0m\n```' ;; + g) TRUTH='```ansi\n'${GOLDENTRUTH}${TEXT}'\e[0m\n```' ;; + ?) echo "error: option -$OPTARG is not implemented"; exit ;; + esac +done + +echo -e $TRUTH | xclip -sel clip diff --git a/scriptlets/unwebp.sh b/scriptlets/unwebp.sh new file mode 100755 index 0000000..49d8f5a --- /dev/null +++ b/scriptlets/unwebp.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +find "$PWD" -type f -name '*webp' -print0 | \ + while IFS= read -r -d '' file; do + newfile=$( echo "$file" | sed -r "s|nhentai_[0-9]+_0||g; s|\.webp$|.png|") + printf '%s ---> %s\n' "$file" "$newfile" + magick "$file" "$newfile" && rm -f "$file" + done diff --git a/scriptlets/url_processor.sh b/scriptlets/url_processor.sh new file mode 100755 index 0000000..98ae663 --- /dev/null +++ b/scriptlets/url_processor.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +BROWSER="chromium" +FLAGS="--profile-directory=Default" +LINK=$( sed -r "s|youtube\.com|yewtu\.be|g" <<< "$1" ) + +$BROWSER "$FLAGS" "$LINK" + diff --git a/scriptlets/veepeen_toggler.sh b/scriptlets/veepeen_toggler.sh new file mode 100755 index 0000000..2e9dd1d --- /dev/null +++ b/scriptlets/veepeen_toggler.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +declare -A connections=( ["shigoto"]="shigoto/vpn" ["ucell"]="shigoto/ucell/vpn" ["ums"]="shigoto/ums/vpn" ["telekomsrbija"]="shigoto/telekomsrbija/vpn" ) + +function get_from_pass () { + pass show "$1" | grep "^$2:" | sed -r "s|^$2: ||g" +} + +[[ $# < 1 ]] && echo -e "Please specify a VPN connection profile.\nOptions:\n$( for conn in "${!connections[@]}"; do echo "$conn"; done)" && exit -1 + +passentry="${connections["$1"]}" +[[ -z $passentry ]] && echo -e "ERROR. VPN CONNECTION PROFILE NOT FOUND\nOptions:\n$( for conn in "${!connections[@]}"; do echo "$conn"; done)" && exit -2 +CONN_NAME="$( get_from_pass "$passentry" "name" )" + +if [[ "$( nmcli c s | grep "$CONN_NAME" | sed -r "s|.*\s+([^ ]+)\s+|\1|g" )" != "--" ]]; then + echo "ALREADY CONNECTED. DISCONNECTING..." + nmcli con down "$CONN_NAME" +else + CONN_GATEWAY="$( get_from_pass "$passentry" "gateway" )" + CONN_CERTIFICATE="$( get_from_pass "$passentry" "certificate" )" + CONN_USERAGENT="$( get_from_pass "$passentry" "useragent" )" + + [[ -n $CONN_CERTIFICATE ]] && CERTFLAG="--servercert $CONN_CERTIFICATE" || CERTFLAG="" + [[ -n $CONN_USERAGENT ]] && USERAGENT="--useragent $CONN_USERAGENT" || USERAGENT="" + + CONN_USERNAME="$( get_from_pass "$passentry" "username" )" + CONN_PASSWORD="$( pass $passentry | head -n1 )" + echo "CONNECTING... " + + if get_from_pass "$passentry" "OTP" | grep -q "yes"; then + eval ` { echo "$CONN_PASSWORD"; read OTP; echo "$OTP"; } | openconnect $USERAGENT -u "$CONN_USERNAME" --passwd-on-stdin $CERTFLAG --authenticate $CONN_GATEWAY ` + # eval ` echo "$CONN_PASSWORD" | cat - /dev/tty | openconnect $USERAGENT -u "$CONN_USERNAME" --passwd-on-stdin $CERTFLAG --authenticate $CONN_GATEWAY ` + else + eval ` echo "$CONN_PASSWORD" | openconnect $USERAGENT -u "$CONN_USERNAME" --passwd-on-stdin $CERTFLAG --authenticate $CONN_GATEWAY ` + fi + + if [ -z "$COOKIE" ]; then + echo "ERROR: NO COOKIE" + exit 1 + else + nmcli con up "$CONN_NAME" passwd-file /proc/self/fd/5 5< <( printf "%s\n%s\n%s\n%s" "vpn.secrets.cookie:$COOKIE" "vpn.secrets.gwcert:$FINGERPRINT" "vpn.secrets.gateway:$CONN_GATEWAY" "vpn.secrets.resolve:$RESOLVE" ) + fi +fi diff --git a/scriptlets/wine_jp_config.sh b/scriptlets/wine_jp_config.sh new file mode 100644 index 0000000..ed48992 --- /dev/null +++ b/scriptlets/wine_jp_config.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +export LOCPATH=$HOME/.wine/locale-ja/ +mkdir -p $LOCPATH +localedef -f EUC-JP -i ja_JP $LOCPATH/ja_JP.EUC-JP +localedef -c -f SHIFT_JIS -i ja_JP $LOCPATH/ja_JP.SJIS + +## You get a warning that SHIFT_JIS is not ASCII compatible, that is normal. With that setup you can now run apps using +# env LOCPATH=$HOME/.wine/locale-ja/ LANG=ja_JP.SJIS wine prog.exe + +## or if the app is using EUC-JP (less common afaik) +# env LOCPATH=$HOME/.wine/locale-ja/ LANG=ja_JP.EUC-JP wine prog.exe + diff --git a/scriptlets/wine_jp_run.sh b/scriptlets/wine_jp_run.sh new file mode 100755 index 0000000..7bf14e4 --- /dev/null +++ b/scriptlets/wine_jp_run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +[[ "$1" =~ .*.exe$ ]] || { echo "ERROR"; exit -1; } + +env LOCPATH=$HOME/.wine/locale-ja/ LANG=ja_JP.SJIS wine "$1" |