summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-04-16 10:09:29 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-04-16 10:09:29 +0200
commit692bc52c20da866630fa401be6740bc38f8f8574 (patch)
treebe52e621dbbb15bfd2f43ec92053e4b0a817c392 /bin
parent197a1a74f468d9d69d624b19f90280a3946455e5 (diff)
parent19ea61db733c9152f2b334b0ae9871f81ac3664d (diff)
Merge branch 'main' of debuc.com:dotfiles
Diffstat (limited to 'bin')
-rwxr-xr-xbin/extra/rek16
-rwxr-xr-xbin/extra/upds51
-rwxr-xr-xbin/extra/usbtoggle25
-rwxr-xr-xbin/extra/wipe4
-rwxr-xr-xbin/extra/ytplay2
-rwxr-xr-xbin/guiscripts/clipo2
-rwxr-xr-xbin/menuscripts/mpass-otp4
7 files changed, 99 insertions, 5 deletions
diff --git a/bin/extra/rek b/bin/extra/rek
new file mode 100755
index 0000000..b5baac7
--- /dev/null
+++ b/bin/extra/rek
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# Record desktop with ffmpeg, strip metadata and use mp4 for relative small file size
+# copy the path of the output file to the system clipboard for sharing
+out="out.mp4"
+
+# with audio
+if [ "$1" = "-a" ]
+then
+ ffmpeg -y -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0+0,0 -f pulse -ac 2 -i default -map 0:v -map 0:a? -map_metadata -1 -map_metadata:s:v -1 -map_metadata:s:a -1 -map_chapters -1 -disposition 0 "$out"
+else
+ ffmpeg -y -video_size 1920x1080 -framerate 25 -f x11grab -i :0.0+0,0 -map 0:v -map 0:a? -map_metadata -1 -map_metadata:s:v -1 -map_metadata:s:a -1 -map_chapters -1 -disposition 0 "$out"
+fi
+
+# copy output path
+readlink -f "$out" | clipp
diff --git a/bin/extra/upds b/bin/extra/upds
new file mode 100755
index 0000000..38648ed
--- /dev/null
+++ b/bin/extra/upds
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+if [ "$1" = "install" ]
+then
+ hook="/etc/pacman.d/hooks/upds.hook"
+ if [ "$(id -u)" -ne 0 ]
+ then
+ >&2 printf 'Please run as root.\n'; exit 1
+ fi
+
+ if [ -f "$hook" ]
+ then
+ >&2 printf 'Hook already installed.\n'; exit 1
+ fi
+
+ # Install the hook
+ cat <<EOF > "$hook"
+# Hook for keeping available updates in sync after upgrade
+# relies on 'upds'
+[Trigger]
+Operation = Upgrade
+Type = Package
+Target = *
+[Action]
+Description = Sync upds
+When = PostTransaction
+Exec = /usr/bin/sh -c '/usr/bin/kill -s USR1 "\$(/usr/bin/pgrep upds | /usr/bin/head -n 1)"'
+EOF
+ >&2 printf 'Installed.\n'
+
+ exit
+fi
+
+count_updates() { checkupdates | wc -l > ~/.cache/updates; }
+
+# Periodically count updates in background
+(
+ while true
+ do
+ count_updates
+ sleep 60m
+ done
+) &
+
+# update on USR1 signal
+trap count_updates USR1
+
+# wait for signal
+while true
+do sleep 1s
+done
diff --git a/bin/extra/usbtoggle b/bin/extra/usbtoggle
new file mode 100755
index 0000000..7adb2a2
--- /dev/null
+++ b/bin/extra/usbtoggle
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# toggle an usb device
+
+# dependencies
+# - lsusb (to list usb devices)
+# - commander (menu command)
+# - doas (to run as root)
+
+device="$(lsusb | fzf)"
+[ "$device" ] || exit 1
+# get vendor id
+d=${device#*: * }
+v=${d%%:*}
+# get product id
+d=${device#*:*:}
+p=${d%% *}
+
+# find path by uzing vendor and product IDs
+file="$(grep -l "$p" $(grep -l "$v" /sys/bus/usb/devices/*/idVendor |
+ sed 's/idVendor/idProduct/') |
+ sed 's/idProduct$/authorized/')"
+
+echo 0 | doas tee "$file"
+echo 1 | doas tee "$file"
diff --git a/bin/extra/wipe b/bin/extra/wipe
index ec2abe9..6006b8e 100755
--- a/bin/extra/wipe
+++ b/bin/extra/wipe
@@ -2,8 +2,8 @@
[ 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"
+printf "sure? "
+[ "$(head -n 1)" != "y" ] && exit 1
find "$1" -type f -print0 |
xargs -0I{} shred -uz "{}" &&
diff --git a/bin/extra/ytplay b/bin/extra/ytplay
new file mode 100755
index 0000000..b5c1a8c
--- /dev/null
+++ b/bin/extra/ytplay
@@ -0,0 +1,2 @@
+#!/bin/sh
+yt-dlp -o - "$(ytlink)" | mpv -
diff --git a/bin/guiscripts/clipo b/bin/guiscripts/clipo
index 39994f9..078cc13 100755
--- a/bin/guiscripts/clipo
+++ b/bin/guiscripts/clipo
@@ -1,6 +1,6 @@
#!/bin/sh
[ "$1" = "-p" ] && arg='primary'
if [ "$WAYLAND_DISPLAY" ]
-then wl-paste -n ${1}
+then wl-paste -n "$1"
else xclip -o -selection "${arg:-clipboard}" -r
fi
diff --git a/bin/menuscripts/mpass-otp b/bin/menuscripts/mpass-otp
index 86690d3..52d1341 100755
--- a/bin/menuscripts/mpass-otp
+++ b/bin/menuscripts/mpass-otp
@@ -1,6 +1,6 @@
#!/bin/sh
-pass="$(find "$PASSWORD_STORE_DIR"/keys/otp -name "*.gpg" -printf '%f\n' |
- sed 's/\.gpg$//' |
+pass="$(find "$PASSWORD_STORE_DIR"/keys/otp -iname "*.gpg" |
+ sed "/^\./d;s#^$PASSWORD_STORE_DIR/keys/otp/##;s/\.gpg$//" |
commander -c)"
[ "$pass" ] || exit 1
pass otp -c keys/otp/"$pass"