From 0c9b0016c6e682832722942d68a5837250267380 Mon Sep 17 00:00:00 2001 From: "Arthur K." Date: Sun, 22 Dec 2024 19:10:54 +0300 Subject: [PATCH] YEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAH~ --- .config/zsh/.zshenv | 1 + .config/zsh/.zshrc | 1 + .local/bin/scripts/ie | 10 ++++++++- .local/bin/scripts/vid | 50 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100755 .local/bin/scripts/vid diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv index 5a62864..662444c 100644 --- a/.config/zsh/.zshenv +++ b/.config/zsh/.zshenv @@ -21,6 +21,7 @@ LC_TELEPHONE="en_US.UTF-8" LC_TIME="en_US.UTF-8" # default configs +ANDROID_HOME="${HOME}/.local/share/android" EDITOR="/usr/bin/nvim" GNUPGHOME='~/.local/share/gnupg' GOPATH="${HOME}/.local/share/go" diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 62e2806..c9d7631 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -122,6 +122,7 @@ alias grb="git rebase" alias grs="git restore --staged" alias grt="git reset" alias gs="git status" +alias gswc="git switch -c" # docker aliases alias dc="docker compose" diff --git a/.local/bin/scripts/ie b/.local/bin/scripts/ie index efbcc17..b49d95d 100755 --- a/.local/bin/scripts/ie +++ b/.local/bin/scripts/ie @@ -1,5 +1,7 @@ #!/bin/bash -e +set -o pipefail + API_ENDPOINT="http://ip-api.com/json/$1"'?fields=' FIELDS_FULL='7876383' FIELDS_SHORT='8192' @@ -21,7 +23,13 @@ if [ -t 0 ] && [ -t 1 ]; then elif [ -t 1 ]; then notify-send -i /dev/null "IP Info" "$(get_stats)" else - curl "${API_ENDPOINT}${FIELDS_SHORT}" 2>/dev/null | jq -r .query | tr -d $'\n' + if [ -n "$1" ]; then + resp="$(dig +short "$1" | tr -d $'\n')" + [ -n "$resp" ] && printf "%s" "$resp" || { echo 'Not found!' >&2; exit 1; } + else + curl "${API_ENDPOINT}${FIELDS_SHORT}" 2>/dev/null | jq -r .query | tr -d $'\n' + fi + # curl "${API_ENDPOINT}${FIELDS_SHORT}" 2>/dev/null | jq -r .query | tr -d $'\n' fi # vim: ft=bash diff --git a/.local/bin/scripts/vid b/.local/bin/scripts/vid new file mode 100755 index 0000000..5cc5103 --- /dev/null +++ b/.local/bin/scripts/vid @@ -0,0 +1,50 @@ +#!/bin/sh + +# thx https://github.com/mrsobakin + +VIDEO_DIR="$HOME/Videos/Screencap" +FRAMERATE=60 + +error() { + echo "$@" + exit 1 +} + +if [ "$1" = "--background" ]; then + [ -z "$XDG_RUNTIME_DIR" ] && error "XDG_RUNTIME_DIR is not set" + + LOCK_FILE="$XDG_RUNTIME_DIR/screencap.pid" + if [ -f "$LOCK_FILE" ]; then + echo "Stopping recording..." + kill "$(cat "$LOCK_FILE")" + rm -f "$LOCK_FILE" + exit 0 + fi +fi + + +slop -f "%wx%h :0.0+%x,%y" | { + read -r size pos + [ "$size" = "" ] && error "Interrupted area selection" + + echo "Starting recording..." + + record() { + exec ffmpeg \ + -video_size "$size" \ + -framerate "$FRAMERATE" \ + -thread_queue_size 4096 \ + -f x11grab -i "$pos" -c:v h264 \ + -f pulse -ac 2 -i default \ + "$VIDEO_DIR/$(date +%s%N).mp4" + } + + if [ "$1" != "--background" ]; then + record + else + record & + pid=$! + echo "$pid" > "$LOCK_FILE" + fi +} +