Author: Adam Evyčędo <git@apiote.xyz>
move scripts to functions
.config/fish/config.fish | 4 .config/sh/aliases | 2 .config/sh/functions | 800 ++++++++++++++++++++++++------------- .config/sway/config | 29 .config/sway/sway_startup.sh | 2 .local/bin/backup | 86 ---- .local/bin/bar_all_once | 6 .local/bin/bar_network | 2 .local/bin/bt | 27 - .local/bin/doasedit | 20 .local/bin/fd | 8 .local/bin/hostblock | 29 - .local/bin/luakit | 12 .local/bin/mntblk | 55 -- .local/bin/network_backup | 56 -- .local/bin/pass | 91 ---- .local/bin/photosArchive | 88 ---- .local/bin/photosJoin | 25 - .local/bin/rip | 8 .local/bin/run | 28 - .local/bin/shmoji | 65 --- .local/bin/subs | 16
diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 04a9eab9329b3e40fbf8a29be4ff1db735325b50..2eb8a8813ff3301b17244c3db4ee32f3b1b019c3 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -69,7 +69,3 @@ if [ (tty) = "/dev/tty1" ] && which sway >/dev/null 2>&1 posix_source ~/.config/sh/variables.wayland exec dbus-run-session -- sway end - -# todo function fish_prompt -# echo '' -# end diff --git a/.config/sh/aliases b/.config/sh/aliases index 4da7666404ed7c3a72a0c83af50b60f5e6ad6759..c3485b0688f7af87b221450f616b92c2a0752109 100644 --- a/.config/sh/aliases +++ b/.config/sh/aliases @@ -13,7 +13,7 @@ alias ag="ag -U" alias sshp='ssh -o PasswordAuthentication=yes -o PreferredAuthentications=keyboard-interactive,password -o PubkeyAuthentication=no' # doas -alias connmanctl="doas /usr/bin/connmanctl" +alias connmanctl="doas connmanctl" alias rfkill="doas /usr/sbin/rfkill" # alternatives diff --git a/.config/sh/functions b/.config/sh/functions index a21bef3d72c12eae7c2382c1c8f8b763e597a5ef..7eece8914d3092d3b4fdee0e4ed4cee0244badd6 100644 --- a/.config/sh/functions +++ b/.config/sh/functions @@ -23,200 +23,6 @@ fi done < /etc/apk/world } -# PS1> -abbreviate_aliases() { - # alias must not end with / ; must be sorted like exceptions—more specific (longer) first - aliases="$HOME/Music:;$HOME/Code:;$HOME/Desktop:;$HOME/Documents:;$HOME/Downloads:;$HOME/Pictures:;$HOME/Public:;$HOME/Templates:;$HOME/Videos:;$HOME:~" - - path="$PWD" - IFS=";"; for a in $aliases - do - aliasPath=$(echo "$a" | cut -d':' -f1) - aliasSymbol=$(echo "$a" | cut -d':' -f2) - if beginswith "$aliasPath" "$path" - then - path=$(echo "$path" | sed "s!$aliasPath!$aliasSymbol!") - break - fi - done - - if [ "$(echo "$path" | cut -c1)" = '/' ] - then - path="$path" - fi - echo "$path" -} - -makePS1() { - ex=$? - - bgBlack="$(tput setab 100)" - bgRed="$(tput setab 101)" - bgYellow="$(tput setab 103)" - bgGreen="$(tput setab 102)" - bgBrown="$(tput setab 107)" - bgBlue="$(tput setab 106)" - fgBlack="$(tput setaf 100)" - fgWhite="$(tput setaf 250)" - fgRed="$(tput setaf 101)" - fgBlue="$(tput setaf 106)" - fgYellow="$(tput setaf 103)" - fgGreen="$(tput setaf 102)" - fgBrown="$(tput setaf 107)" - clear="$(tput sgr0)" - - # todo if $(jobs -l | wc -l) -gt 1 -> print indicator - - if [ "$ex" -gt 0 ] - then - printf "\001%b%b\002 %s " "$bgRed" "$fgWhite" "$ex" - if [ -n "$VIRTUAL_ENV" ] - then - printf "\001%b%b\002\001%b\002" "$fgRed" "$bgBlue" "$clear" - else - printf "\001%b%b\002\001%b\002" "$fgRed" "$bgYellow" "$clear" - fi - fi - - if [ -n "$VIRTUAL_ENV" ] - then - venv="$(echo "$VIRTUAL_ENV" | sed 's!/.venv!!')" - printf "\001%b%b\002 %s \001%b%b\002\001%b\002" "$bgBlue" "$fgBlack" "${venv##*/}" "$fgBlue" "$bgYellow" "$clear" - fi - - path=$(abbreviate_aliases) - path=${path%/} - n=$(echo "$path" | sed -e 's![^/]!!g' | wc -c) - - i=0 - IFS='/'; for d in $path - do - # fixme grouping (left,right?) - if [ "$i" -lt $((n-1)) ] - then - if [ "$i" -le 2 ] || [ "$i" -ge $((n-2)) ] || [ "$i" -eq 3 -a "$n" -lt 6 ] - then - printf "\001%b%b\002 %s \001%b\002" "$bgYellow" "$fgBlack" "$d" "$clear" - elif [ "$i" -eq 3 ] && [ "$n" -ge 6 ] - then - printf "\001%b%b\002 … \001%b\002" "$bgYellow" "$fgBlack" "$clear" - fi - else - printf "\001%b%b\002 %s \001%b\002" "$bgYellow" "$fgBlack" "$d" "$clear" - fi - i=$((i+1)) - done - - if git rev-parse 2>/dev/null - then - branch=$(git branch | grep '\*' | cut -d' ' -f2) - bg=$bgGreen - fg=$fgBlack - arrow=$fgGreen - gitText=" $branch " - if git status | grep 'Your branch is behind' >/dev/null - then - gitText="$gitText" - fi - if git status | grep 'Untracked files' >/dev/null - then - gitText="$gitTextﱐ " - fi - if git status | grep 'Changes not staged for commit' >/dev/null - then - gitText="$gitText " - bg=$bgBrown - fg=$fgWhite - arrow=$fgBrown - fi - if git status | grep 'Changes to be committed' >/dev/null - then - gitText="$gitTextﱣ " - bg=$bgBrown - fg=$fgWhite - arrow=$fgBrown - fi - if git status | grep 'Your branch is ahead' >/dev/null - then - gitText="$gitTextﰖ " - fi - printf "\001%b%b\002\001%b\002" "$fgYellow" "$bg" "$clear" - printf "\001%b%b\002 %s\001%b\002" "$bg" "$fg" "$gitText" "$clear" - printf "\001%b%b\002\001%b\002" "$bgBlack" "$arrow" "$clear" - git_present=1 - else - git_present=0 - fi - - if hg branch >/dev/null 2>&1 - then - branch=$(hg branch) - bg=$bgGreen - fg=$fgBlack - arrow=$fgGreen - gitText=" $branch " - #if hg inc -l1 >/dev/null - #then - # gitText="$gitText" - #fi - if [ "$(hg status -u | wc -l)" -gt 0 ] - then - gitText="$gitTextﱐ " - fi - if [ "$(hg status -dram | wc -l)" -gt 0 ] - then - gitText="$gitText " - bg=$bgBrown - fg=$fgWhite - arrow=$fgBrown - fi - #if hg out -l1 >/dev/null - #then - # gitText="$gitTextﰖ " - #fi - printf "\001%b%b\b\002\001%b\002" "$fgYellow" "$bg" "$clear" - printf "\001%b%b\002 %s\001%b\002" "$bg" "$fg" "$gitText" "$clear" - printf "\001\b%b%b\002\001%b\002" "$bgBlack" "$arrow" "$clear" - hg_present=1 - else - hg_present=0 - fi - - if [ $git_present -eq 0 ] && [ $hg_present -eq 0 ] - then - printf "\001%b%b\002\001%b\002" "$bgBlack" "$fgYellow" "$clear" - fi - - if [ "$(whoami)" = "root" ] - then - printf "\001%b%b\002 # \001%b%b\002\001%b\002 " "$bgBlack" "$fgYellow" "$clear" "$fgBlack" "$clear" - else - printf "\001%b%b\002 \$ \001%b%b\002\001%b\002 " "$bgBlack" "$fgGreen" "$clear" "$fgBlack" "$clear" - fi -} -# <PS1 - -makePS2() { - bgBlack="$(tput setab 0)" - fgBlack="$(tput setaf 0)" - fgGreen="$(tput setaf 2)" - clear="$(tput sgr0)" - - printf "\001%b%b\002 … \001%b%b\002\001%b\002 " "$bgBlack" "$fgGreen" "$clear" "$fgBlack" "$clear" -} - -entry() { - date_full=$(date "+%Y-%m-%d") - date_short=$(date "+%b %d") - cd ~/Documents/Creatio/Diary/Current/ || exit 1 - if [ ! -f "$date_full.asciidoc" ] - then - printf "=== %s\n\n\n" "$date_short" > "$date_full.asciidoc" - fi - kak -e "kak-spell-enable en_GB" "$date_full.asciidoc" - cd - >/dev/null || exit 1 -} - _gen_fzf_default_opts() { color00='#28211c' color01='#36312e' @@ -248,53 +54,35 @@ "$1"*) true;; *) false;; esac; } endswith() { case $2 in *"$1") true;; *) false;; esac; } -screenshot() { - slurp | grim -g - - | cwebp -lossless -o "$HOME/Pictures/screen_$(date +%Y-%m-%dT%H:%M:%S).webp" -- - +screenshot_area() { + grimshot --notify save area - | cwebp -lossless -o "$HOME/Pictures/screen_$(date +%Y-%m-%dT%H:%M:%S).webp" -- - +} + +screenshot_this_window() { + grimshot --notify save active - | cwebp -lossless -o "$HOME/Pictures/screen_$(date +%Y-%m-%dT%H:%M:%S).webp" -- - +} + +screenshot_window() { + grimshot --notify save window - | cwebp -lossless -o "$HOME/Pictures/screen_$(date +%Y-%m-%dT%H:%M:%S).webp" -- - } screenshot_all() { - grim - | cwebp -lossless -o "$HOME/Pictures/screen_$(date +%Y-%m-%dT%H:%M:%S).webp" -- - + grimshot --notify save screen - | cwebp -lossless -o "$HOME/Pictures/screen_$(date +%Y-%m-%dT%H:%M:%S).webp" -- - } toggle_wifi() { - state=$(connmanctl technologies | grep wifi -A3 | grep Powered | cut -d '=' -f 2 |tr -d ' ') + state=$(doas connmanctl technologies | grep wifi -A3 | grep Powered | cut -d '=' -f 2 |tr -d ' ') if [ "$state" = 'False' ] then - . /tmp/dbus.sh - connmanctl enable wifi - doas sv restart connmand + doas connmanctl enable wifi + sleep 5 + doas /etc/init.d/connman restart else - connmanctl disable wifi + doas connmanctl disable wifi fi + bar_all_once } -# golint() { -# if [ $# -gt 0 ] -# then -# result=$(cat "$1") -# else -# result=$(golangci-lint run --out-format checkstyle) -# fi -# files=$(echo "$result" | xmllint --xpath '//file' - | tr '\n' '\t') -# IFS=$'\t'; for file in $(echo "$files") -# do -# filename=$(echo "$file" | xmllint --xpath 'string(//file/@name)' -) -# errors=$(echo "$file" | xmllint --xpath '//error' - | tr '\n' '\t') -# IFS=$'\t'; for error in $(echo "$errors") -# do -# line=$(echo "$error" | xmllint --xpath 'string(//error/@line)' -) -# column=$(echo "$error" | xmllint --xpath 'string(//error/@column)' -) -# message=$(echo "$error" | xmllint --xpath 'string(//error/@message)' -) -# kind=$(echo "$error" | xmllint --xpath 'string(//error/@severity)' -) -# echo "$filename:$line:$column: $kind: $message" -# done -# done -# } -# -#fd() { -# $EDITOR $(ag --nobreak --nonumbers --noheading . | fzf --delimiter=':' --nth=2.. | cut -d ':' -f 1) -#} - datediff() { d1=$(date -d "$1" +%s) d2=$(date -d "$2" +%s) @@ -322,23 +110,6 @@ alarm() { echo "notify-send -u critical -i appointment-soon 'Alarm' '$2'; ffplay ~adam/Music/mps/cloister.ogg" | at "$1" } -# guak() { -# if $(pgrep -fc guak) -lt 2 ] -# the -# alcritty --class guake & -# eco '1' > /tmp/guak -# ext -# fi -# if "$(cat /tmp/guak)" = '1' ] -# the -# swymsg '[app_id="guake"] move scratchpad' -# eco '0' > /tmp/guak -# els -# swymsg '[app_id="guake"] scratchpad show' -# eco '1' > /tmp/guak -# fi -# } - guakStart() { wezterm start --always-new-process >/dev/null 2>&1 & pid=$(jobs -p) @@ -498,17 +269,6 @@ # testme ffmpeg -i input.mp4 -c:a copy -c:v libsvtav1 -preset 10 -r 25 -threads 16 -crf 17 svtav1_test.mp4 ffmpeg -i "$1" -crf "$Q" -threads 16 -b:v 0 -c:v libaom-av1 -r 25 -strict experimental -tile-columns 2 -pix_fmt yuv420p "${1%%.*}.av1.webm" } -touchpad() { - ID=$(xinput list | grep -Eo 'TouchPad\s*id\=[0-9]{1,2}' | grep -Eo '[0-9]{1,2}') - State=$(xinput list-props "$ID" | grep 'Device Enabled' | awk '{print $4}') - if [ "$State" -eq 1 ] - then - xinput disable "$ID" - else - xinput enable "$ID" - fi -} - volume() { if command -v pactl >/dev/null 2>&1 then @@ -572,33 +332,515 @@ fi find "$dir" -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -n1 } -project() { - project_start=0 - i=1 - while read -r line +backup() { + set -ex + + if [ "$1" = 'mymlan' ] + then + if [ "$(id -u)" -eq 0 ] + then + printf "don’t run as root" + exit 1 + fi + rsync -rtP --delete /media/usb/adam/H500/Mårran/ /media/usb/adam/Mymlan/ + fi + + if [ "$1" = 'daily' ] + then + case "$(hostname)" in + mycroft) + if [ "$(id -nu)" != 'adam' ] + then + printf "run as adam" + exit 1 + fi + + name="backup_$(date '+%Y%m%dT%H%M')" + + [ -f /tmp/1000-runtime-dir/keybase/keybased.sock ] || keybase service >/dev/null 2>&1 & + doas modprobe fuse + [ -d /keybase/ ] || kbfsfuse >/dev/null 2>&1 & + while ! cd /keybase 2>/dev/null + do + sleep 2 + done + cd + + find /keybase/private/bquiet/backup/mycroft/ -type f -iname 'backup_*.tar' -mtime '+6' -exec rm {} \; + + # git-remotes in ~/Code/dwd + tar cf "/keybase/private/bquiet/backup/mycroft/${name}.tar" --exclude dwd ~/Code/ ~/Documents/ ~/Downloads/ ~/Pictures/ ~/Templates/ /etc/runlevels /etc/connman/ /etc/doas.conf /etc/udev /etc/udisks2/ /etc/sysctl.conf /etc/hostname /etc/apk/world + ;; + DeepThought) + if [ "$(id -nu)" != 'backup' ] + then + printf "run as backup" + exit 1 + fi + + set -x + date + name="backup_$(date '+%Y%m%dT%H%M')" + cmd="$1" + + infraFiles=$(doas -u infra /home/infra/backup "$cmd") + wwwFiles=$(doas -u www /var/www/backup "$cmd") + + if [ -z "$cmd" ] + then + find /keybase/private/bquiet/backup/deepthought/ -type f -iname 'backup_*.tar' -mtime '+6' -exec rm {} \; + + #shellcheck disable=SC2086 + tar -cPlf "/keybase/private/bquiet/backup/deepthought/${name}.tar" backup $infraFiles $wwwFiles + fi + ;; + esac + exit 0 + fi + + if [ "$(id -u)" -ne 0 ] + then + printf 'run as root' + exit 1 + fi + + case "$(hostname)" in + mycroft) + cd / + btrfs subvolume snapshot -r / "root_$(date '+%Y%m%d')" + btrfs send root_* | btrfs receive /media/usb/adam/H500/ + btrfs subvolume delete "root_$(date '+%Y%m%d')" + cd /home || exit 1 + btrfs subvolume snapshot -r /home/ "home_$(date '+%Y%m%d')" + btrfs send home_* | btrfs receive /media/usb/adam/H500/ + btrfs subvolume delete "home_$(date '+%Y%m%d')" + ;; + esac +} + +connected() { + if connmanctl services | grep -qE '(O|R) ' + then + return 0 + else + return 1 + fi +} + +shouldBackupNow() { + if [ ! -f ~/.cache/lastBackup ] + then + return 0 + fi + + now=$(date '+%s') + then=$(cat ~/.cache/lastBackup) + + test $((now - then)) -gt 86400 +} + +shouldPassNow() { + cd ~/Code/current/joeblack || return 1 + passLastDate=$(git log --date=unix | grep Date | tr -s ' ' |cut -d ' ' -f2- | head -n1) + cd ~/.local/share/eeze || return 1 + eezeLastDate=$(git log --date=unix | grep Date | tr -s ' ' |cut -d ' ' -f2- | head -n1) + test "$passLastDate" -lt "$eezeLastDate" +} + +network_backup() { + if connected + then + shouldPassNow && notify-send -i backup -u critical 'JoeBlack should be run' 'There are changes to passwords since last JoeBlack sync' + shouldBackupNow && ( + notify-send -i backup 'Running daily backup' + backup daily + notify-send -i backup 'Finished daily backup' + date '+%s' >~/.cache/lastBackup + ) + fi + + ip monitor address | while read -r _ do - if [ $project_start -eq 0 ] + if connected + then + shouldPassNow && notify-send -i backup -u critical 'JoeBlack should be run' 'There are changes to passwords since last JoeBlack sync' + shouldBackupNow && ( + notify-send -i backup 'Running daily backup' + backup daily + notify-send -i backup 'Finished daily backup' + date '+%s' >~/.cache/lastBackup + ) + fi + done +} + +bar_all_once() { + ~/.local/bin/bar_clock + ~/.local/bin/bar_battery -1 + ~/.local/bin/bar_network -1 + ~/.local/bin/bar_bluetooth +} + +bt() { + # TODO https://github.com/arkq/bluez-alsa/wiki/Using-BlueALSA-as-default-ALSA-PCM#automation + + trap bar_bluetooth INT + + if [ "$1" = 'on' ] + then + ( + ln -sf ~/.config/alsa/asoundrc-bluealsa ~/.config/alsa/asoundrc-default + #set -e + doas /usr/sbin/rfkill unblock bluetooth + sleep 1 + bluetoothctl power on || (sleep 2; bluetoothctl power on) + sleep 1 + bluetoothctl connect 9C:19:C2:95:5D:E1 + ) + elif [ "$1" = 'off' ] + then + bluetoothctl power off + ln -sf /dev/null ~/.config/alsa/asoundrc-default + else + bluetoothctl show | grep Powered | cut -f2 + bluetoothctl info | grep -E '(Alias|Connected)' | cut -f2 + fi + + bar_bluetooth +} + +fd() { + if [ "$(git rev-parse --show-toplevel 2>/dev/null)" = '/home/adam' ] + then + /usr/bin/fd -I "$@" + else + /usr/bin/fd "$@" + fi +} + +luakit() { + . ~/.config/sh/variables + + /usr/bin/luakit + cd ~/.local/share/luakit/ || exit 1 + sqlite3 cookies.db 'delete from moz_cookies;' + sqlite3 history.db 'delete from history;' + sqlite3 downloads.db 'delete from downloads;' + rm -rf ./local_storage/* + rm -rf ./indexeddb/* + echo '{{["command"]={2},},{},}' > ./command-history +} + +mntblk() { + set -e + + # shellcheck disable=SC2010 + disks=$(ls -l /dev/disk/by-uuid/ | grep -v dm | grep -v sda | cut -d '>' -f 2 | tail -n+2 | cut -d '/' -f 3) + labels=$(ls -l /dev/disk/by-label/) + + if [ -z "$disks" ] + then + echo "No disks attached" + exit + fi + + disk_labels=$(for disk in $disks + do + mountpoint=$(mount | grep "$disk" | cut -d ' ' -f 3- | rev | cut -d ' ' -f 4- | rev) + label=$(echo "$labels" | grep "$disk" | awk -F '->' '{print $1}' | tr -s ' ' | cut -d ' ' -f 9) + if [ -z "$label" ] then - if [ "$line" = "[$1]" ] + entry="$disk�$disk" + else + entry="$disk�$label" + fi + if [ "$mountpoint" ] + then + entry="$entry ($mountpoint)" + fi + echo "$entry" + done) + + result=$(echo "$disk_labels" | fzf -m -d '�' --with-nth 2) + if [ -z "$result" ] + then + exit + fi + + label=$(echo "$result" | awk -F '�' '{print $2}') + disk=$(echo "$result" | awk -F '�' '{print $1}') + path="/dev/$disk" + + if mount | grep -q "$path" + then + action='unmount' + else + action='mount' + fi + + udisksctl "$action" -b "$path" + + if [ "$action" = 'unmount' ] && ! [ "$1" = '-s' ] + then + echo "Ejecting $path" + doas eject "$path" + fi +} + +pass() { + export POSIXLY_CORRECT="true" + + case "$1" in + 'sync') + shift + force="" + TEMP=$(getopt -n 'pass sync' -o 'f' -- "$@") + if [ $? -ne 0 ] then - project_start=$i + echo 'error parsing args' + exit 1 fi - else - if [ "$(echo "$line" | cut -c1)" = '[' ] + eval set -- "$TEMP" + unset TEMP + while true + do + case "$1" in + '-f') + force='true' + shift + continue + ;; + '--') + shift + break + ;; + esac + done + + cd ~/.local/share/eeze/ || (echo 'no eeze data dir'; exit 1) + echo 'pulling changes' + git pull + if [ -n "$force" ] then - break + echo 'reindexing' + eeze -Ir fi - key="$(echo "$line" | cut -d'=' -f1)" - value="$(echo "$line" | cut -d'=' -f2)" - case $key in - "root") - eval PROJECT_ROOT="$value" - export PROJECT_ROOT - ;; - esac + echo 'pushing changes' + git push + cd ~/Code/current/joeblack || exit 0 + echo '# syncing Joe Black' + ./encode + git add payload + git commit -m "$(date '+%Y%m%dT%H%M')" + git push + ;; + 'new') + shift + opts_def='-sy' + num_def='20' + TEMP=$(getopt -n 'pass new' -o '01AaBcCNnHhsvy' -- "$@") + if [ $? -ne 0 ] + then + echo 'error parsing args' + exit 1 + fi + eval set -- "$TEMP" + unset TEMP + while true + do + case "$1" in + '--') + shift + break + ;; + *) + opts="$opts $1" + ;; + esac + done + num="$1" + + [ -z "$opts" ] && opts=$opts_def + [ -z "$num" ] && num=$num_def + + echo '# adding to store' + pwgen $opts "$num" 1 | eeze-add + + cd ~/Code/current/joeblack || exit 0 + echo '# syncing Joe Black' + ./encode + git add payload + git commit -m "$(date '+%Y%m%dT%H%M')" + git push + ;; + *) + echo 'pass (sync|new) [options]' + ;; + esac +} + +rip() { + cd-paranoia -Q 2>&1 | + grep "^ *[1-9]" | + sed -e 's/^ *\|\..*//g' | + while read -r t; do + cd-paranoia "$t" - | ffmpeg -i pipe: "rip_$t.flac"; + done +} + +run() { + result=$(for app in /usr/share/applications/*.desktop + do + name=$(grep -E '^Name=' "$app" | head -n1 | cut -d '=' -f 2) + commands=$(grep -E '^Name=|^Exec' "$app" | sed 's/ %.//' | cut -d '=' -f2- | awk '(NR-1)%2 == 0 { printf("%s%s", $0, "�") }; (NR-1)%2 == 1 { print }') + if [ -z "$commands" ] + then + continue fi - i=$((i+1)) - done < ~/.config/projects.toml - cd "$PROJECT_ROOT" || exit 1 - exec "$SHELL" + if [ "$(echo "$commands" | wc -l)" -gt 1 ] + then + echo "$commands" | while read -r comman + do + if [ "$(echo "$comman" | sed 's/�.*//')" = "$name" ] + then + echo "$comman" + else + echo "$name, $comman" + fi + done + else + echo "$commands" + fi + done | uniq | fzf -m -d '�' --with-nth 1) + + # shellcheck disable=SC2091 + $(echo "$result" | sed 's/.*�//') >/dev/null 2>&1 & +} + +ws() { + if stat "$HOME/Pictures/wallpapers/$(hostname)_w$1.webp" >/dev/null 2>&1 + then + wallpaper="$HOME/Pictures/wallpapers/$(hostname)_w$1.webp" + else + wallpaper="$HOME/Pictures/wallpapers/$(hostname).webp" + fi + + killall swaybg + swaybg -i "$wallpaper" -m fill >/dev/null 2>&1 & + #nanosleep 100000000 + swaymsg workspace "$1" +} + +photosArchive() { + IFS='' + + author="Adam Pioterek <photos@apiote.xyz>" + copyright="CC-BY-SA" + + while [ $# -gt 0 ] + do + if [ "$1" = "--author" ] + then + shift + author=$1 + fi + if [ "$1" = "--copyright" ] + then + shift + copyright=$1 + fi + if [ "$1" = "--no-exif" ] + then + noExif=true + fi + if [ "$1" = "--no-rename" ] + then + noRename=true + fi + shift + done + + if [ "$noRename" ] + then + printf "No renaming\n" + else + printf "Renaming\n" + rename '.JPG' '.jpg' ./*.JPG + exiv2 -F mv ./*.jpg + + rename '.MOV' '.mov' ./*.MOV + for film in ./*.mov + do + filmName=$(ffprobe -show_entries format_tags=creation_time "$film" 2>/dev/null | grep TAG: | cut -d '.' -f1 | sed 's/TAG:creation_time=//' | sed -E 's/(-|:)//g' | sed 's/T/_/') + mv "$film" "$filmName.mov" + done + fi + + if [ "$noExif" ] + then + printf 'No exif\n' + else + printf "Setting exif data: %s, %s\n" "$author" "$copyright" + exiv2 -M "set Exif.Image.Copyright $copyright" mo ./*.jpg + exiv2 -M "set Xmp.pdf.Author $author" mo ./*.jpg + exiv2 -dc ./*.jpg + fi + + printf "Orienting\n" + for x in ./*.jpg + do + convert -auto-orient "$x" "${x}_r" + done + + printf "Removing oriented\n" + for x in ./*_r + do + name=${x%_*} + mv "$x" "$name" + done + + printf "Encoding to webp\n" + for x in ./*.jpg + do + name=${x%.*} + cwebp "$x" -metadata all -o "${name}.webp" || (mv "$x" "$x.webp" && rm "${name}.webp") + done + + printf "Encoding to webm\n" + for x in `ls | grep mp4` + do + toAV1 $x + done + + printf "Checksum\n" + sha512sum ./*.webp ./*.webm ./*.mkv > .checksum + + printf "Zipping\n" + zip Result.zip ./*.webp ./*.webm ./*.mkv .checksum .description +} + +photosJoin() { + oldPath=$(pwd) + mkdir /tmp/photosOne /tmp/photosTwo + cp "$1" /tmp/photosOne + cp "$2" /tmp/photosTwo + cd /tmp/photosOne || exit 1 + unzip "$1" + rm "$1" + cd /tmp/photosTwo || exit 1 + unzip "$2" + rm "$2" + + mkdir /tmp/photosResult + cd /tmp/photosResult || exit 1 + cat /tmp/photosOne/.checksum /tmp/photosTwo/.checksum > .checksum + cat /tmp/photosOne/.description /tmp/photosTwo/.description > .description + rm /tmp/photosOne/.checksum /tmp/photosOne/.description + rm /tmp/photosTwo/.checksum /tmp/photosTwo/.description + mv /tmp/photosOne/* . + mv /tmp/photosTwo/* . + zip Result.zip ./*.webp ./*.webm ./*.mkv .checksum .description + cd "$oldPath" || exit 1 + mv /tmp/photosResult/Result.zip . + rm -rf /tmp/photosOne /tmp/photosTwo /tmp/photosResult } diff --git a/.config/sway/config b/.config/sway/config index 49b603761e2ed60b825ffb626b36fc3da87c4e15..fd883ec17a712e218bcb961c552ca9f3bd8e334c 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -46,16 +46,16 @@ bindsym $mod+Ctrl+t split v, layout tabbed; bindsym $mod+Ctrl+space floating toggle -bindsym $mod+exclam exec ~/.local/bin/workspace 1 -bindsym $mod+at exec ~/.local/bin/workspace 2 -bindsym $mod+numbersign exec ~/.local/bin/workspace 3 -bindsym $mod+dollar exec ~/.local/bin/workspace 4 -bindsym $mod+percent exec ~/.local/bin/workspace 5 -bindsym $mod+asciicircum exec ~/.local/bin/workspace 6 -bindsym $mod+ampersand exec ~/.local/bin/workspace 7 -bindsym $mod+asterisk exec ~/.local/bin/workspace 8 -bindsym $mod+parenleft exec ~/.local/bin/workspace 9 -bindsym $mod+parenright exec ~/.local/bin/workspace 10 +bindsym $mod+exclam exec sh -c '. ~/.config/sh/functions; ws 1' +bindsym $mod+at exec sh -c '. ~/.config/sh/functions; ws 2' +bindsym $mod+numbersign exec sh -c '. ~/.config/sh/functions; ws 3' +bindsym $mod+dollar exec sh -c '. ~/.config/sh/functions; ws 4' +bindsym $mod+percent exec sh -c '. ~/.config/sh/functions; ws 5' +bindsym $mod+asciicircum exec sh -c '. ~/.config/sh/functions; ws 6' +bindsym $mod+ampersand exec sh -c '. ~/.config/sh/functions; ws 7' +bindsym $mod+asterisk exec sh -c '. ~/.config/sh/functions; ws 8' +bindsym $mod+parenleft exec sh -c '. ~/.config/sh/functions; ws 9' +bindsym $mod+parenright exec sh -c '. ~/.config/sh/functions; ws 10' bindsym $mod+left workspace prev bindsym $mod+right workspace next @@ -72,7 +72,7 @@ bindsym $mod+Shift+parenleft move window to workspace 9 bindsym $mod+Shift+parenright move window to workspace 10 bindsym $mod+Ctrl+Return exec wezterm -bindsym $mod+f exec ~/.local/bin/luakit +bindsym $mod+f exec exec sh -c '. ~/.config/sh/functions; luakit' bindsym $mod+Shift+f exec qutebrowser bindsym $mod+e exec wezterm start -- ~/.local/bin/filemanager @@ -106,14 +106,15 @@ bindsym XF86WLAN exec sh -c '. ~/.config/sh/functions; toggle_wifi' bindsym $mod+F12 exec sh -c '. ~/.config/sh/functions; toggle_wifi' bindsym --locked XF86Launch3 exec sh -c '. ~/.config/sh/functions; backlight t' -bindsym --locked $mod+F11 exec sh -c '. ~/.config/sh/functions; backlight t' # todo bindsym XF86Display exec ~/Code/Scripts/changeDisplay # todo bindsym $mod+F4 exec ~/Code/Scripts/changeDisplay bindsym $mod+Ctrl+l exec swaylock -bindsym Print exec sh -c '. ~/.config/sh/functions; screenshot' -bindsym Ctrl+Print exec sh -c '. ~/.config/sh/functions; screenshot_all' +bindsym $mod+F11 exec sh -c '. ~/.config/sh/functions; screenshot_area' +bindsym Shift+F11 exec sh -c '. ~/.config/sh/functions; screenshot_this_window' +bindsym Ctrl+F11 exec sh -c '. ~/.config/sh/functions; screenshot_all' +bindsym Alt+F11 exec sh -c '. ~/.config/sh/functions; screenshot_window' default_border pixel 1 titlebar_border_thickness 0 diff --git a/.config/sway/sway_startup.sh b/.config/sway/sway_startup.sh index 2f6e9fc26b7f286ffb35fdf707cc496467158577..1c71b6a1111f9b6ec99193b4424d3a2176adf766 100755 --- a/.config/sway/sway_startup.sh +++ b/.config/sway/sway_startup.sh @@ -48,4 +48,4 @@ ~/.local/bin/bar_clock ~/.local/bin/bar_all_once -~/.local/bin/network_backup & +# network_backup & diff --git a/.local/bin/backup b/.local/bin/backup deleted file mode 100755 index c814b44fb09323e055154aac6ccda971d61402ba..0000000000000000000000000000000000000000 --- a/.local/bin/backup +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh - -set -e - - -if [ "$1" = 'mymlan' ] -then - if [ "$(id -u)" -eq 0 ] - then - printf "don’t run as root" - exit 1 - fi - rsync -rtP --delete /media/usb/adam/H500/Mårran/ /media/usb/adam/Mymlan/ -fi - -if [ "$1" = 'daily' ] -then - case "$(hostname)" in - Mycroft) - if [ "$(id -nu)" != 'adam' ] - then - printf "run as adam" - exit 1 - fi - - name="backup_$(date '+%Y%m%dT%H%M')" - - [ -f /run/user/1000/keybase/keybased.pid ] || keybase service >/dev/null 2>&1 & - [ -d /keybase/ ] || kbfsfuse >/dev/null 2>&1 & - while ! cd /keybase 2>/dev/null - do - sleep 2 - done - cd - - find /keybase/private/bquiet/backup/mycroft/ -type f -iname 'backup_*.tar' -mtime '+6' -exec rm {} \; - - # git-remotes in ~/Code/dwd - xbps-query -m >/tmp/world - tar cPlf "/keybase/private/bquiet/backup/mycroft/${name}.tar" --exclude dwd ~/Code/ ~/Documents/ ~/Downloads/ ~/Pictures/ ~/Templates/ /var/service/ /etc/sv/ /etc/connman/ /etc/doas.conf /etc/doh /etc/elogind/ /etc/fido_keys /etc/udev /etc/udisks2/ /etc/sysctl.conf /etc/hostname /tmp/world - ;; - DeepThought) - if [ "$(id -nu)" != 'backup' ] - then - printf "run as backup" - exit 1 - fi - - set -x - date - name="backup_$(date '+%Y%m%dT%H%M')" - cmd="$1" - - infraFiles=$(doas -u infra /home/infra/backup "$cmd") - wwwFiles=$(doas -u www /var/www/backup "$cmd") - - if [ -z "$cmd" ] - then - find /keybase/private/bquiet/backup/deepthought/ -type f -iname 'backup_*.tar' -mtime '+6' -exec rm {} \; - - #shellcheck disable=SC2086 - tar -cPlf "/keybase/private/bquiet/backup/deepthought/${name}.tar" backup $infraFiles $wwwFiles - fi - ;; - esac - exit 0 -fi - -if [ "$(id -u)" -ne 0 ] -then - printf 'run as root' - exit 1 -fi - -case "$(hostname)" in - Mycroft) - cd / - btrfs subvolume snapshot -r / "root_$(date '+%Y%m%d')" - btrfs send root_* | btrfs receive /media/usb/adam/H500/ - btrfs subvolume delete "root_$(date '+%Y%m%d')" - cd /home || exit 1 - btrfs subvolume snapshot -r /home/ "home_$(date '+%Y%m%d')" - btrfs send home_* | btrfs receive /media/usb/adam/H500/ - btrfs subvolume delete "home_$(date '+%Y%m%d')" - ;; -esac diff --git a/.local/bin/bar_all_once b/.local/bin/bar_all_once deleted file mode 100755 index a2bc4b84dbe8ff38790e9daa065b9b495b683821..0000000000000000000000000000000000000000 --- a/.local/bin/bar_all_once +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -~/.local/bin/bar_clock -~/.local/bin/bar_battery -1 -~/.local/bin/bar_network -1 -~/.local/bin/bar_bluetooth diff --git a/.local/bin/bar_network b/.local/bin/bar_network index e197ad2120614770145e2c8daedbf4388af7c0bf..f872781363239c10d601a1e2eaccbf0a3d246cdb 100755 --- a/.local/bin/bar_network +++ b/.local/bin/bar_network @@ -28,7 +28,7 @@ then exit fi -ip monitor address | while read -r _ +/sbin/ip monitor address | while read -r _ do printf "network|%s\n" "$(render)" >/tmp/swaybar/pipe done diff --git a/.local/bin/bt b/.local/bin/bt deleted file mode 100755 index 53233ae1a4c6ddbc74b2a250fd85318a4279273c..0000000000000000000000000000000000000000 --- a/.local/bin/bt +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# TODO https://github.com/arkq/bluez-alsa/wiki/Using-BlueALSA-as-default-ALSA-PCM#automation - -trap bar_bluetooth INT - -if [ "$1" = 'on' ] -then - ( - ln -sf ~/.config/alsa/asoundrc-bluealsa ~/.config/alsa/asoundrc-default - #set -e - doas /usr/sbin/rfkill unblock bluetooth - sleep 1 - bluetoothctl power on || (sleep 2; bluetoothctl power on) - sleep 1 - bluetoothctl connect 9C:19:C2:95:5D:E1 - ) -elif [ "$1" = 'off' ] -then - bluetoothctl power off - ln -sf /dev/null ~/.config/alsa/asoundrc-default -else - bluetoothctl show | grep Powered | cut -f2 - bluetoothctl info | grep -E '(Alias|Connected)' | cut -f2 -fi - -bar_bluetooth diff --git a/.local/bin/doasedit b/.local/bin/doasedit deleted file mode 100755 index d6807424b6f4939bb5e31882b0a4a18410283c1c..0000000000000000000000000000000000000000 --- a/.local/bin/doasedit +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -set -e - -EDITOR=${EDITOR:-kak} - -if [ "$(id -u)" -ne 0 ] -then - echo Must be run by root - exit 1 -fi - -cp /etc/doas.conf /tmp/doas.conf -doas "$EDITOR" /tmp/doas.conf -if doas -C /tmp/doas.conf -then - chown root:root /tmp/doas.conf - chmod 644 /tmp/doas.conf - mv /tmp/doas.conf /etc/doas.conf -fi diff --git a/.local/bin/fd b/.local/bin/fd deleted file mode 100755 index c0700492285afa102b80a9f129c39e17636afd8c..0000000000000000000000000000000000000000 --- a/.local/bin/fd +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if [ "$(git rev-parse --show-toplevel)" = '/home/adam' ] -then - /usr/bin/fd -I "$@" -else - /usr/bin/fd "$@" -fi diff --git a/.local/bin/hostblock b/.local/bin/hostblock deleted file mode 100755 index 55df7c0cc138180f294b44a933d95011af501a1b..0000000000000000000000000000000000000000 --- a/.local/bin/hostblock +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -blockers="steven_black;https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts amp;https://www.github.developerdan.com/hosts/lists/amp-hosts-extended.txt cares;https://someonewhocares.org/hosts/zero/hosts" - -if [ "$(hostname)" = "Marvin" ] -then - mount -o rw,remount / - prefix="/system" -else - prefix="" -fi - -mkdir -p /etc/hosts.d/ - -for blocker in $blockers -do - name=$(echo "$blocker" | cut -d';' -f1) - url=$(echo "$blocker" | cut -d';' -f2) - curl "$url" > "/etc/hosts.d/$name.dwd" -done - -echo "# THIS FILE IS GENERATED. EDIT /etc/hosts.d/*" > "$prefix/etc/hosts" -cat /etc/hosts.d/*.local | grep -Ev '^#' | sort -u >> "$prefix/etc/hosts" -cat /etc/hosts.d/*.dwd | grep -Ev '^#' | sort -u | grep '0.0.0.0' >> "$prefix/etc/hosts" - -if [ "$(hostname)" = "Marvin" ] -then - mount -o ro,remount / -fi diff --git a/.local/bin/luakit b/.local/bin/luakit deleted file mode 100755 index 762590a207ba23b55fd92cc4e5d5fbf7ae11dfc6..0000000000000000000000000000000000000000 --- a/.local/bin/luakit +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -. ~/.config/sh/variables - -/usr/bin/luakit -cd ~/.local/share/luakit/ || exit 1 -sqlite3 cookies.db 'delete from moz_cookies;' -sqlite3 history.db 'delete from history;' -sqlite3 downloads.db 'delete from downloads;' -rm -rf ./local_storage/* -rm -rf ./indexeddb/* -echo '{{["command"]={2},},{},}' > ./command-history diff --git a/.local/bin/mntblk b/.local/bin/mntblk deleted file mode 100755 index 7f7f1f8bb8744579786131926e41770ca99a8b1b..0000000000000000000000000000000000000000 --- a/.local/bin/mntblk +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -set -e - -# shellcheck disable=SC2010 -disks=$(ls -l /dev/disk/by-uuid/ | grep -v dm | grep -v sda | cut -d '>' -f 2 | tail -n+2 | cut -d '/' -f 3) -labels=$(ls -l /dev/disk/by-label/) - -if [ -z "$disks" ] -then - echo "No disks attached" - exit -fi - -disk_labels=$(for disk in $disks -do - mountpoint=$(mount | grep "$disk" | cut -d ' ' -f 3- | rev | cut -d ' ' -f 4- | rev) - label=$(echo "$labels" | grep "$disk" | awk -F '->' '{print $1}' | tr -s ' ' | cut -d ' ' -f 9) - if [ -z "$label" ] - then - entry="$disk�$disk" - else - entry="$disk�$label" - fi - if [ "$mountpoint" ] - then - entry="$entry ($mountpoint)" - fi - echo "$entry" -done) - -result=$(echo "$disk_labels" | fzf -m -d '�' --with-nth 2) -if [ -z "$result" ] -then - exit -fi - -label=$(echo "$result" | awk -F '�' '{print $2}') -disk=$(echo "$result" | awk -F '�' '{print $1}') -path="/dev/$disk" - -if mount | grep -q "$path" -then - action='unmount' -else - action='mount' -fi - -udisksctl "$action" -b "$path" - -if [ "$action" = 'unmount' ] && ! [ "$1" = '-s' ] -then - echo "Ejecting $path" - doas eject "$path" -fi diff --git a/.local/bin/network_backup b/.local/bin/network_backup deleted file mode 100755 index 9ca949ef9bffc1a198b7a1b700d19af45992f77f..0000000000000000000000000000000000000000 --- a/.local/bin/network_backup +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -connected() { - if connmanctl services | grep -qE '(O|R) ' - then - return 0 - else - return 1 - fi -} - -shouldBackupNow() { - if [ ! -f ~/.cache/lastBackup ] - then - return 0 - fi - - now=$(date '+%s') - then=$(cat ~/.cache/lastBackup) - - test $((now - then)) -gt 86400 -} - -shouldPassNow() { - cd ~/Code/current/joeblack || return 1 - passLastDate=$(git log --date=unix | grep Date | tr -s ' ' |cut -d ' ' -f2- | head -n1) - cd ~/.local/share/eeze || return 1 - eezeLastDate=$(git log --date=unix | grep Date | tr -s ' ' |cut -d ' ' -f2- | head -n1) - test "$passLastDate" -lt "$eezeLastDate" -} - -if connected -then - shouldPassNow && notify-send -i backup -u critical 'JoeBlack should be run' 'There are changes to passwords since last JoeBlack sync' - shouldBackupNow && ( - notify-send -i backup 'Running daily backup' - backup daily - notify-send -i backup 'Finished daily backup' - date '+%s' >~/.cache/lastBackup - ) -fi - - -ip monitor address | while read -r _ -do - if connected - then - shouldPassNow && notify-send -i backup -u critical 'JoeBlack should be run' 'There are changes to passwords since last JoeBlack sync' - shouldBackupNow && ( - notify-send -i backup 'Running daily backup' - backup daily - notify-send -i backup 'Finished daily backup' - date '+%s' >~/.cache/lastBackup - ) - fi -done diff --git a/.local/bin/pass b/.local/bin/pass deleted file mode 100755 index 8a96890ca628ab4df76a7faf88164f85de82d8ee..0000000000000000000000000000000000000000 --- a/.local/bin/pass +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -export POSIXLY_CORRECT="true" - -case "$1" in - 'sync') - shift - force="" - TEMP=$(getopt -n 'pass sync' -o 'f' -- "$@") - if [ $? -ne 0 ] - then - echo 'error parsing args' - exit 1 - fi - eval set -- "$TEMP" - unset TEMP - while true - do - case "$1" in - '-f') - force='true' - shift - continue - ;; - '--') - shift - break - ;; - esac - done - - cd ~/.local/share/eeze/ || (echo 'no eeze data dir'; exit 1) - echo 'pulling changes' - git pull - if [ -n "$force" ] - then - echo 'reindexing' - eeze -Ir - fi - echo 'pushing changes' - git push - cd ~/Code/current/joeblack || exit 0 - echo '# syncing Joe Black' - ./encode - git add payload - git commit -m "$(date '+%Y%m%dT%H%M')" - git push - ;; - 'new') - shift - opts_def='-sy' - num_def='20' - TEMP=$(getopt -n 'pass new' -o '01AaBcCNnHhsvy' -- "$@") - if [ $? -ne 0 ] - then - echo 'error parsing args' - exit 1 - fi - eval set -- "$TEMP" - unset TEMP - while true - do - case "$1" in - '--') - shift - break - ;; - *) - opts="$opts $1" - ;; - esac - done - num="$1" - - [ -z "$opts" ] && opts=$opts_def - [ -z "$num" ] && num=$num_def - - echo '# adding to store' - pwgen $opts "$num" 1 | eeze-add - - cd ~/Code/current/joeblack || exit 0 - echo '# syncing Joe Black' - ./encode - git add payload - git commit -m "$(date '+%Y%m%dT%H%M')" - git push - ;; - *) - echo 'pass (sync|new) [options]' - ;; -esac diff --git a/.local/bin/photosArchive b/.local/bin/photosArchive deleted file mode 100755 index dca2d7170582e31ae0ec4b4f2654f7b5766fbcb5..0000000000000000000000000000000000000000 --- a/.local/bin/photosArchive +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/sh - -IFS='' - -author="Adam Pioterek <photos@apiote.xyz>" -copyright="CC-BY-SA" - -while [ $# -gt 0 ] -do - if [ "$1" = "--author" ] - then - shift - author=$1 - fi - if [ "$1" = "--copyright" ] - then - shift - copyright=$1 - fi - if [ "$1" = "--no-exif" ] - then - noExif=true - fi - if [ "$1" = "--no-rename" ] - then - noRename=true - fi - shift -done - -if [ "$noRename" ] -then - printf "No renaming\n" -else - printf "Renaming\n" - rename '.JPG' '.jpg' ./*.JPG - exiv2 -F mv ./*.jpg - - rename '.MOV' '.mov' ./*.MOV - for film in ./*.mov - do - filmName=$(ffprobe -show_entries format_tags=creation_time "$film" 2>/dev/null | grep TAG: | cut -d '.' -f1 | sed 's/TAG:creation_time=//' | sed -E 's/(-|:)//g' | sed 's/T/_/') - mv "$film" "$filmName.mov" - done -fi - -if [ "$noExif" ] -then - printf 'No exif\n' -else - printf "Setting exif data: %s, %s\n" "$author" "$copyright" - exiv2 -M "set Exif.Image.Copyright $copyright" mo ./*.jpg - exiv2 -M "set Xmp.pdf.Author $author" mo ./*.jpg - exiv2 -dc ./*.jpg -fi - -printf "Orienting\n" -for x in ./*.jpg -do - convert -auto-orient "$x" "${x}_r" -done - -printf "Removing oriented\n" -for x in ./*_r -do - name=${x%_*} - mv "$x" "$name" -done - -printf "Encoding to webp\n" -for x in ./*.jpg -do - name=${x%.*} - cwebp "$x" -metadata all -o "${name}.webp" || (mv "$x" "$x.webp" && rm "${name}.webp") -done - -#printf "Encoding to webm\n" -#for x in `ls | grep mp4` -#do -# name=${x%.*} -# ffmpeg -i $x -b:v 10000k -c:a libopus -c:v libvpx-vp9 $name.webm -#done - -printf "Checksum\n" -sha512sum ./*.webp ./*.webm ./*.mkv > .checksum - -printf "Zipping\n" -zip Result.zip ./*.webp ./*.webm ./*.mkv .checksum .description diff --git a/.local/bin/photosJoin b/.local/bin/photosJoin deleted file mode 100755 index 1223c787a40a3f2200f751b2057c9d34d831ad7a..0000000000000000000000000000000000000000 --- a/.local/bin/photosJoin +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -oldPath=$(pwd) -mkdir /tmp/photosOne /tmp/photosTwo -cp "$1" /tmp/photosOne -cp "$2" /tmp/photosTwo -cd /tmp/photosOne || exit 1 -unzip "$1" -rm "$1" -cd /tmp/photosTwo || exit 1 -unzip "$2" -rm "$2" - -mkdir /tmp/photosResult -cd /tmp/photosResult || exit 1 -cat /tmp/photosOne/.checksum /tmp/photosTwo/.checksum > .checksum -cat /tmp/photosOne/.description /tmp/photosTwo/.description > .description -rm /tmp/photosOne/.checksum /tmp/photosOne/.description -rm /tmp/photosTwo/.checksum /tmp/photosTwo/.description -mv /tmp/photosOne/* . -mv /tmp/photosTwo/* . -zip Result.zip ./*.webp ./*.webm ./*.mkv .checksum .description -cd "$oldPath" || exit 1 -mv /tmp/photosResult/Result.zip . -rm -rf /tmp/photosOne /tmp/photosTwo /tmp/photosResult diff --git a/.local/bin/rip b/.local/bin/rip deleted file mode 100755 index 4b9d0858b91b4e4791d10505bde5e4d6364c05f3..0000000000000000000000000000000000000000 --- a/.local/bin/rip +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -cd-paranoia -Q 2>&1 | -grep "^ *[1-9]" | -sed -e 's/^ *\|\..*//g' | -while read -r t; do - cd-paranoia "$t" - | ffmpeg -i pipe: "rip_$t.flac"; -done diff --git a/.local/bin/run b/.local/bin/run deleted file mode 100755 index b7f3bc710bca38664a397734625a4a1c2ef3d3c8..0000000000000000000000000000000000000000 --- a/.local/bin/run +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -result=$(for app in /usr/share/applications/*.desktop -do - name=$(grep -E '^Name=' "$app" | head -n1 | cut -d '=' -f 2) - commands=$(grep -E '^Name=|^Exec' "$app" | sed 's/ %.//' | cut -d '=' -f2- | awk '(NR-1)%2 == 0 { printf("%s%s", $0, "�") }; (NR-1)%2 == 1 { print }') - if [ -z "$commands" ] - then - continue - fi - if [ "$(echo "$commands" | wc -l)" -gt 1 ] - then - echo "$commands" | while read -r comman - do - if [ "$(echo "$comman" | sed 's/�.*//')" = "$name" ] - then - echo "$comman" - else - echo "$name, $comman" - fi - done - else - echo "$commands" - fi -done | uniq | fzf -m -d '�' --with-nth 1) - -# shellcheck disable=SC2091 -$(echo "$result" | sed 's/.*�//') >/dev/null 2>&1 & diff --git a/.local/bin/shmoji b/.local/bin/shmoji deleted file mode 100755 index c66368152a7c692385019790ab2958b78be4ebda..0000000000000000000000000000000000000000 --- a/.local/bin/shmoji +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# -# https://github.com/biox/shmoji/blob/main/shmoji -# shell-based emoji picker -# -# deps by command: -# - shmoji download: curl -# - shmoji fzf: fzf -# - shmoji bemenu: bemenu & wtype -# - shmoji rofi: rofi & xdotool - -set -e - -cmd="$1" -emojidir="$HOME/.local/share/shmoji" -emojifile="$emojidir/emojis.txt" - -die() { - printf "%s\n" "$1" - exit 1 -} - -depends() { - for dep in "$@"; do - command -v "$dep" > /dev/null || die "$dep not found" - done -} - -emojicheck() { - [ -f "$emojifile" ] || die "emojis not found. try 'shmoji download'" -} - -case "$cmd" in - download) - depends curl - mkdir -p "$emojidir" - # $ wc -l /var/www/trash.j3s.sh/emojis.txt - # 3570 /var/www/trash.j3s.sh/emojis.txt - curl 'https://trash.j3s.sh/emojis.txt' >"$emojifile" - ;; - bemenu) - emojicheck - depends bemenu wtype - emoji=$(cat "$emojifile" | bemenu -c -W 0.2 -l 20) - printf "%s" "$emoji" | cut -d " " -f 1 | tr -d '\n' | wtype - - ;; - rofi) - emojicheck - depends rofi xdotool - win=$(xdotool getactivewindow) - emoji=$(cat "$emojifile" | rofi -dmenu | cut -d " " -f 1 | tr -d '\n') - [ "$emoji" ] && xdotool windowactivate --sync $win type --clearmodifiers $emoji - ;; - fzf) - emojicheck - depends fzf - emoji=$(cat "$emojifile" | fzf) - printf "%s" "$emoji" | cut -d " " -f 1 | tr -d '\n' - ;; - *) - printf "%s\n" "usage: shmoji [download | bemenu | rofi | fzf]" - ;; -esac - -exit 0 diff --git a/.local/bin/subs b/.local/bin/subs deleted file mode 100755 index c6fbeca88caab11584fff70f5742310703a32ddf..0000000000000000000000000000000000000000 --- a/.local/bin/subs +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - - -find . -maxdepth 1 -iname '*.avi' -o -iname '*.mp4' -o -iname '*.mkv' | while read -r f -do - ext=${f##*.} - subfile=$(echo "$f" | sed "s/$ext/srt/") - if [ -e "$subfile" ] - then - newfile=${f%.*} - printf "adding %s to %s; will create %s\n" "$f" "$subfile" "$newfile" - ffmpeg -nostdin -i "$f" -f srt -i "$subfile" -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt "${newfile}.sub.mkv" - else - printf "subtitle file %s does not exist\n" "$subfile" - fi -done