From b23515c42408174ca27b5cbc5130c090a86ca1bc Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Wed, 21 Apr 2021 19:51:56 +0200 Subject: [PATCH] bin: slight script adjustments --- .config/shell/functions | 10 +++++++--- .local/bin/scripts/arg-test | 1 + .local/bin/scripts/update-keyboard-layout | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.config/shell/functions b/.config/shell/functions index 823da02..a57e564 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -358,7 +358,7 @@ clean() { highlight "m to clean mac-files" if [[ $1 =~ "m" ]]; then find -iname '.spotlight*' -print -exec rm -r {} \; - find -name "*.DS_Store" -delete + find -name '*.DS_Store' -delete fi if test "$BASH_VERSION"; then @@ -380,12 +380,16 @@ clean() { export aptclean_last=$aptclean_cur fi - which yay &>/dev/null && yay -Sc highlight "e to delete empty folders" [[ $1 =~ "e" ]] && find -empty -type d -delete -print - nix-collect-garbage + highlight "o to optimize extensively" + if [[ $1 =~ "o" ]]; then + which yay &>/dev/null && yay -Sc + nix-collect-garbage -d + nix-store --optimize + fi } function zipdiff() { diff --git a/.local/bin/scripts/arg-test b/.local/bin/scripts/arg-test index 7952743..2dab8b3 100755 --- a/.local/bin/scripts/arg-test +++ b/.local/bin/scripts/arg-test @@ -2,3 +2,4 @@ echo "Args: $@" echo "Number of args: $#" echo "${@:-default}" | sed 's/\(\w\+\)/\1+sed/g' +echo "Last arg: ${@:$#}" diff --git a/.local/bin/scripts/update-keyboard-layout b/.local/bin/scripts/update-keyboard-layout index fa27d93..fcdc640 100755 --- a/.local/bin/scripts/update-keyboard-layout +++ b/.local/bin/scripts/update-keyboard-layout @@ -1,13 +1,13 @@ #!/bin/sh { case $ACTION in - add) id=1;; - remove) id=0;; - *) id=$(test -c /dev/ttyACM0 && echo 1 || echo 0);; + (add) id=1;; + (remove) id=0;; + (*) id=$(test -c /dev/ttyACM0 && echo 1 || echo 0);; esac echo "Keyboard layout update to $id($ACTION) at $(date)" >>/tmp/scripts.log export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0 -# setxkbmap "$id" #nodeadkeys + xkbstate="$(dirname $(dirname $0))/xkblayout-state" test "$($xkbstate print %C)" -gt 1 && $xkbstate set $id # Swap semicolon and colon - https://unix.stackexchange.com/questions/615799/swap-semicolon-colon-to-p-unexpected-cause-semicolon-colon-affected-by-cpas-lock