diff --git a/.local/bin/scripts/autolight b/.local/bin/scripts/autolight index 48bcb7e..196199b 100755 --- a/.local/bin/scripts/autolight +++ b/.local/bin/scripts/autolight @@ -2,6 +2,15 @@ # Automatically set screen brightness based on time of day. # OLD: value=$(expr 100 - $(expr 13 - $(date +%H) | tr -d -) \* 5) # S Function: echo "(c($(date +%H) / 4 - 3) + 1) * 50" | bc -l -value=$(echo "l=(100 - 1.5 * ( 11 - $(date +%H) ) ^ 2); if(l > 0) l else 3" | bc -l) -light -S $value -{ date && echo $value; } >>/var/log/autolight +# summertime: value=$(echo "l=(100 - 1.5 * ( 11 - $(date +%H) ) ^ 2); if(l > 0) l else 3" | bc -l) +value=$(echo "l=(100 - 3 * ( 12 - $(date +%H) ) ^ 2); if(l > 0) l else 3" | bc -l) +if test "$1" != "-n"; then + light -S $value + inputmodule-control led-matrix --brightness $(echo $value / 5 + 2 | bc) + if ! test -w /var/log/autolight + then + sudo chown :$(id -g) /var/log + sudo chmod g+w /var/log + fi +fi +printf "Set Light Level %4.1f at %s\n" "$value" "$(date)" | tee -a /var/log/autolight diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 07f4dc9..7c4e02a 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -43,10 +43,6 @@ fileinfo() { tput rmso size=$(stat --format=%s "$arg") - # Check if SSH key (<10KB then read) - if test "$size" -lt 10000 - then $elevate ssh-keygen -l -f "$arg" 2>/dev/null - fi # I think this check is here to avoid scrolling text interpreted as video #probe="$($elevate ffprobe "$arg" 2>&1)" #echo $probe | grep -v -e '00:00:00.04' -e 'ansi' && @@ -59,7 +55,12 @@ fileinfo() { ) - birth %.10w mod %.10y" "$arg" | numfmt --field=3 --to=iec-i --padding=6 --suffix=B fi done + # Check if SSH key (<10KB then read) + if test "${size:-99999}" -lt 10000 + then $elevate ssh-keygen -l -f "$arg" 2>/dev/null || true + fi tput sgr0 + pacman -Qo "$arg" 2>/dev/null || true } prefix=/tmp/b @@ -77,7 +78,7 @@ for arg; do fi # amount of items to display per line in a grid for two lines max grid=$(expr $(tput cols) / \( 25 - \( $# / 2 \) \& $# \< 30 \| 5 \)) - tmpfile="$prefix/$(basename -- "$arg")_$(dd "if=$arg" bs=512 count=10 2>/dev/null | md5sum | tr -d ' ' || true)" + tmpfile="$prefix/$(basename -- "$arg")_$(dd "if=$arg" bs=1M count=16 2>/dev/null | md5sum | cut -d ' ' -f1 || true)" mkdir -p "$prefix" case "$mime" in (*\ application/pdf) @@ -108,8 +109,13 @@ for arg; do ! $inspect && # TODO sometimes duration mismatch for short videos test $(printf "%.0f" $(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$arg")) -gt 3 && - mtn -q -i -t -W -r$(expr 5 - $# \& $# \< 4 \| 1) -D6 -b 0.6 -c $grid -w $(expr $(tput cols) '*' 20) \ - -O "$prefix" -o "$suffix" "$arg" && + { mtn -q -i -t \ + -D6 -b 0.6 \ + -r$(expr 5 - $# \& $# \< 4 \| 1) -c $grid -w $(expr $(tput cols) '*' 20) \ + -W -O "$prefix" -o "$suffix" "$arg" || + mtn -q -i -t \ + -W -O "$prefix" -o "$suffix" "$arg" + } && timg -W "$prefix/$(basename -- "${arg%.*}")$suffix" ;; (*\ image/*) @@ -154,7 +160,8 @@ for arg; do ;; (*:\ SQLite\ *\ database*) highlight "Tables" && sqlite3 "$arg" ".tables";; # TODO for few tables: SELECT * FROM db LIMIT 3; | cut -c-$col (*:\ data) ;; - (*\ key) bat+=("$arg");; + (*\ key) bat+=("$arg") + continue;; (*) bat+=("$arg") timga+=("$arg") continue @@ -245,15 +252,16 @@ if test "$ls" -o $# -le $(echo "$flags" | wc -w); then checkperm . # Alternative: find -exec ls -dl {} + { - # TODO handle single quotes in filenames - # TODO listing sometimes doubles as exa prints partial listings while working - timeout .6s sh -c " - if test '$tree' - then $elevate tree -a --dirsfirst --du -h -C -L 3 $flags -- $(printf "'%s' " "${ls[@]:-.}") + # Below issues are fixed by disabling timeout, maybe an alternative can be found to prevent hanging on huge dirs + # handle single quotes in filenames + # listing sometimes doubles as exa prints partial listings while working + #timeout .6s sh -c " + if test -n "$tree" + then $elevate tree -a --dirsfirst --du -h -C -L 3 $flags -- "${ls[@]:-.}" elif which exa 2>/dev/null >&2 - then $elevate exa --icons --color=always --long --group --classify --all --all --sort=modified --reverse $flags -- $(printf "'%s' " "${ls[@]:-.}") - else $elevate ls -l $(test $# -gt ${#ls[@]} && echo '-d') --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line-symlink-to-dir --all $flags -- $(printf "'%s' " "${ls[@]:-.}") + then $elevate exa --icons --color=always --long --group --classify --all --all --sort=modified --reverse $flags -- "${ls[@]:-.}" + else $elevate ls -l $(test $# -gt ${#ls[@]} && echo '-d') --color=always --human-readable --si --group-directories-first --file-type --dereference-command-line-symlink-to-dir --all $flags -- "${ls[@]:-.}" fi - " || $elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none $flags -- "${ls[@]:-.}" + #" || $elevate ls $(test $# -gt ${#ls[@]} && echo "-d") --color=always --human-readable --si --dereference-command-line --all --sort=none $flags -- "${ls[@]:-.}" } | $pager --quit-if-one-screen fi diff --git a/.local/bin/scripts/black b/.local/bin/scripts/black index 2de8590..8ed3c3a 100755 --- a/.local/bin/scripts/black +++ b/.local/bin/scripts/black @@ -1,5 +1,5 @@ #!/bin/sh -e -# Suspend screen until enter is pressed +# Suspend screen until enter is pressed or interrupted test "$1" && sleep $1 dpms() { if test $XDG_SESSION_TYPE = wayland @@ -9,5 +9,6 @@ dpms() { } dpms off trap 'dpms on' INT -sleep 99999 +sleep 3 +read _ dpms on diff --git a/.local/bin/scripts/contact b/.local/bin/scripts/contact new file mode 100755 index 0000000..8c1cded --- /dev/null +++ b/.local/bin/scripts/contact @@ -0,0 +1,23 @@ +#!/bin/sh -e +# Process raw contact data into a vcard and save it to nextcloud +echo "Finish input with Ctrl-D" >&2 +inputfile=/tmp/aichat-contact +cat >"$inputfile" + +while test "$accept" != "y" +do printf "\nProcessing...\n" >&2 + vcard="$(aichat --role carddav <"$inputfile")" + echo "$vcard" + printf "Accept? ([y]es/[n]o/[c]ancel) " >&2 + read -r accept + test "$accept" != "c" || exit $? +done +uid=$(echo "$vcard" | grep UID | grep --only-matching '[-0-9a-fx]\{36\}') +echo + +ncfields=$(pass show service/nextcloud) +ncfield() { + echo "$ncfields" | head -$1 | tail -1 +} +echo "$vcard" | curl -o /tmp/contact -w "HTTP Response Code from $(ncfield 3): %{http_code}\n" -u $(ncfield 2):$(ncfield 1) "$(ncfield 3)/remote.php/dav/addressbooks/users/$(ncfield 2)/${1:-contacts}/$uid.vcf" -X PUT -H 'Depth: 0' -H 'Content-Type: text/vcard; charset=utf-8;' -H 'DNT: 1' --data-binary @- +cat /tmp/contact diff --git a/.local/bin/scripts/disktest b/.local/bin/scripts/disktest index 3ef7477..9bb9ccf 100755 --- a/.local/bin/scripts/disktest +++ b/.local/bin/scripts/disktest @@ -22,8 +22,10 @@ then highlight "Write Test" test -s $tempfile || ( highlight "Preparing random bits:" && sudo dd status=progress if=/dev/urandom of=$tempfile bs=1M count=$count ) && + sha1sum $tempfile highlight "Copying random bits:" && sudo dd status=progress if=$tempfile of=.$count bs=1M count=$count + sha1sum .$count highlight "Copying zero bits:" && sudo dd status=progress if=/dev/zero of=.$count bs=1M count=$count sudo rm .$count diff --git a/.local/bin/scripts/downloads b/.local/bin/scripts/downloads index 9a699b9..258eb58 100755 --- a/.local/bin/scripts/downloads +++ b/.local/bin/scripts/downloads @@ -4,17 +4,19 @@ d5=$DATA/5-* dow=$d5/download # Internal Duplicates -rmlint --rank-by=Olam -o pretty -o sh:/tmp/dow.sh $dow/*.* +script1=/tmp/dedup-download_$(date +%s)_internal.sh +rmlint --rank-by=Olam -o pretty -o sh:$script1 $dow/*.* printf "Enter to confirm, any text to skip (answer does not matter if nothing is printed above this). " read -r answer -test -n "$answer" || /tmp/dow.sh -d +test -n "$answer" || $script1 -d # Songs mv -v -- $dow/*.mp3 $dow/*.flac $dow/*.wav $MUSIC/ mv -v -- $dow/*.iso $DATA/4-*/flash/ # Data-dir duplicates -rmlint --keep-all-tagged --max-depth=5 --rank-by=Odlam -o pretty -o sh:/tmp/dow.sh $d5 // $DATA/1-* $DATA/2-* $DATA/3-* $DATA/4-* +script2=/tmp/dedup-download_$(date +%s)_data.sh +rmlint --keep-all-tagged --max-depth=5 --rank-by=Odlam -o pretty -o sh:$script2 $d5 // $DATA/1-* $DATA/2-* $DATA/3-* $DATA/4-* printf "Enter to confirm, any text to skip (answer does not matter if nothing is printed above this). " read -r answer -test -n "$answer" || /tmp/dow.sh -d +test -n "$answer" || $script2 -d diff --git a/.local/bin/scripts/ecled b/.local/bin/scripts/ecled new file mode 100755 index 0000000..07dd8f6 --- /dev/null +++ b/.local/bin/scripts/ecled @@ -0,0 +1,12 @@ +#!/bin/sh -e +# Make controlling framework leds from framework more accessible +case $# in +(0) + for led in $(sudo ectool led '' query 2>&1 | tail -1 | cut -d: -f2) + do + highlight $led + sudo ectool led $led query + done;; +(1) sudo ectool led "$@" query;; +(*) sudo ectool led "$@";; +esac diff --git a/.local/bin/scripts/edit-config b/.local/bin/scripts/edit-config index 58c3063..1d48fcf 100755 --- a/.local/bin/scripts/edit-config +++ b/.local/bin/scripts/edit-config @@ -10,7 +10,7 @@ listconf() { find "${XDG_CONFIG_HOME:-$HOME/.config}" /etc /var/lib/postgres /var/lib/pleroma/static/instance \ -maxdepth 4 -follow \ \( -name Partitions -o -name mdn -o -name .git -o -name .local -o -name plugged \) -prune -o \ - ! \( -iname "*.markdown" -o -iname "*.md" -o -name "Network Persistent State" -o -iname "*.pem" \) -a \ + ! \( -iname "*.markdown" -o -name "Network Persistent State" -o -iname "*.pem" \) -a \ -type f -readable -exec grep -lI '' {} + 2>/dev/null } | dedup-lines } diff --git a/.local/bin/scripts/ffmeta b/.local/bin/scripts/ffmeta index 673606c..dddb62a 100755 --- a/.local/bin/scripts/ffmeta +++ b/.local/bin/scripts/ffmeta @@ -1,5 +1,5 @@ #!/bin/sh -# View song metadata using ffprobe +# View media metadata using ffprobe # Accepts filenames from args or stdin (one file per line) # TODO only print header when interactive if test "$#" -eq 0 @@ -7,5 +7,7 @@ then cat else printf '%s\n' "$@" fi | while read f; do highlight "$f" - find "$f" -type f -exec ffprobe -loglevel 20 -print_format default=noprint_wrappers=1 -show_format -pretty {} \; + find "$f" -type f -exec ffprobe -hide_banner \ + -loglevel $(expr 34 - $#) -print_format default=noprint_wrappers=1 -show_format -pretty {} \; + # loglevel: from 32 shows stream details (steps of 8), so only for small groups done | less diff --git a/.local/bin/scripts/fw-clock b/.local/bin/scripts/fw-clock new file mode 100755 index 0000000..ef399a9 --- /dev/null +++ b/.local/bin/scripts/fw-clock @@ -0,0 +1,8 @@ +#!/bin/sh -e +# Creates a breathing clock in a tmux session (9-16) +# or fixed brightness +tmux new-session -d -s ledmatrix \; \ + send-keys 'retry inputmodule-control led-matrix --clock' C-m \; \ + split-window -v \; \ + send-keys "while test $(expr 12 - $(date +%H) | tr -d -) -lt 4; do inputmodule-control led-matrix --breathing; done + autolight" C-m diff --git a/.local/bin/scripts/gol b/.local/bin/scripts/gol new file mode 100755 index 0000000..62e1010 --- /dev/null +++ b/.local/bin/scripts/gol @@ -0,0 +1,58 @@ +#!/bin/bash -e +# Run Game of Life on the Framework 16 matrix with the given input string +CFG="${XDG_CONFIG_HOME}/fwledmatrix/combos" +mkdir -p "$(dirname "$CFG")" + +alphabet=({A..Z} = + '!' '.' ':') # - +case "$1" in +(--iter) + # Iterate over all combinations + for l1 in "${alphabet[@]}" ""; do + for l2 in "${alphabet[@]}" ""; do + for l3 in "${alphabet[@]}" ""; do + for l4 in "${alphabet[@]}" ""; do + for l5 in "${alphabet[@]}" ""; do + combination="${l1}${l2}${l3}${l4}${l5}" + echo "$combination" + gol "$combination" + done + done + done + done + done + ;; +(--random) + # Function to generate a random combination + generate_random_combination() { + local combination="" + for _ in {1..5}; do + # Select a random letter from the alphabet + random_letter=${alphabet[$RANDOM % ${#alphabet[@]}]} + combination+="$random_letter" + done + echo "$combination" + } + while true + do gol "$(generate_random_combination)" + done + ;; +(""|--known) + while true + do gol "$(shuf -n 1 "$CFG")" + done + ;; +(*) + inputmodule-control led-matrix --stop-game + string="$(echo "$@" | tr 'a-z' 'A-Z')" + echo "Running '$string'" + inputmodule-control led-matrix --string "$string" + sleep 1 + inputmodule-control led-matrix --start-game game-of-life --game-param current-matrix + while ! read -r -t 30 game_continue + do inputmodule-control led-matrix --sleeping false + done + if test -n "$game_continue" + then echo "$string" >>"$CFG" + fi + ;; +esac diff --git a/.local/bin/scripts/help b/.local/bin/scripts/help index b0d1532..cef6965 100755 --- a/.local/bin/scripts/help +++ b/.local/bin/scripts/help @@ -26,7 +26,7 @@ showinfo() { cmd="$1" case "$cmd" in - (fwupdmgr|hunt|rdoc|gh|chordpro|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff|qpdf|ninja|qobuz-dl|beet) + (fwupdmgr|hunt|rdoc|gh|chordpro|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff|qpdf|ninja|qobuz-dl|beet|flux) unbuffer "$@" --help | sed 's|^[^ ].*:|\0|' | $paginate;; (sqlcmd) sqlcmd -?;; (exa) "$0" eza;; diff --git a/.local/bin/scripts/jrnl-tag b/.local/bin/scripts/jrnl-tag index 88e0487..a1c1bd8 100755 --- a/.local/bin/scripts/jrnl-tag +++ b/.local/bin/scripts/jrnl-tag @@ -5,8 +5,8 @@ if test $# -eq 0 then set -x $0 sleep uni nap cry tech read dev phone bike tour laptop computer piano faith health lens Zinc \ - girl CB Claudia Kerstin Turi Taura \ - Erlangen Bayreuth Berlin ICF + girl CB Claudia Turi Taura \ + Erlangen Bayreuth Berlin true $? else for arg diff --git a/.local/bin/scripts/moul b/.local/bin/scripts/moul index 538d16c..17a3e3d 100755 --- a/.local/bin/scripts/moul +++ b/.local/bin/scripts/moul @@ -14,15 +14,22 @@ case $1 in #done & # TODO handle labels with spaces lsblk --list --noheadings --output name,label,fstype,mountpoint | grep -v LUKS | grep -v '/' | grep ".\+ [^ ]\+"; + awk '$1 !~ /^#/ && NF>=2 {print $2}' /etc/fstab | while read fstab_mount; do + if ! grep -qs " $fstab_mount " /proc/mounts; then + echo "$fstab_mount" + fi + done; } | fzf --exit-0 | sed "s/^\([^ ]\+ \+\)\?\([^ ]\+\) \+[^ ]\+ *$/\2/" );; (--help) echo "$_help" && exit 0;; (-u) shift for last; do true; done sudo umount --verbose "$@" - code=$? - sudo rm -df "$last" - exit $code;; + exit $? + #code=$? + #sudo rm -df "$last" + #exit $code + ;; (*) arg=$1 shift;; esac @@ -39,13 +46,13 @@ then loopdevice="$(sudo losetup -f)" fi # FSTAB: BY LABEL -if grep --word-regexp "LABEL=$arg" /etc/fstab +if grep --word-regexp "^LABEL=$arg" /etc/fstab then # have to mount twice as the first one might be creating the directory mount -L "$arg" "$@" 2>/dev/null || mount -L "$arg" "$@" exit $? fi -# FSTAB: BY MOUNTPOINT/NAME -if grep --word-regexp "$arg" /etc/fstab +# FSTAB: BY MOUNTPOINT/NAME - does not find by UUID +if sudo findmnt --fstab | grep --word-regexp "$arg" then mount "$arg" "$@"; exit $? fi diff --git a/.local/bin/scripts/mpq b/.local/bin/scripts/mpq index f225e56..4140543 100755 --- a/.local/bin/scripts/mpq +++ b/.local/bin/scripts/mpq @@ -1,5 +1,8 @@ #!/bin/sh -e # Add file to mpd queue +if test $# -eq 0 +then mpc --format "%album% %track% > %artist% - %title% (%genre% aus %date%)" current +fi for arg do fullpath=$(realpath "$arg") mpc insert "${fullpath/$MUSIC\//}" diff --git a/.local/bin/scripts/compress b/.local/bin/scripts/pack similarity index 100% rename from .local/bin/scripts/compress rename to .local/bin/scripts/pack diff --git a/.local/bin/scripts/pl b/.local/bin/scripts/pl index c3329e3..314178f 100755 --- a/.local/bin/scripts/pl +++ b/.local/bin/scripts/pl @@ -5,6 +5,7 @@ test $# -gt 0 && command=$1 && shift test "$1" = '-v' && verbose='true' && shift || verbose='false' ! test -d "$MUSIC" && echo "No music directory!" && exit 1 +playlists="$MUSIC/playlists" case $command in (update) for pl; do @@ -19,7 +20,18 @@ case $command in done | tee $pl echo "Backup of $pl saved to $bak" >&2 done;; - (edit) ${EDITOR:-nano} $(find $MUSIC/Playlists -iname "$1\.*" | grep . || find $MUSIC/Playlists -iname "$1*");; + (edit) ${EDITOR:-nano} $(find "$playlists" -iname "$1\.*" | grep . || find "$playlists" -iname "$1*");; + (add) # Add current mpc song or given songs to playlist + pl=$1 + shift + playlist="$playlists/$pl"* + test -e "$playlist" || { playlist="$playlists/$pl.m3u8" && touch "$playlist"; } + if test $# -gt 0 + then realpath --relative-to $playlists "$@" + else mpc current -f "../%file%" + fi | tee -a $playlist + echo "...added to $playlist" + ;; (make) if test $1 = d then shift && i=1; while test $i -le ${1:-9}; do $0 make "${2:-Ω}$i" "empty$i"; ((i++)); done diff --git a/.local/bin/scripts/rd b/.local/bin/scripts/rd index 021b116..0ddab18 100755 --- a/.local/bin/scripts/rd +++ b/.local/bin/scripts/rd @@ -1,6 +1,8 @@ #!/bin/sh -e # Remove recursively safely case "$1" in ([0-9]) depth=$1; shift;; esac +if test "$1" == "--"; then shift; fi + for f in "${@:-$PWD}" do test -w "$(dirname "$f")" && elevate="" || elevate=sudo @@ -15,7 +17,7 @@ do fi # Clean empty files - $elevate find -name '.thumbnails' -printf 'Pre-cleaning %p\n' -exec rm -r {} + + $elevate find "$f" -name '.thumbnails' -printf 'Pre-cleaning %p\n' -exec rm -r {} + $elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) \ \( -name '.stfolder' -o -name '.*keep' -o -name '*.py' -o -name 'nodelay.txt' -o -name '.git' -o -name 'tmp' -o -name '.nomedia' -o -name '__init__.py' -o -name '*ignore' -o -name 'instalee' \) \ \( -type d -o -type f \) -prune -o -empty -printf 'Removing empty %p\n' -exec rm -d {} + diff --git a/.local/bin/scripts/rgain b/.local/bin/scripts/rgain index 9bcafb3..1b1651e 100755 --- a/.local/bin/scripts/rgain +++ b/.local/bin/scripts/rgain @@ -1,7 +1,6 @@ -#!/bin/sh +#!/bin/sh -e # Recursively add replaygain to the given files or from the current directory -#rsgain custom --album --skip-existing --tagmode=i "${@:-${MUSIC:-.}}" -beet replaygain -a -t 4 -w || - r128gain $(test -f "$1" || echo '--recursive') --skip-tagged --preserve-times 1 "${@:-.}" +nice -n 8 rsgain easy --skip-existing --multithread=${SPARE_CORES:-3} "${@:-.}" +#test $# -eq 0 && nice -n 8 beet replaygain --album --threads=${SPARE_CORES:-3} --write "$@" # Need a find command, call for each album -# rsgain easy --skip-existing --multithread=${SPARE_CORES:-3} "${@:-.}" +#rsgain custom --album --skip-existing --tagmode=i "${@:-${MUSIC:-.}}" diff --git a/.local/bin/scripts/s b/.local/bin/scripts/s index 5a194b4..d4e6116 100755 --- a/.local/bin/scripts/s +++ b/.local/bin/scripts/s @@ -4,6 +4,7 @@ export chars=$(expr $(tput cols) - 60) case "$1" in (+*) size=${1#+}G; depth=2; shift;; esac case "$1" in ([0-9]) depth=$1; shift;; esac -(du --max-depth "${depth:-1}" -xhat ${size:-50M} "$@" | sort -h | grep -v "^0") | +du="du --max-depth '${depth:-1}' -xha" +($du -t ${size:-50M} "$@" | sort -h | grep -v "^0") | while read line; do echo "$(tput smso)$line$(tput rmso) $(pacman -Qqo $(echo $line | awk '{print $2}') 2>/dev/null | paste -s -d',' | sed "s/\(.\{${chars}\}\).*/\1.../")"; done || #| column -t || - (du --max-depth "${depth:-1}" -xha "$@" | sort -h | tail) + ($du "$@" | sort -h | tail) diff --git a/.local/bin/scripts/save b/.local/bin/scripts/save index e15c5e7..e2c8b1f 100755 --- a/.local/bin/scripts/save +++ b/.local/bin/scripts/save @@ -1,5 +1,7 @@ #!/bin/sh -e # Put system to sleep after specified number of seconds +# If used in a pipe, put a command into /tmp/save to override mpc pause || mpdr $(which timer || sleep) "${@:-30}" -systemctl suspend +# TODO delay in case I happen to still be on PC - use idle? +$(cat /tmp/save 2>/dev/null) || systemctl suspend diff --git a/.local/bin/scripts/swayscale b/.local/bin/scripts/swayscale index 4dfac92..d606ee6 100755 --- a/.local/bin/scripts/swayscale +++ b/.local/bin/scripts/swayscale @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -ex # Force Sway Scaling shift=1 scale=1 diff --git a/.local/bin/scripts/sy b/.local/bin/scripts/sy index 7d96bc2..9cb319b 100755 --- a/.local/bin/scripts/sy +++ b/.local/bin/scripts/sy @@ -10,8 +10,8 @@ case "$1" in sudo mkdir -p /etc/yadm sudo chown -R $USER /etc/yadm sysyadm clone -w / gitea@git.jfischer.org:xeruf/etc.git --bootstrap;; - (init) sudo -E sysyadm init -b main -w /;; - (*) sudo -E sysyadm "$@";; + (init) sudo "$(which sysyadm)" init -b main -w /;; + (*) sudo --preserve-env=PATH,XDG_CONFIG_HOME "$(which sysyadm)" "$@";; esac #sudo chmod +rw /tmp/git -R 2>/dev/null sudo chown -R $USER /etc/yadm diff --git a/.local/bin/scripts/vnctype b/.local/bin/scripts/vnctype index 1c254bd..86101aa 100755 --- a/.local/bin/scripts/vnctype +++ b/.local/bin/scripts/vnctype @@ -1,5 +1,5 @@ #!/bin/sh -e -# Type in NoVNC - from clipboard or interactively with german layout +# Type in NoVNC with X tools - from clipboard or interactively with german layout xdotool search --onlyvisible --classname Navigator windowactivate # Activate Firefox if test $# -gt 0 then diff --git a/.local/bin/scripts/void b/.local/bin/scripts/void index 20a992e..8da765a 100755 --- a/.local/bin/scripts/void +++ b/.local/bin/scripts/void @@ -1,7 +1,8 @@ #!/bin/sh -temp=$(mktemp) +#temp=$(mktemp) target=$(pass app/voidcat) for arg; do +extension=$(echo "$arg" | sed 's/.*\.//') echo "Uploading $arg" { curl --progress-bar -X POST \ -H "V-Content-Type: $(file --mime-type -b $1)" \ @@ -9,6 +10,6 @@ echo "Uploading $arg" -H "V-Filename: $arg" \ -H "Authorization: Bearer $(echo "$target" | head -1)" \ --data-binary @$arg \ - $(echo "$target" | tail -1); echo; } | tee -a $temp + $(echo "$target" | tail -1); echo; } | sed "s/\$/.$extension/" done -test $# -gt 1 && echo && cat $temp | sed 's|http:|https:|' +#test $# -gt 1 && echo && #sed 's|http:|https:|' "$temp" diff --git a/.local/bin/scripts/wl-save b/.local/bin/scripts/wl-save index 4ac0ecd..424ec09 100755 --- a/.local/bin/scripts/wl-save +++ b/.local/bin/scripts/wl-save @@ -1,5 +1,5 @@ #!/bin/sh -e # Save wl clipboard image with last copied url -file="$(date +%y%m%d-%H%M%S)_$(cliphist list | grep https:// | head -1 | rev | cut -d/ -f1 | rev).png" +file="$(date +%y%m%d-%H%M%S)_$(cliphist list | grep --max-count 1 https:// | sed 's|/$||' | rev | cut -d/ -f1 | rev).png" wl-paste >"$file" b "$file"