From d1ec85edcfb34f40f35759f59e66f2205d905aae Mon Sep 17 00:00:00 2001 From: filip <“filip.rabiega@gmail.com”> Date: Sat, 14 Feb 2026 17:18:10 +0100 Subject: add se texclear samedir openmd installfont fzo drecord --- askpass | 4 +- batterylow | 10 ++--- bmks | 14 +++---- dictloop | 5 --- drecord | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dz-feed | 2 +- fzo | 14 +++++++ installfont | 9 +++++ openmd | 15 ++++++++ runchadguide | 3 ++ samedir | 10 +++++ se | 16 ++++++++ testcam | 7 +++- texclear | 15 ++++++++ wrocwttr | 2 +- 15 files changed, 226 insertions(+), 24 deletions(-) create mode 100755 drecord create mode 100755 fzo create mode 100755 installfont create mode 100755 openmd create mode 100755 runchadguide create mode 100755 samedir create mode 100755 se create mode 100755 texclear diff --git a/askpass b/askpass index 2c14e6f..bbc52a2 100755 --- a/askpass +++ b/askpass @@ -1,6 +1,6 @@ #!/bin/sh -# This script is the SUDO_ASKPASS variable, meaning that it will be used as a +# This script is the SSH_ASKPASS and SUDO_ASKPASS variables, meaning that it will be used as a # password prompt if needed. -dmenu -fn Monospace-18 -P -p "$1" <&- && echo +dmenu -fn Monospace-18 -P -p "$1" <&- diff --git a/batterylow b/batterylow index 85cdf5d..c083670 100755 --- a/batterylow +++ b/batterylow @@ -4,16 +4,12 @@ battery=$(upower -e | grep BAT | head -n 1) -percentage=$(upower -i "$battery" | - awk '/percentage/ {gsub(/%/, "", $2); print $2}') +percentage=$(upower -i "$battery" | awk '/percentage/ {gsub(/%/, "", $2); print $2}') -state=$(upower -i "$battery" | - awk '/state/ {print $2}') +state=$(upower -i "$battery" | awk '/state/ {print $2}') # Only notify if the battery is discharging -if [ "$state" != "discharging" ]; then - exit 0 -fi +[ "$state" != "discharging" ] && exit 0 if [ "$percentage" -le 5 ]; then notify-send "Battery very low." diff --git a/bmks b/bmks index 6ac46f9..d1621e3 100755 --- a/bmks +++ b/bmks @@ -46,14 +46,14 @@ bmks_ls() { } bmks_del() { - bmks_check - case $PREFERED_LAUNCHER in - dmenu) sel=$(sort "$URL_FILE_PATH/$URL_FILE_NAME" | dmenu -i -l 15) ;; - fzf) sel=$(sort "$URL_FILE_PATH/$URL_FILE_NAME" | fzf) ;; - esac + bmks_check + case $PREFERED_LAUNCHER in + dmenu) sel=$(sort "$URL_FILE_PATH/$URL_FILE_NAME" | dmenu -i -l 15) ;; + fzf) sel=$(sort "$URL_FILE_PATH/$URL_FILE_NAME" | fzf) ;; + esac - [ -n "$sel" ] && grep -vF -- "$sel" "$URL_FILE_PATH/$URL_FILE_NAME" > /tmp/bmks && \ - mv /tmp/bmks "$URL_FILE_PATH/$URL_FILE_NAME" + [ -n "$sel" ] && grep -vF -- "$sel" "$URL_FILE_PATH/$URL_FILE_NAME" >/tmp/bmks && + mv /tmp/bmks "$URL_FILE_PATH/$URL_FILE_NAME" } bmks_display() { diff --git a/dictloop b/dictloop index b58f56f..23ba1b0 100755 --- a/dictloop +++ b/dictloop @@ -1,11 +1,6 @@ #!/bin/sh # Script for checking multiple definitions one after another -# Load aliases if available -if [ -n "$ZDOTDIR" ] && [ -f "$ZDOTDIR/aliasrc" ]; then - . "$ZDOTDIR/aliasrc" -fi - # Argument check if [ "$#" -ne 1 ]; then echo "Usage: dictloop " >&2 diff --git a/drecord b/drecord new file mode 100755 index 0000000..5058a44 --- /dev/null +++ b/drecord @@ -0,0 +1,124 @@ +#!/bin/sh + +# Usage: +# `$0`: Ask for recording type via dmenu +# `$0 screencast`: Record both audio and screen +# `$0 video`: Record only screen +# `$0 audio`: Record only audio +# `$0 kill`: Kill existing recording +# +# If there is already a running instance, user will be prompted to end it. + +updateicon() { + echo "$1" >/tmp/recordingicon + pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}" +} + +killrecording() { + recpid="$(cat /tmp/recordingpid)" + # kill with SIGTERM, allowing finishing touches. + kill -15 "$recpid" + rm -f /tmp/recordingpid + updateicon "" + pkill -RTMIN+9 "${STATUSBAR:-dwmblocks}" + # even after SIGTERM, ffmpeg may still run, so SIGKILL it. + sleep 3 + kill -9 "$recpid" + exit +} + +screencast() { + ffmpeg -y \ + -f x11grab \ + -framerate 60 \ + -s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \ + -i "$DISPLAY" \ + -f alsa -i default \ + -r 30 \ + -c:v h264 -crf 0 -preset ultrafast -c:a aac \ + "$HOME/screencast-$(date '+%y%m%d-%H%M-%S').mp4" & + echo $! >/tmp/recordingpid + updateicon "⏺️🎙️" +} + +video() { + ffmpeg \ + -f x11grab \ + -s "$(xdpyinfo | awk '/dimensions/ {print $2;}')" \ + -i "$DISPLAY" \ + -c:v libx264 -qp 0 -r 30 \ + "$HOME/video-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! >/tmp/recordingpid + updateicon "⏺️" +} + +webcamhidef() { + ffmpeg \ + -f v4l2 \ + -i /dev/video0 \ + -video_size 1920x1080 \ + "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! >/tmp/recordingpid + updateicon "🎥" +} + +webcam() { + ffmpeg \ + -f v4l2 \ + -i /dev/video0 \ + -video_size 640x480 \ + "$HOME/webcam-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! >/tmp/recordingpid + updateicon "🎥" +} + +audio() { + ffmpeg \ + -f alsa -i default \ + -c:a flac \ + "$HOME/audio-$(date '+%y%m%d-%H%M-%S').flac" & + echo $! >/tmp/recordingpid + updateicon "🎙️" +} + +askrecording() { + choice=$(printf "screencast\\nvideo\\nvideo selected\\naudio\\nwebcam\\nwebcam (hi-def)" | dmenu -i -p "Select recording style:") + case "$choice" in + screencast) screencast ;; + audio) audio ;; + video) video ;; + *selected) videoselected ;; + webcam) webcam ;; + "webcam (hi-def)") webcamhidef ;; + esac +} + +asktoend() { + response=$(printf "Yes\\nNo" | dmenu -i -p "Recording still active. End recording?") && + [ "$response" = "Yes" ] && killrecording +} + +videoselected() { + slop -f "%x %y %w %h" >/tmp/slop + read -r X Y W H /tmp/recordingpid + updateicon "⏺️" +} + +case "$1" in +screencast) screencast ;; +audio) audio ;; +video) video ;; +*selected) videoselected ;; +kill) killrecording ;; +*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording ;; +esac diff --git a/dz-feed b/dz-feed index 0b595ad..8d3caeb 100755 --- a/dz-feed +++ b/dz-feed @@ -1,7 +1,7 @@ #!/bin/sh # Cache pdf files to be opened with dz -cache="$HOME/.cache/dz" +cache="${XDG_CACHE_HOME:-$HOME/.cache}"/dz if [ "$1" = "-r" ] || [ ! -e "$cache" ]; then find "$HOME" -mindepth 1 \( -name ".*" -o -path "$HOME/cell" -o -path "$HOME/phone/*" \) -prune -o -print | diff --git a/fzo b/fzo new file mode 100755 index 0000000..576125e --- /dev/null +++ b/fzo @@ -0,0 +1,14 @@ +#!/bin/sh + +: "${EDITOR:=${VISUAL:=vi}}" + +file=$( + find . -maxdepth 5 -type f -readable \ + -not -path '*/.git/*' 2>/dev/null | + sed 's|^\./||' | + sort --ignore-case --unique | + fzf --prompt="Open file > " \ + --preview 'sed -n "1,200p" {}' +) + +[ -n "$file" ] && "$EDITOR" "$file" diff --git a/installfont b/installfont new file mode 100755 index 0000000..5fd978f --- /dev/null +++ b/installfont @@ -0,0 +1,9 @@ +#!/bin/sh +# Example: ./install-nerd-font.sh JetBrainsMono +FONT=$1 +mkdir -p ~/.local/share/fonts +cd ~/.local/share/fonts || exit +wget "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/${FONT}.zip" +unzip "${FONT}.zip" +rm "${FONT}.zip" LICENSE.md readme.md +fc-cache -fv diff --git a/openmd b/openmd new file mode 100755 index 0000000..0a9a889 --- /dev/null +++ b/openmd @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: openmd file" + exit 1 +fi + +file="$1" +tmp_pdf="$(mktemp --suffix=.pdf)" + +pandoc "$file" -o "$tmp_pdf" &>/dev/null +zathura "$tmp_pdf" + +# cleanup after zathura closes +rm -f "$tmp_pdf" diff --git a/runchadguide b/runchadguide new file mode 100755 index 0000000..714eef2 --- /dev/null +++ b/runchadguide @@ -0,0 +1,3 @@ +#!/bin/sh + +poetry run gunicorn -w 4 -k uvicorn.workers.UvicornWorker src.fastapi.flights_api:app --bind 0.0.0.0:8000 diff --git a/samedir b/samedir new file mode 100755 index 0000000..0a19707 --- /dev/null +++ b/samedir @@ -0,0 +1,10 @@ +#!/bin/sh + +# Open a terminal window in the same directory as the currently active window. + +PID=$(xprop -id "$(xprop -root | xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p") +PID="$(pstree -lpA "$PID")" +PID="${PID##*(}" +PID="${PID%)}" +cd "$(readlink /proc/"$PID"/cwd)" || return 1 +"$TERMINAL" diff --git a/se b/se new file mode 100755 index 0000000..5450a5c --- /dev/null +++ b/se @@ -0,0 +1,16 @@ +#!/bin/sh + +: "${EDITOR:=${VISUAL:=vi}}" +: "${SCRIPTS:=$HOME/.scripts}" + +file=$( + find "$SCRIPTS" -maxdepth 2 -type f -readable \ + -not -path '*/.git/*' \ + -or -not -name '\.*' 2>/dev/null | + sed 's|^\./||' | + sort --ignore-case --unique | + fzf --prompt="Open script > " \ + --preview 'sed -n "1,200p" {}' +) + +[ -n "$file" ] && "$EDITOR" "$file" diff --git a/testcam b/testcam index 7b36cd1..d126306 100755 --- a/testcam +++ b/testcam @@ -1,3 +1,8 @@ #!/bin/sh -ffmpeg -f v4l2 -i /dev/video0 -f matroska - | mpv - +# ffmpeg -f v4l2 -i /dev/video0 -f matroska - | mpv - + +ffmpeg -f v4l2 -input_format mjpeg -framerate 30 \ + -i /dev/video0 \ + -vcodec copy -f matroska - | + mpv --no-cache --demuxer-readahead-secs=0 --untimed - diff --git a/texclear b/texclear new file mode 100755 index 0000000..73aa60e --- /dev/null +++ b/texclear @@ -0,0 +1,15 @@ +#!/bin/sh + +# Clears the build files of a LaTeX/XeLaTeX build. +# I have nvim run this file whenever I exit a .tex file. + +case "$1" in +*.tex) + file=$(readlink -f "$1") + dir=$(dirname "$file") + base="${file%.*}" + find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyg|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete + rm -rdf "$dir/_minted-$(basename -- $base)" + ;; +*) printf "Give .tex file as argument.\\n" ;; +esac diff --git a/wrocwttr b/wrocwttr index 727a464..9f29f48 100755 --- a/wrocwttr +++ b/wrocwttr @@ -2,7 +2,7 @@ # Check the temperature in Wrocław, Poland CITY="Wroc%C5%82aw" -CACHE_DIR="$HOME/.cache/weather" +CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/weather" FILE="$CACHE_DIR/wroc.txt" mkdir -p "$CACHE_DIR" -- cgit v1.2.3