summaryrefslogtreecommitdiff
path: root/bin/common
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-30 08:23:45 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-30 08:23:45 +0200
commit3f8594ee04d2a3d9b40a259daf3b564a53b510fa (patch)
tree66ed50643cdc81af813b5771a99732d0f78bb618 /bin/common
parent45d39ae0c67bb086f4df0c366b251e06c888408d (diff)
parent333aaf38c66a1e4ba41d3acea38b21613c0075b2 (diff)
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/common')
-rwxr-xr-xbin/common/goo2
-rwxr-xr-xbin/common/saf13
-rwxr-xr-xbin/common/toush14
-rwxr-xr-xbin/common/y2feed21
-rwxr-xr-xbin/common/ytclipo4
5 files changed, 36 insertions, 18 deletions
diff --git a/bin/common/goo b/bin/common/goo
index cfd03ec..cb7a8b6 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 ${2:-.} \(${dirs} -false \) -prune -o -type ${1:-f} -mindepth 1 -print"
eval "$cmd" 2>/dev/null
diff --git a/bin/common/saf b/bin/common/saf
index 0c6fbc4..2936346 100755
--- a/bin/common/saf
+++ b/bin/common/saf
@@ -3,10 +3,19 @@
# Simple Ass Fetch by futxlii
red="$(printf '\033[31m')"
-green="$(printf '\033[32m')"
blue="$(printf '\033[34m')"
reset="$(printf '\033[0m')"
+load ()
+{
+ # take everything after 'load average: ' then remove '0.' or '.' or ','
+ # from output, this multiplies by hundred, so we can divide an integer
+ # instead of a fraction (which dash can't do)
+ for time in $(uptime | sed -e 's/^.*load average://' -e 's/0\?\.\|,//g')
+ do printf "%s%%\n" "$((time/$(nproc)))"
+ done | xargs
+}
+
for file in /etc/os-release /usr/lib/os-release
do
[ -f "$file" ] && . "$file" && break
@@ -19,6 +28,6 @@ SHELL="$(basename "$SHELL")"
cat <<EOF
${red}- ${blue}${ID:-"unknown"}
${red}- ${blue}$KERNEL
- ${red}- ${blue}$UPTIME
+ ${red}- ${blue}$UPTIME ($(load))
${red}- ${blue}$SHELL${reset}
EOF
diff --git a/bin/common/toush b/bin/common/toush
index dd675b9..eb2d7cf 100755
--- a/bin/common/toush
+++ b/bin/common/toush
@@ -1,14 +1,10 @@
#!/bin/sh
-# fork of
-# https://codeberg.org/futxlii/bin/toush :)
+# idea from https://codeberg.org/futxlii/bin/toush :)
shebang='#!/bin/sh'
-usage() { >&2 printf 'Usage: %s' "${0##*/}"; exit 1 ;}
+[ -f "$1" ] && exit 1
-[ "$1" ] || usage
-while [ "$1" ]; do
- [ -f "$1" ] && usage
- printf '%s\n\n' "$shebang" > "$1" && chmod +x "$1"
- shift
-done
+printf '%s\n\n' "$shebang" > "$1" &&
+ chmod +x "$1" && $EDITOR "$1"
+grep -qv "$shebang\|^$" "$1" || rm "$1"
diff --git a/bin/common/y2feed b/bin/common/y2feed
index e30bccf..b55d66b 100755
--- a/bin/common/y2feed
+++ b/bin/common/y2feed
@@ -1,5 +1,18 @@
#!/bin/sh
-echo "url: $1" >&2
-curl -L -s "$1" |
- pup 'link[title=RSS] attr{href}' |
- tee /dev/stderr
+
+get_feed()
+{
+ link="$(curl -L -s "$1" | pup 'link[title=RSS] attr{href}' 2>/dev/null)"
+ [ "$link" ] && printf "%s\n" "$link" | tee /dev/stderr && exit
+}
+
+[ "$1" ] || exit 1
+
+# url is channel
+get_feed "$1"
+
+part="$(echo "$1" | awk -F '/' '{print $NF}')"
+# last part is channel id
+get_feed "https://www.youtube.com/channel/$part"
+# last part is channel tag
+get_feed "https://www.youtube.com/$part"
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