added: scripts from @zethra's configs, and tidied flake structure lili bit
This commit is contained in:
parent
b0a649e560
commit
9a3fbee8bb
25 changed files with 230 additions and 0 deletions
|
|
@ -14,6 +14,7 @@
|
||||||
./kitty.nix
|
./kitty.nix
|
||||||
# ./starship.nix
|
# ./starship.nix
|
||||||
./neofetch.nix
|
./neofetch.nix
|
||||||
|
./scripts/anotherhadi
|
||||||
# ./qutebrowser
|
# ./qutebrowser
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
49
home/scripts/zethra/combine-pfps
Executable file
49
home/scripts/zethra/combine-pfps
Executable file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#This script will merge two images into one using imageMagick.
|
||||||
|
#The final result will be a picture that is split diagonally.
|
||||||
|
#The diagonal line will start from the bottom left of the image.
|
||||||
|
#Both pictures must be of the same size.
|
||||||
|
#If you do not give the filenames as part of the command line, the default names will be used (Left.jpg and Right.jpg).
|
||||||
|
|
||||||
|
#If command line argument 1 is not provided, the value will default to the variable $LEFT_DEFAULT
|
||||||
|
LEFT_DEFAULT="Left.jpg";
|
||||||
|
LEFT=${1:-$LEFT_DEFAULT};
|
||||||
|
|
||||||
|
#If command line argument 2 is not provided, the value will default to the variable $Right_DEFAULT
|
||||||
|
RIGHT_DEFAULT="Right.jpg";
|
||||||
|
RIGHT=${2:-$RIGHT_DEFAULT};
|
||||||
|
|
||||||
|
#The intermediate images we will use must be png to support transparency.
|
||||||
|
#We remove the extension '.jpg' from the filenames and add the extension '.png'.
|
||||||
|
LEFT_NORM="${LEFT%.jpg}.norm.png"
|
||||||
|
RIGHT_NORM="${RIGHT%.jpg}.norm.png"
|
||||||
|
LEFT_OUT="${LEFT%.jpg}.Diagonal Up - Mask.png";
|
||||||
|
RIGHT_OUT="${RIGHT%.jpg}.Diagonal Up - Mask.png";
|
||||||
|
OUT="combined.png";
|
||||||
|
|
||||||
|
# #Read the width and height of one of the images
|
||||||
|
WIDTH_LEFT=$(identify -format %w "$LEFT");
|
||||||
|
HEIGHT_LEFT=$(identify -format %h "$LEFT");
|
||||||
|
WIDTH_RIGHT=$(identify -format %w "$RIGHT");
|
||||||
|
HEIGHT_RIGHT=$(identify -format %h "$RIGHT");
|
||||||
|
|
||||||
|
# Find the smallest width and height of both images
|
||||||
|
WIDTH=$((WIDTH_LEFT < WIDTH_RIGHT ? WIDTH_LEFT : WIDTH_RIGHT))
|
||||||
|
HEIGHT=$((HEIGHT_LEFT < HEIGHT_RIGHT ? HEIGHT_LEFT : HEIGHT_RIGHT))
|
||||||
|
|
||||||
|
# Normalize their sizes to those smallest dimensions
|
||||||
|
convert "$LEFT" -background none -resize "$WIDTH"x"$HEIGHT"^ -gravity center -extent "$WIDTH"x"$HEIGHT" "$LEFT_NORM"
|
||||||
|
convert "$RIGHT" -background none -resize "$WIDTH"x"$HEIGHT"^ -gravity center -extent "$WIDTH"x"$HEIGHT" "$RIGHT_NORM"
|
||||||
|
|
||||||
|
convert -respect-parenthesis \
|
||||||
|
\( "$LEFT_NORM" -gravity north -crop "$WIDTH"x"$HEIGHT"+0+0 +repage -write "$LEFT_OUT" \) `#Load first image to a new png` \
|
||||||
|
\( "$RIGHT_NORM" -gravity east -crop "$WIDTH"x"$HEIGHT"+0+0 +repage -write "$RIGHT_OUT" \) `#Load second image to a new png` \
|
||||||
|
\( -size "$WIDTH"x"$HEIGHT" xc:black -fill white -draw "polygon 0,0 0,"$HEIGHT" "$WIDTH",0" -write "MASK_$LEFT_OUT" \) `#Create the mask of the upper triangle` \
|
||||||
|
\( -clone 2 -negate -write "MASK_$RIGHT_OUT" \) `#Create the mask of the lower triangle` \
|
||||||
|
\( -clone 0 -clone 2 -alpha off -compose copy_opacity -composite -write "$LEFT_OUT" \) `#Apply the upper triangle mask to the left image` \
|
||||||
|
\( -clone 1 -clone 3 -alpha off -compose copy_opacity -composite -write "$RIGHT_OUT" \) `#Apply the lower triangle mask to the right image` \
|
||||||
|
-delete 0-3 -compose over -composite "$OUT" `#Merge the two images together`;
|
||||||
|
|
||||||
|
#Cleaning up
|
||||||
|
rm "MASK_$RIGHT_OUT" "MASK_$LEFT_OUT" "$LEFT_OUT" "$RIGHT_OUT" "$LEFT_NORM" "$RIGHT_NORM";
|
||||||
4
home/scripts/zethra/git-reset-author
Executable file
4
home/scripts/zethra/git-reset-author
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
git rebase -r --root --exec 'git commit --amend --no-edit --reset-author'
|
||||||
|
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --msg-filter "sed /^Signed-off-by:/d"
|
||||||
3
home/scripts/zethra/gitlvim
Executable file
3
home/scripts/zethra/gitlvim
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
lvim +goto $@
|
||||||
3
home/scripts/zethra/gitnvim
Executable file
3
home/scripts/zethra/gitnvim
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
lvim +goto $@
|
||||||
9
home/scripts/zethra/iommu-groups.sh
Executable file
9
home/scripts/zethra/iommu-groups.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
shopt -s nullglob
|
||||||
|
for g in $(find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V); do
|
||||||
|
echo "IOMMU Group ${g##*/}:"
|
||||||
|
for d in $g/devices/*; do
|
||||||
|
echo -e "\t$(lspci -nns ${d##*/})"
|
||||||
|
done;
|
||||||
|
done;
|
||||||
|
|
||||||
49
home/scripts/zethra/nixos-upgrade
Executable file
49
home/scripts/zethra/nixos-upgrade
Executable file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
nixcfg=~/Projects/nixcfg
|
||||||
|
|
||||||
|
cd "$nixcfg"
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
outdir="$tmpdir/out"
|
||||||
|
trap "git rm -f --ignore-unmatch flake.lock" EXIT
|
||||||
|
ln -s ./hosts/$(hostname)/flake.lock .
|
||||||
|
git add flake.lock
|
||||||
|
nix flake update
|
||||||
|
nom build -o "$outdir" ".#nixosConfigurations.$(hostname).config.system.build.toplevel"
|
||||||
|
nvd diff /run/current-system "$outdir"
|
||||||
|
|
||||||
|
if [ "$#" -gt 0 ] && [ "$1" = "-y" ]; then
|
||||||
|
echo 'Skipping prompt'
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
while true; do
|
||||||
|
read -p 'Do you want to process with upgrade [Y/n]' yn
|
||||||
|
case "$yn" in
|
||||||
|
[Yy]* )
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
[Nn]* )
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo Upgrading...
|
||||||
|
|
||||||
|
# Do system upgrade
|
||||||
|
sudo rsync -rl --delete --exclude=".*" . /etc/nixos
|
||||||
|
sudo ln -s "/etc/nixos/hosts/$(hostname)/hardware-configuration.nix" /etc/nixos/hardware-configuration.nix
|
||||||
|
sudo nixos-rebuild switch
|
||||||
|
|
||||||
|
if [ $(git status --porcelain ./hosts/$(hostname)/flake.lock | wc -l) -gt 0 ]; then
|
||||||
|
git rm -f flake.lock
|
||||||
|
git add ./hosts/$(hostname)/flake.lock
|
||||||
|
git commit -m "System upgrade $(hostname)"
|
||||||
|
fi
|
||||||
6
home/scripts/zethra/ocr-clipboard
Executable file
6
home/scripts/zethra/ocr-clipboard
Executable file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd "$(mktemp -d)"
|
||||||
|
wl-paste > in.png
|
||||||
|
tesseract in.png out
|
||||||
|
wl-copy < out.txt
|
||||||
3
home/scripts/zethra/open
Executable file
3
home/scripts/zethra/open
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
xdg-open "$@" >/dev/null 2>&1 & disown
|
||||||
11
home/scripts/zethra/send-to-cache
Executable file
11
home/scripts/zethra/send-to-cache
Executable file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
REMOTE='root@noraa.gay'
|
||||||
|
else
|
||||||
|
REMOTE="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
nix build .
|
||||||
|
nix store sign -k /etc/nixos/secrets/cache-priv-key.pem ./result/
|
||||||
|
nix copy --to "ssh-ng://$REMOTE" ./result/
|
||||||
14
home/scripts/zethra/show-upgrade
Executable file
14
home/scripts/zethra/show-upgrade
Executable file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
nixcfg=~/Projects/nixcfg
|
||||||
|
|
||||||
|
tempdir=$(mktemp -d /tmp/tmp.nix-updateinfo.XXX)
|
||||||
|
git clone --reference "$nixcfg" "$nixcfg" "$tempdir"
|
||||||
|
cd $tempdir
|
||||||
|
nix flake lock --update-input nixpkgs
|
||||||
|
nix build ".#nixosConfigurations.$(hostname).config.system.build.toplevel"
|
||||||
|
nvd diff /run/current-system ./result
|
||||||
|
|
||||||
|
cd ~-
|
||||||
|
rm -rf "$tempdir"
|
||||||
27
home/scripts/zethra/speak-clipboard
Executable file
27
home/scripts/zethra/speak-clipboard
Executable file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PIDFILE='/tmp/speak.pid'
|
||||||
|
|
||||||
|
if [ -f "$PIDFILE" ]; then
|
||||||
|
PID=$(cut -f 1 $PIDFILE)
|
||||||
|
DIR=$(cut -f 2 $PIDFILE)
|
||||||
|
kill "$PID"
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
rm -rf "$DIR"
|
||||||
|
else
|
||||||
|
DIR=`mktemp -d`
|
||||||
|
xclip -sel clip -o > "$DIR/text"
|
||||||
|
RHVoice-test -r 140 -i "$DIR/text" -o "$DIR/out.wav"
|
||||||
|
mpv "$DIR/out.wav" &
|
||||||
|
# set -m
|
||||||
|
# festival --tts < "$DIR/text" &
|
||||||
|
PID="$!"
|
||||||
|
# set +m
|
||||||
|
echo "Making pid file, $PID $PIDFILE"
|
||||||
|
printf "$PID\t$DIR" > "$PIDFILE"
|
||||||
|
wait $(jobs -p)
|
||||||
|
echo "Speech done"
|
||||||
|
rm -rf "$DIR"
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
24
home/scripts/zethra/speak-screen
Executable file
24
home/scripts/zethra/speak-screen
Executable file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PIDFILE='/tmp/speak.pid'
|
||||||
|
|
||||||
|
if [ -f "$PIDFILE" ]; then
|
||||||
|
PID=$(cut -f 1 $PIDFILE)
|
||||||
|
DIR=$(cut -f 2 $PIDFILE)
|
||||||
|
kill "$PID"
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
rm -rf "$DIR"
|
||||||
|
else
|
||||||
|
DIR=`mktemp -d`
|
||||||
|
spectacle -rbno "$DIR/in.png"
|
||||||
|
tesseract "$DIR/in.png" - | tr '|' 'I' > "$DIR/text"
|
||||||
|
RHVoice-test -r 140 -i "$DIR/text" -o "$DIR/out.wav"
|
||||||
|
mpv "$DIR/out.wav" &
|
||||||
|
PID="$!"
|
||||||
|
echo "Making pid file, $PID $PIDFILE"
|
||||||
|
printf "$PID\t$DIR" > "$PIDFILE"
|
||||||
|
wait $(jobs -p)
|
||||||
|
echo "Speech done"
|
||||||
|
rm -rf "$DIR"
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
fi
|
||||||
27
home/scripts/zethra/speak-selected
Executable file
27
home/scripts/zethra/speak-selected
Executable file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PIDFILE='/tmp/speak.pid'
|
||||||
|
|
||||||
|
if [ -f "$PIDFILE" ]; then
|
||||||
|
PID=$(cut -f 1 $PIDFILE)
|
||||||
|
DIR=$(cut -f 2 $PIDFILE)
|
||||||
|
kill "$PID"
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
rm -rf "$DIR"
|
||||||
|
else
|
||||||
|
DIR=`mktemp -d`
|
||||||
|
xsel > "$DIR/text"
|
||||||
|
RHVoice-test -r 140 -i "$DIR/text" -o "$DIR/out.wav"
|
||||||
|
mpv "$DIR/out.wav" &
|
||||||
|
# set -m
|
||||||
|
# festival --tts < "$DIR/text" &
|
||||||
|
PID="$!"
|
||||||
|
# set +m
|
||||||
|
echo "Making pid file, $PID $PIDFILE"
|
||||||
|
printf "$PID\t$DIR" > "$PIDFILE"
|
||||||
|
wait $(jobs -p)
|
||||||
|
echo "Speech done"
|
||||||
|
rm -rf "$DIR"
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue