summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/common/ytlink20
-rwxr-xr-xbin/extra/curszip12
-rw-r--r--bin/extra/keyboards.txt2
-rwxr-xr-xbin/extra/qrclip12
-rwxr-xr-xbin/extra/udict12
-rwxr-xr-xbin/guiscripts/clipo4
-rwxr-xr-xbin/guiscripts/clipp6
-rwxr-xr-xbin/guiscripts/swclip (renamed from bin/guiscripts/cps)0
-rwxr-xr-xbin/menuscripts/mmedia2
-rwxr-xr-xbin/menuscripts/mpass4
-rwxr-xr-xbin/menuscripts/tsh29
11 files changed, 74 insertions, 29 deletions
diff --git a/bin/common/ytlink b/bin/common/ytlink
index 48be9cf..215c164 100755
--- a/bin/common/ytlink
+++ b/bin/common/ytlink
@@ -2,15 +2,21 @@
# convert to youtube.com/path url
# works for:
-# - 'youtu.be/watch?v=xxxxxx'
+# - 'youtu.be/xxxxxx'
# - 'https://piped.video/watch?v=xxxxx'
+# - https://youtube.com/watch?v=xxxx
-inp="$1"
-[ "${inp:=$(clipo)}" ] || inp="$(cat /dev/stdin)"
+# get from $1 or clipboard if empty
+vid="${1:-$(clipo)}"
+# The following subsitutions will try to grab the video id
# if link is http://127.0.0.1:9010/https://www.youtube.com/watch?v=7KpxsqwNF0o
-inp="${inp#*/https://}"
+vid="${vid#*/https://}"
# remove util scheme
-inp="${inp#*//}"
-inp="https://youtube.com/${inp#*/}"
-printf "%s" "$inp"
+vid="${vid#*//}"
+# remove domain
+vid="${vid#*/}"
+# remove query string
+vid="${vid#watch?v=}"
+
+printf "https://youtube.com/watch?v=%s\n" "$vid"
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/extra/keyboards.txt b/bin/extra/keyboards.txt
index db004ce..d6e9b8a 100644
--- a/bin/extra/keyboards.txt
+++ b/bin/extra/keyboards.txt
@@ -1,2 +1,2 @@
us
-us -option ctrl:swapcaps,altwin:menu_win -variant colemak
+colemak -option ctrl:swapcaps,altwin:menu_win
diff --git a/bin/extra/qrclip b/bin/extra/qrclip
new file mode 100755
index 0000000..f9dc92e
--- /dev/null
+++ b/bin/extra/qrclip
@@ -0,0 +1,12 @@
+#!/bin/sh
+case $1 in
+ '-o')
+ qrencode -s 16 "$(clipo)" -o - |
+ imv -w "imv - $(clipo)" - ;;
+ '-s')
+ qrencode -s 16 "https://duckduckgo.com/$(clipo)" -o - |
+ imv -w "imv - search $(clipo)" - ;;
+ *)
+ >&2 printf 'qrclip [-s | -o]\n'
+ exit 1
+esac
diff --git a/bin/extra/udict b/bin/extra/udict
new file mode 100755
index 0000000..77f9747
--- /dev/null
+++ b/bin/extra/udict
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+[ $# -eq 0 ] && printf '%s\n' "Usage:
+ udict some term" && exit 1
+
+term="$@"
+
+term="$(printf '%s\n' "${term}" | sed 's/ /\\/g' )"
+
+curl -s "https://api.urbandictionary.com/v0/define?term=${term}" |
+ jq -r '.list[0] | .word, .definition' |
+ sed -e 's/\[/\o033[1m/g' -e 's/\]/\o033[0m/g' -e '1s/^.*$/\o033[1;4;34m&\o033[0m/'
diff --git a/bin/guiscripts/clipo b/bin/guiscripts/clipo
index 078cc13..e554c24 100755
--- a/bin/guiscripts/clipo
+++ b/bin/guiscripts/clipo
@@ -1,6 +1,6 @@
#!/bin/sh
-[ "$1" = "-p" ] && arg='primary'
+[ "$1" = "-p" ] && i='primary' j="-p"
if [ "$WAYLAND_DISPLAY" ]
then wl-paste -n "$1"
-else xclip -o -selection "${arg:-clipboard}" -r
+else xsel -o ${j:--b}
fi
diff --git a/bin/guiscripts/clipp b/bin/guiscripts/clipp
index c9e4f51..c3ee8f2 100755
--- a/bin/guiscripts/clipp
+++ b/bin/guiscripts/clipp
@@ -1,6 +1,6 @@
#!/bin/sh
-[ "$1" = "-p" ] && arg='primary'
+[ "$1" = "-p" ] && i='primary' j='-p'
if [ "$WAYLAND_DISPLAY" ]
-then wl-copy -n $1
-else xclip -selection "${arg:-clipboard}" -r
+then wl-copy -n $i
+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 63d3f7b..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 -n -x -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/mpass b/bin/menuscripts/mpass
index 7029ffe..7348321 100755
--- a/bin/menuscripts/mpass
+++ b/bin/menuscripts/mpass
@@ -14,14 +14,14 @@ list_pswds()
while [ -d "$store/$file" ]
do
- choice="$(list_pswds "$store/$file" | commander -c)"
+ choice="$(list_pswds "$store/$file" | dmenu -c -g 4 -l 4)"
[ "$choice" ] || exit 1
[ -z "$file" ] && file="$choice" || file="$file/$choice"
done
[ "$file" ] || exit 1
pass show -c "$file" || exit 1
-notify-send -t 1000 "mpass" "copied <b>$file</b>"
+notify-send -t 1000 "mpass" "copied: $file"
[ "$WAYLAND_DISPLAY" ] && cliphist list >/dev/null && # on wayland and cliphist is running
cliphist list | head -n 1 | cliphist delete
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