summaryrefslogtreecommitdiff
path: root/bin/extra
diff options
context:
space:
mode:
Diffstat (limited to 'bin/extra')
-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
5 files changed, 96 insertions, 2 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 -