From 22d2c57240e65df482e30fbe684844c6b173aca2 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 14 Aug 2023 12:37:09 +0200 Subject: [saf] added load function --- bin/common/saf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/common/saf b/bin/common/saf index 0c6fbc4..dcc43d5 100755 --- a/bin/common/saf +++ b/bin/common/saf @@ -7,6 +7,15 @@ green="$(printf '\033[32m')" blue="$(printf '\033[34m')" reset="$(printf '\033[0m')" +load () +{ + for time in $(uptime | cut -f3- -d',' | cut -f2 -d':' | tr ',' ' ') + do + percent="$(echo "$time*100/$(nproc)" | bc)" + echo "${percent:-0}%" + 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 < Date: Mon, 14 Aug 2023 12:37:22 +0200 Subject: [saf] removed unused green color --- bin/common/saf | 1 - 1 file changed, 1 deletion(-) (limited to 'bin') diff --git a/bin/common/saf b/bin/common/saf index dcc43d5..9e31c68 100755 --- a/bin/common/saf +++ b/bin/common/saf @@ -3,7 +3,6 @@ # Simple Ass Fetch by futxlii red="$(printf '\033[31m')" -green="$(printf '\033[32m')" blue="$(printf '\033[34m')" reset="$(printf '\033[0m')" -- cgit v1.2.3 From 0b8685b836fb3cc034857438bf87076fa39af1a1 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 14 Aug 2023 12:50:14 +0200 Subject: [saf] remove bc dependency --- bin/common/saf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/common/saf b/bin/common/saf index 9e31c68..2936346 100755 --- a/bin/common/saf +++ b/bin/common/saf @@ -8,10 +8,11 @@ reset="$(printf '\033[0m')" load () { - for time in $(uptime | cut -f3- -d',' | cut -f2 -d':' | tr ',' ' ') - do - percent="$(echo "$time*100/$(nproc)" | bc)" - echo "${percent:-0}%" + # 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 } -- cgit v1.2.3 From e1893b1b31503adaa2c2484b57a5d7a4a5d0516c Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 14 Aug 2023 21:37:08 +0200 Subject: [googoo] fixed destination argument not working --- bin/common/goo | 2 +- config/essentials/zsh/functions.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/common/goo b/bin/common/goo index a56cbaf..cfd03ec 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:-$HOME} \(${dirs} -false \) -prune -o -type ${1:-f} -mindepth 1 -print" eval "$cmd" 2>/dev/null diff --git a/config/essentials/zsh/functions.zsh b/config/essentials/zsh/functions.zsh index 3c5f11f..e0eeb45 100644 --- a/config/essentials/zsh/functions.zsh +++ b/config/essentials/zsh/functions.zsh @@ -49,7 +49,7 @@ _googoo_fzf_opt () o () { _googoo_fzf_opt "$1" - f="$(goo f "dest" | fzf $opt)" + f="$(goo f "$dest" | fzf $opt)" test "$1" && shift test -f "$f" && $EDITOR $@ "$f" } -- cgit v1.2.3 From ece73a892806912ed45f875149065085690d64d4 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 15 Aug 2023 16:40:43 +0200 Subject: [y2feed] added support for different links You can now supply a channel id, a link to a channel or a tag, this should work with yt-local and piped as well. --- bin/common/y2feed | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'bin') 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" -- cgit v1.2.3 From 95926dbc3923e2f4f1a582713c7e6b0fb3fb9e6e Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 22 Aug 2023 11:52:56 +0200 Subject: [mpdf] refactor and use of commander introduce the use of commander to get rid of if else, also use tee to write to temporary file --- bin/menuscripts/mpdf | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'bin') 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" & -- cgit v1.2.3 From e68f87e355dab3094bf5195cb51fc79ce6f8569d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 22 Aug 2023 12:02:48 +0200 Subject: [mvid] refactor and use commander use tee to write to temp file, use commander instead of if else statement --- bin/menuscripts/mvid | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'bin') 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" -- cgit v1.2.3 From 57650e96e2c3a24d2101b5497c255f21b52d2f92 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 22 Aug 2023 22:03:13 +0200 Subject: [mpower] small refactor and added commander --- bin/menuscripts/mpower | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'bin') diff --git a/bin/menuscripts/mpower b/bin/menuscripts/mpower index 443ed54..005c497 100755 --- a/bin/menuscripts/mpower +++ b/bin/menuscripts/mpower @@ -1,14 +1,7 @@ #!/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" -- cgit v1.2.3 From dccf53c0d83973623e0d4c3f2550471232cf22b4 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 22 Aug 2023 22:25:53 +0200 Subject: [goo] search in pwd by default --- bin/common/goo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') 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 -- cgit v1.2.3 From 7ab95433e2d80ba03db7667795e72d398b9d2a7b Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 22 Aug 2023 22:31:08 +0200 Subject: [mpower] added extra newline --- bin/menuscripts/mpower | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/menuscripts/mpower b/bin/menuscripts/mpower index 005c497..3b66824 100755 --- a/bin/menuscripts/mpower +++ b/bin/menuscripts/mpower @@ -2,6 +2,7 @@ choice="$(printf 'poweroff suspend hibernate -reboot' | commander -c -d)" +reboot +' | commander -c -d)" [ "$choice" ] && systemctl "$choice" -- cgit v1.2.3