diff options
| author | filip <“filip.rabiega@gmail.com”> | 2026-02-14 17:18:10 +0100 |
|---|---|---|
| committer | filip <“filip.rabiega@gmail.com”> | 2026-02-14 17:18:10 +0100 |
| commit | d1ec85edcfb34f40f35759f59e66f2205d905aae (patch) | |
| tree | 3707fbf2fae5eb07fbfc2e3c42ffb6aafa436e66 | |
| parent | 0dea101a038ba195048b4d0bc704f203d9cd1316 (diff) | |
| download | chadscripts-d1ec85edcfb34f40f35759f59e66f2205d905aae.tar.gz chadscripts-d1ec85edcfb34f40f35759f59e66f2205d905aae.tar.bz2 chadscripts-d1ec85edcfb34f40f35759f59e66f2205d905aae.zip | |
add se texclear samedir openmd installfont fzo drecord
| -rwxr-xr-x | askpass | 4 | ||||
| -rwxr-xr-x | batterylow | 10 | ||||
| -rwxr-xr-x | bmks | 14 | ||||
| -rwxr-xr-x | dictloop | 5 | ||||
| -rwxr-xr-x | drecord | 124 | ||||
| -rwxr-xr-x | dz-feed | 2 | ||||
| -rwxr-xr-x | fzo | 14 | ||||
| -rwxr-xr-x | installfont | 9 | ||||
| -rwxr-xr-x | openmd | 15 | ||||
| -rwxr-xr-x | runchadguide | 3 | ||||
| -rwxr-xr-x | samedir | 10 | ||||
| -rwxr-xr-x | se | 16 | ||||
| -rwxr-xr-x | testcam | 7 | ||||
| -rwxr-xr-x | texclear | 15 | ||||
| -rwxr-xr-x | wrocwttr | 2 |
15 files changed, 226 insertions, 24 deletions
@@ -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" <&- @@ -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." @@ -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() { @@ -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 <dict>" >&2 @@ -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/slop + rm /tmp/slop + + ffmpeg \ + -f x11grab \ + -framerate 60 \ + -video_size "$W"x"$H" \ + -i :0.0+"$X,$Y" \ + -c:v libx264 -qp 0 -r 30 \ + "$HOME/box-$(date '+%y%m%d-%H%M-%S').mkv" & + echo $! >/tmp/recordingpid + updateicon "⏺️" +} + +case "$1" in +screencast) screencast ;; +audio) audio ;; +video) video ;; +*selected) videoselected ;; +kill) killrecording ;; +*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording ;; +esac @@ -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 | @@ -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 @@ -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 @@ -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" @@ -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" @@ -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 @@ -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" |
