summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/common/goo2
-rwxr-xr-xbin/common/ytclipo4
-rwxr-xr-xbin/extra/1xsearch20
-rwxr-xr-xbin/extra/confirm12
-rwxr-xr-xbin/extra/trl115
-rwxr-xr-xbin/extra/wipe13
-rwxr-xr-xbin/guiscripts/keyadd45
-rwxr-xr-xbin/guiscripts/startw1
-rwxr-xr-xbin/menuscripts/mhelp20
-rwxr-xr-xbin/menuscripts/mpass10
10 files changed, 188 insertions, 54 deletions
diff --git a/bin/common/goo b/bin/common/goo
index cfd03ec..a56cbaf 100755
--- a/bin/common/goo
+++ b/bin/common/goo
@@ -18,6 +18,6 @@ arduino15"
for dir in $exclude; do
dirs="$dirs -name \"$dir\" -o "
done
-cmd="find ${2:-$HOME} \(${dirs} -false \) -prune -o -type ${1:-f} -mindepth 1 -print"
+cmd="find ${dest:-$HOME} \(${dirs} -false \) -prune -o -type ${1:-f} -mindepth 1 -print"
eval "$cmd" 2>/dev/null
diff --git a/bin/common/ytclipo b/bin/common/ytclipo
index 263f1b3..7e7b9cc 100755
--- a/bin/common/ytclipo
+++ b/bin/common/ytclipo
@@ -19,8 +19,8 @@ notify-send "ytclipo" "<b>downloading</b> $inp"
yt-dlp "$inp" \
--restrict-filenames \
-f "b" \
- -S "res:720" \
+ -S "res:1080" \
-P "$HOME/vids/youtube/" \
- -o "%(title)s.%(ext)s"
+ -o "%(channel)s - %(title)s.%(ext)s"
notify-send "ytclipo" "<b>ytclipo</b><br>finished downloading."
echo "$inp" >> /tmp/ytclipo_history
diff --git a/bin/extra/1xsearch b/bin/extra/1xsearch
deleted file mode 100755
index a248d38..0000000
--- a/bin/extra/1xsearch
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-
-# dependencies
-which pup > /dev/null ||
- exit 1
-
-test -z "${query:=$1}" &&
- query="$(cat /dev/stdin)"
-
-url="https://1337x.to"
-query="$(echo "$query" | tr ' ' '+' )"
-result="$(curl -s "$url/search/$query/1/" |
- pup -p 'a attr{href}' |
- grep "^/torrent" |
- head -n 1)"
-# result contains / as first char
-curl -s "$url$result" |
- pup -p 'a attr{href}' |
- grep "^magnet:" |
- head -n 1
diff --git a/bin/extra/confirm b/bin/extra/confirm
new file mode 100755
index 0000000..116b468
--- /dev/null
+++ b/bin/extra/confirm
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+read_char ()
+{
+ old_stty_cfg=$(stty -g 2> /dev/null)
+ stty raw -echo 2> /dev/null
+ dd ibs=1 count=1 2> /dev/null
+ stty $old_stty_cfg 2> /dev/null
+}
+
+>&2 printf "$1 "
+read_char | grep -q "[yY]"
diff --git a/bin/extra/trl b/bin/extra/trl
new file mode 100755
index 0000000..ee42040
--- /dev/null
+++ b/bin/extra/trl
@@ -0,0 +1,115 @@
+#!/bin/sh
+
+# prints on stderr
+log () { >&2 echo "$@"; }
+
+help ()
+{
+ >&2 cat <<-EOF
+ h help
+ l clear output
+ q quit
+
+ i invert languages
+ p select primary
+ s select secondary
+ EOF
+}
+# returns available languages
+languages () {
+ cat <<-EOF
+ arabic
+ dutch
+ french
+ german
+ polish
+ english
+ portuguese
+ spanish
+ romanian
+ hebrew
+ swedish
+ italian
+ turkish
+ japanese
+ ukrainian
+ korean
+ chinese
+ czech
+ hungarian
+ danish
+ persian
+ greek
+ slovak
+ hindi
+ thai
+ EOF
+}
+
+# translates a word
+# $1: primary language
+# $2: secondary language
+# $3: word to translate
+translate ()
+{
+ curl -s "https://context.reverso.net/translation/$1-$2/$3" \
+ --compressed \
+ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0' \
+ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \
+ -H 'Accept-Language: en-US,en;q=0.5' \
+ -H 'Accept-Encoding: gzip, deflate, br' |
+ pup 'a.link_highlighted em text{}' |
+ sed 's/.*/\L&/' |
+ sort | uniq | sed 's/.*/ &/'
+}
+
+# prints the current language
+current_language ()
+{
+ log " current: $primary-$secondary"
+}
+
+select_language ()
+{
+ tmp="$(languages | fzf)"
+ [ "$tmp" ] && [ "$tmp" != "$primary" ] && [ "$tmp" != "$secondary" ] &&
+ eval "$1=\"$tmp\""
+ current_language
+}
+
+# set default languages
+primary=french
+secondary=dutch
+
+
+main ()
+{
+ current_language
+ while true
+ do
+ log -n '>'
+ read -r prompt
+ test $? -eq 1 && exit 0 # quit on ctrl-d
+ case "$prompt" in
+ q) break ;;
+ l) clear ;;
+ i) tmp="$secondary"; secondary="$primary"; primary="$tmp"
+ current_language ;;
+ h) help ;; # TODO
+ p) select_language primary ;;
+ s) select_language secondary ;;
+ '') ;;
+ *) translate "$primary" "$secondary" "$prompt" ;;
+ esac
+ done
+}
+
+
+if [ "$1" = "--help" ] || [ "$1" = "-h" ]
+then
+ log "usage: trl"
+ help
+ exit
+fi
+
+main
diff --git a/bin/extra/wipe b/bin/extra/wipe
new file mode 100755
index 0000000..ec2abe9
--- /dev/null
+++ b/bin/extra/wipe
@@ -0,0 +1,13 @@
+#!/bin/sh
+[ 0 -eq "$#" ] && >&2 echo 'usage: wipe <file>' && exit 1
+[ ! -f "$1" ] && [ ! -d "$1" ] && >&2 echo "'$1' not found." && exit 1
+
+confirm "sure?" || exit 1
+>&2 printf "\n"
+
+find "$1" -type f -print0 |
+ xargs -0I{} shred -uz "{}" &&
+ [ -d "$1" ] && # remove leftovver empty directories
+ find "$1" | tac | tr '\n' '\0' |
+ xargs -0I{} rm -d "{}" &&
+ >&2 echo "wiped."
diff --git a/bin/guiscripts/keyadd b/bin/guiscripts/keyadd
index 96d6d03..cb81efe 100755
--- a/bin/guiscripts/keyadd
+++ b/bin/guiscripts/keyadd
@@ -22,9 +22,24 @@ die ()
echo "$1" >&2
}
+notify ()
+{
+ notify-send -t 1000 "keyadd" "$1"
+ die "$1"
+}
+
+
SSHFOLDER="$HOME/.ssh"
-if test -z "${key:=$1}"
+# Test if can connect to ssh-agent
+ssh-add -l > /dev/null 2>&1
+if [ $? -gt 1 ] # ignore if there are no identities
+then
+ notify "Could not connect to agent."
+ exit 1
+fi
+
+if [ -z "${key:=$1}" ]
then
key="$(find "$SSHFOLDER" -iname "*.pub" |
sed "s,$SSHFOLDER/,," | # Clean
@@ -35,24 +50,26 @@ else
fi
die "key: $key"
-test ! -f "$SSHFOLDER/$key" && exit 1
+[ ! -f "$SSHFOLDER/$key" ] && exit 1
-HOST=$(hostnamectl hostname | sed 's/forlure/fl/;s/montecristo/mc/')
-die "HOST: $HOST"
+HOST=$(hostnamectl hostname)
+die "host: $HOST"
if [ "$1" = "-d" ]
then
- ssh-add -d - < "$SSHFOLDER"/$key.pub &&
- notify-send "$0" "deleted <b>$key</b>" ||
- notify-send "$0" "could not delete."
-elif ! ssh-add -l | grep -q "$(ssh-keygen -lf "$SSHFOLDER"/$key)"
+ if ssh-add -q -d - < "$SSHFOLDER"/"$key".pub 2> /dev/null
+ then
+ notify "Deleted <b>$key</b>"
+ else
+ notify "Could not delete."
+ fi
+# check if key is already added
+elif ssh-add -l | grep -q "$(ssh-keygen -lf "$SSHFOLDER"/"$key")"
then
- die "adding: $key"
+ notify "Key already added."
+else
export PASSWORD="keys/$HOST/ssh/$key"
export SSH_ASKPASS="$0"
- ssh-add - < "$SSHFOLDER"/$key &&
- notify-send "$0" "added <b>$key</b>"
-else
- die "key already added."
- notify-send "$0" "key already added."
+ ssh-add -q - < "$SSHFOLDER"/"$key" &&
+ notify "Added <b>$key</b>."
fi
diff --git a/bin/guiscripts/startw b/bin/guiscripts/startw
index 768f401..9b35556 100755
--- a/bin/guiscripts/startw
+++ b/bin/guiscripts/startw
@@ -1,5 +1,6 @@
#!/bin/sh
eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg,ssh)"
+eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg 3A626DD20A32EB2E5DD9CE71CFD9ABC97158CD5D 2> /dev/null)"
Hyprland
diff --git a/bin/menuscripts/mhelp b/bin/menuscripts/mhelp
index e03222b..5963a88 100755
--- a/bin/menuscripts/mhelp
+++ b/bin/menuscripts/mhelp
@@ -1,5 +1,4 @@
#!/usr/bin/env sh
-OPTIONS="/tmp/dmh_options.txt"
if [ "$MENUCMD" = "tofi" ]
then
@@ -16,18 +15,15 @@ fi
test -z "$program" && exit 1
-if $program --help > "$OPTIONS"
-then
- option="$(grep "^ *-[-a-zA-Z0-9]* " "$OPTIONS" |
- tr -s ' ' |
- sort |
- uniq |
- column -l 2 -t |
- $menucmd |
- awk '{print $1}')"
-fi
+option="$($program --help |
+ # Parse options
+ grep "^ *-[-a-zA-Z0-9]* " |
+ tr -s ' ' |
+ sort | uniq |
+ column -l 2 -t |
+ $menucmd |
+ awk '{print $1}')"
test -z "$option" && exit 1
-rm -f "$OPTIONS"
setsid $program $option
diff --git a/bin/menuscripts/mpass b/bin/menuscripts/mpass
index a50f0fb..4ecd4bc 100755
--- a/bin/menuscripts/mpass
+++ b/bin/menuscripts/mpass
@@ -16,10 +16,10 @@ do
[ "$choice" ] || break
file="$file/$choice"
done
-
test -z "$file" && exit 1
-pass show -c "$file" &&
- if [ -n "$WAYLAND_DISPLAY" ] && cliphist list >/dev/null
-then
+
+pass show -c "$file" || exit 1
+notify-send -t 1000 "mpass" "copied <b>$choice</b>"
+
+[ "$WAYLAND_DISPLAY" ] && cliphist list >/dev/null && # on wayland and cliphist is running
cliphist list | head -n 1 | cliphist delete
-fi