From 485c2d2ebaf238eb37a5650d364cb0031854774a Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 13 Jun 2024 23:19:23 +0200 Subject: checkpoint --- bin/extra/curszip | 12 ++++++++---- bin/guiscripts/clipo | 4 ++-- bin/guiscripts/clipp | 4 ++-- bin/guiscripts/cps | 4 ---- bin/guiscripts/swclip | 4 ++++ bin/menuscripts/mmedia | 2 +- bin/menuscripts/tsh | 29 ++++++++++++++++++++--------- 7 files changed, 37 insertions(+), 22 deletions(-) delete mode 100755 bin/guiscripts/cps create mode 100755 bin/guiscripts/swclip (limited to 'bin') diff --git a/bin/extra/curszip b/bin/extra/curszip index 64abdb6..0de772f 100755 --- a/bin/extra/curszip +++ b/bin/extra/curszip @@ -1,13 +1,17 @@ #!/bin/sh -list1() { find "$1" -mindepth 1 -maxdepth 1 -type "${2:-d}" -printf '%f\n'; } +# $1: dir +# $2: type +list1() { find "$1" -mindepth 1 -maxdepth 1 -type "$2" -printf '%f\n'; } -curs="$(list1 ~/docs/school/Vakken | commander -c)" +curs="$(list1 ~/docs/school/Vakken d | dmenu -c)" [ "$curs" ] || exit 1 -zip="$(list1 ~/dl f | fzf -f "$curs" | grep '\.zip$')" >&2 printf "curs: %s\n" "$curs" -[ "$zip" ] || exit 1 +dldir="$(which xdg-user-dir > /dev/null 2>&1 && xdg-user-dir 'DOWNLOAD' || echo '~/dl')" + +zip="$(list1 "$dldir" f | fzf -f "$curs" | grep '\.zip$')" +[ "$zip" ] || exit 1 >&2 printf "zip: %s\n" "$zip" cd -- ~/docs/school/Vakken/"$curs" || exit 1 diff --git a/bin/guiscripts/clipo b/bin/guiscripts/clipo index ebc9a25..e554c24 100755 --- a/bin/guiscripts/clipo +++ b/bin/guiscripts/clipo @@ -1,6 +1,6 @@ #!/bin/sh -[ "$1" = "-p" ] && i='primary' j="-b" +[ "$1" = "-p" ] && i='primary' j="-p" if [ "$WAYLAND_DISPLAY" ] then wl-paste -n "$1" -else xsel -o $j +else xsel -o ${j:--b} fi diff --git a/bin/guiscripts/clipp b/bin/guiscripts/clipp index d545087..c3ee8f2 100755 --- a/bin/guiscripts/clipp +++ b/bin/guiscripts/clipp @@ -1,6 +1,6 @@ #!/bin/sh -[ "$1" = "-p" ] && i='primary' j='-b' +[ "$1" = "-p" ] && i='primary' j='-p' if [ "$WAYLAND_DISPLAY" ] then wl-copy -n $i -else xsel $j +else xsel ${j:--b} fi diff --git a/bin/guiscripts/cps b/bin/guiscripts/cps deleted file mode 100755 index 1cae135..0000000 --- a/bin/guiscripts/cps +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -paste="$(clipo)" -clipo -p | clipp -printf '%s' "$paste" | clipp -p diff --git a/bin/guiscripts/swclip b/bin/guiscripts/swclip new file mode 100755 index 0000000..1cae135 --- /dev/null +++ b/bin/guiscripts/swclip @@ -0,0 +1,4 @@ +#!/bin/sh +paste="$(clipo)" +clipo -p | clipp +printf '%s' "$paste" | clipp -p diff --git a/bin/menuscripts/mmedia b/bin/menuscripts/mmedia index 43a8aca..3141c3b 100755 --- a/bin/menuscripts/mmedia +++ b/bin/menuscripts/mmedia @@ -51,7 +51,7 @@ choice="$( grep "$regex" | sort | tee "$tmp" | concat_path | - dmenu -px -c -i -l 10 -g 1 -F)" + dmenu -px -c -i -l 10 -g 1 -x)" file="$(sed -n "${choice}p" "$tmp")" [ -r "$file" ] || exit 1 diff --git a/bin/menuscripts/tsh b/bin/menuscripts/tsh index eac0c3e..aac27ee 100755 --- a/bin/menuscripts/tsh +++ b/bin/menuscripts/tsh @@ -19,7 +19,7 @@ done export results="$tmp/results" export links="$tmp/links" -types="music anime movies shows other software games isos books" +categories="music anime movies shows other software games isos books" if [ "$WAYLAND_DISPLAY" ] then @@ -42,6 +42,9 @@ help () Available options: seeds, size, name -m MODULE Select a module, if MODULE is 'list', lists out available modules + -c CATEGORY Select category + -f Do not list files + -d Download without confirming EOF } @@ -121,7 +124,7 @@ show_files() # Select a type after having displayed them with 'show_types' select_type() { - for type in $types + for type in $categories do printf "%s\n" "$type" done | fzf } @@ -131,10 +134,17 @@ trap "cleanup" EXIT ## OPTIONS skip=0 -while getopts ":hm:rs:" opt +while getopts ":hm:rs:c:fd" opt do case $opt in h) help && exit ;; + c) + [ "$OPTARG" = "list" ] && >&2 printf '%s\n' "$categories" && exit + category="$(printf '%s\n' "$categories" | tr ' ' '\n' | grep -m 1 "^$OPTARG")" + [ -z "$category" ] && die "No valid category for '$OPTARG'" + logn "category: $category" ;; + f) noaskfiles="1" ;; + d) noaskdownload="1" ;; m) [ "$OPTARG" = "list" ] && list_modules && exit module="$(list_modules | grep -m 1 "^$OPTARG")" @@ -185,17 +195,18 @@ getfunctions=1 . "$LIBPFX/$module" # select result from "$results" for choice in $(select_result | xargs) do - printf 'choice: %s\n' "$choice" + printf 'choice: %s\n' "$(sed -n "${choice}p" "$results" | cut -f 3-)" magnet="$(get_magnet "$choice")" [ "$magnet" ] || exit 1 - confirm 'files?' && show_files "$magnet" + if [ -z "$noaskfiles" ] && confirm 'files?'; then + show_files "$magnet" + fi - if confirm 'download?' + if [ "$noaskdownload" ] || confirm 'download?' then - type="$(select_type)" - [ "$type" ] || exit 1 - transmission-remote debuc.com -a "$magnet" -w "/downloads/$type" + [ "${category:-$(select_type)}" ] || exit 1 + transmission-remote debuc.com -a "$magnet" -w "/downloads/$category" elif confirm "copy?" then echo "$magnet" | clipp -- cgit v1.2.3