summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-06-13 23:19:23 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-06-13 23:19:23 +0200
commit485c2d2ebaf238eb37a5650d364cb0031854774a (patch)
tree8b9c11c322c426e086b4172368c704920bb0d227 /bin
parent02da333eb51cc5f7cfc28e194681db0e5f59d485 (diff)
checkpoint
Diffstat (limited to 'bin')
-rwxr-xr-xbin/extra/curszip12
-rwxr-xr-xbin/guiscripts/clipo4
-rwxr-xr-xbin/guiscripts/clipp4
-rwxr-xr-xbin/guiscripts/swclip (renamed from bin/guiscripts/cps)0
-rwxr-xr-xbin/menuscripts/mmedia2
-rwxr-xr-xbin/menuscripts/tsh29
6 files changed, 33 insertions, 18 deletions
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/swclip
index 1cae135..1cae135 100755
--- a/bin/guiscripts/cps
+++ b/bin/guiscripts/swclip
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