summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-22 23:08:50 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-22 23:08:50 +0200
commit067b271a243dafcf652fe7cfe85e723d25ff1a64 (patch)
treec546402b2c40ca1e0739d1cc404f1d04d1d45067 /bin
parent67a2df82d25f52ea0937f4eed355546deae7b4b5 (diff)
parent9172676556847ff625cbf4b4eff19f441e0b9386 (diff)
Merge branch 'main' of /var/git/dotfiles
Diffstat (limited to 'bin')
-rwxr-xr-xbin/common/goo2
-rwxr-xr-xbin/common/saf13
-rwxr-xr-xbin/common/y2feed21
-rwxr-xr-xbin/menuscripts/mpdf24
-rwxr-xr-xbin/menuscripts/mpower18
-rwxr-xr-xbin/menuscripts/mvid29
6 files changed, 50 insertions, 57 deletions
diff --git a/bin/common/goo b/bin/common/goo
index a56cbaf..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 ${dest:-$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/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/menuscripts/mpdf b/bin/menuscripts/mpdf
index d67fdae..85debfb 100755
--- a/bin/menuscripts/mpdf
+++ b/bin/menuscripts/mpdf
@@ -1,22 +1,10 @@
#!/bin/sh
-if [ "$MENUCMD" = "tofi" ]
-then
- menucmd="tofi --width 30% --height 30% --matching-algorithm normal --prompt-text pdf:"
-elif [ "$MENUCMD" = "dmenu" ]
-then
- menucmd="dmenu -l 10 -g 1 -x -i -p pdf:"
-else
- menucmd="fzf"
-fi
-
-tmp="/tmp/dmpdf"
-find ${1:-$HOME/docs $HOME/dl} 2> /dev/null | grep -E ".+\.pdf" | sort > "$tmp"
-choice="$(sed "s|^$HOME|\~| ; s|\([^/]\)[^/]*/|\1/|g" "$tmp" |
- awk '{printf "%s %s\n", NR ":", $0}' |
- $menucmd |
- grep -o "^[0-9]\+:" |
- cut -f 1 -d :)"
-test -z "$choice" && exit 1
+tmp="/tmp/mpdf"
+choice="$(find ${1:-$HOME/docs $HOME/dl} -iname "*.pdf" 2> /dev/null | sort |
+ tee "$tmp" |
+ sed "s|^$HOME|\~| ; s|\([^/]\)[^/]*/|\1/|g" |
+ commander -x -n)"
file="$(sed -n "${choice}p" "$tmp")"
+[ -r "$file" ] || exit 1
zathura "$file" &
diff --git a/bin/menuscripts/mpower b/bin/menuscripts/mpower
index 443ed54..3b66824 100755
--- a/bin/menuscripts/mpower
+++ b/bin/menuscripts/mpower
@@ -1,14 +1,8 @@
#!/bin/sh
-if [ "$MENUCMD" = "tofi" ]
-then
- menucmd="tofi --width 10% --height 13% --padding-left 2%"
-elif [ "$MENUCMD" = "dmenu" ]
-then
- menucmd="dmenu -g 2 -l 2"
-else
- menucmd="fzf"
-fi
+choice="$(printf 'poweroff
+suspend
+hibernate
+reboot
+' | commander -c -d)"
-choices="poweroff\nreboot\nhibernate\nsuspend"
-choice="$(printf "$choices" | $menucmd)"
-test -z "$choice" || systemctl "$choice"
+[ "$choice" ] && systemctl "$choice"
diff --git a/bin/menuscripts/mvid b/bin/menuscripts/mvid
index ca309fb..09ebab8 100755
--- a/bin/menuscripts/mvid
+++ b/bin/menuscripts/mvid
@@ -1,27 +1,16 @@
#!/usr/bin/env sh
-tmpfile="/tmp/dmvids"
+tmp="/tmp/dmvids"
dirs="${1:-$HOME/vids $HOME/dl}"
-find -L $dirs 2> /dev/null |
- grep ".\+\.\(webm\|mp4\|mpeg\|mkv\)$" |
- sort > "$tmpfile"
-if [ "$MENUCMD" = "tofi" ]
-then
- menucmd="tofi --width 30% --height 30% --matching-algorithm normal"
-elif [ "$MENUCMD" = "dmenu" ]
-then
- menucmd="dmenu -l 10 -g 1 -x -i"
-else
- menucmd="fzf"
-fi
+choice="$(find -L $dirs 2> /dev/null |
+ grep '^.\+\.\(webm\|mp4\|mpeg\|mkv\)$' |
+ sort | tee "$tmp" |
+ sed "s#^$HOME#\~#;s#\([^/]\)[^/]*/#\1/#g" |
+ commander -n -x)"
-choice="$(sed "s|^$HOME|\~| ; s|\([^/]\)[^/]*/|\1/|g" "$tmpfile" |
- awk '{printf "%s %s\n", NR ":", $0}' |
- $menucmd |
- cut -f 1 -d ':')"
-test -z "$choice" &&
- exit 1
+file="$(sed -n "${choice}p" "$tmp")"
+[ -r "$file" ] || exit 1
-mpv "$(sed -n "${choice}p" "$tmpfile")"
+mpv "$file"