Compare commits

..

No commits in common. "main" and "push-yqlvnukzxvnn" have entirely different histories.

6 changed files with 72 additions and 114 deletions

View file

@ -8,7 +8,7 @@
./common.nix ./common.nix
./desktop ./desktop
./dev ./dev
./extra ./extra.nix
./gaming ./gaming
./git ./git
./gpg ./gpg

View file

@ -874,7 +874,7 @@ class MprisProvider(Section, ThreadedUpdater):
"{{ playerName }} {{ status }}", "{{ playerName }} {{ status }}",
"{{ album }}", "{{ album }}",
"{{ artist }}", "{{ artist }}",
"{{ duration(position) }}/{{ duration(mpris:length) }}" " {{ title }}", "{{ duration(position) }}|{{ duration(mpris:length) }}" " {{ title }}",
] ]
# nf-fd icons don't work (UTF-16?) # nf-fd icons don't work (UTF-16?)
@ -894,8 +894,6 @@ class MprisProvider(Section, ThreadedUpdater):
3: "", 3: "",
} }
MAX_SECTION_LENGTH = 40
def __init__(self, theme: int | None = None): def __init__(self, theme: int | None = None):
ThreadedUpdater.__init__(self) ThreadedUpdater.__init__(self)
Section.__init__(self, theme) Section.__init__(self, theme)
@ -928,8 +926,6 @@ class MprisProvider(Section, ThreadedUpdater):
if text: if text:
if i in self.ICONS: if i in self.ICONS:
text = f"{self.ICONS[i]} {text}" text = f"{self.ICONS[i]} {text}"
if len(text) > self.MAX_SECTION_LENGTH:
text = text[: self.MAX_SECTION_LENGTH - 1] + ""
section.updateText(text) section.updateText(text)
else: else:
section.updateText(None) section.updateText(None)

View file

@ -21,7 +21,6 @@
# Communication # Communication
signal-desktop signal-desktop
(pkgs.callPackage ./whisperx.nix {}) # Transcribe voice messages
# downloading # downloading
# transmission TODO Collision if both transmissions are active? # transmission TODO Collision if both transmissions are active?

View file

@ -1,37 +0,0 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.python3Packages.buildPythonPackage {
pname = "whisperx";
version = "2024-08-19";
# pypi doesn't have the requirements.txt file, and it's required
src = pkgs.fetchFromGitHub {
owner = "m-bain";
repo = "whisperX";
rev = "9e3a9e0e38fcec1304e1784381059a0e2c670be5"; # git doesn't have tags
hash = "sha256-IVtn9fe/yi4+fbH57s9LoiREnMZ2nhEObp1a4R/7gHg=";
};
pyproject = true;
dependencies = [
pkgs.python3Packages.torch
pkgs.python3Packages.torchaudio
(pkgs.python3Packages.faster-whisper.overrideAttrs (old: {
# 1.0.2 is actually breaking APIs (requires hotwords argument)
src = pkgs.fetchFromGitHub {
owner = "SYSTRAN";
repo = "faster-whisper";
rev = "v1.0.0";
hash = "sha256-0fE8X1d6CgDrrHtRudksN/tIGRtBKMvoNwkSVyFNda4=";
};
}))
pkgs.python3Packages.transformers
pkgs.python3Packages.pyannote-audio # Not in the requirements.txt for some reason
pkgs.python3Packages.pandas
pkgs.python3Packages.nltk
];
build-system = [
pkgs.python3Packages.setuptools
];
pythonImportsCheck = [
"whisperx"
];
}

View file

@ -213,13 +213,13 @@ elif sys.argv[1] in ("merge", "mr"):
# so jj has a current bookmark. # so jj has a current bookmark.
mr = glab_get_mr(sys.argv[3]) mr = glab_get_mr(sys.argv[3])
jj.run("git", "fetch") jj.run("git", "fetch")
if len(jj.log(f"{mr.source_branch} | {mr.target_branch}")) == 1: if len(JujutsuCommit.log(f"{mr.source_branch} | {mr.target_branch}")) == 1:
title = re.sub(r"^(WIP|Draft): ", "", mr.title) title = re.sub(r"^(WIP|Draft): ", "", mr.title)
jj.run("new", mr.source_branch) jj.run("new", mr.source_branch)
jj.run("describe", "-m", title) jj.run("describe", "-m", title)
jj.run("bookmark", "move", mr.source_branch) jj.run("bookmark", "move", mr.source_branch)
else: else:
jj.run("edit", mr.source_branch) jj.run("bookmark", "edit", mr.source_branch)
elif sys.argv[2] in ( elif sys.argv[2] in (
# If no MR number/branch is given, insert the current bookmark, # If no MR number/branch is given, insert the current bookmark,
# as the current branch concept doesn't exist in jj # as the current branch concept doesn't exist in jj

View file

@ -1,9 +1,7 @@
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
#! nix-shell -i bash --pure #! nix-shell -i bash --pure
#! nix-shell -p bash coreutils imagemagick libjpeg optipng ffmpeg diffutils #! nix-shell -p bash coreutils imagemagick libjpeg optipng ffmpeg diffutils
# vim: filetype=sh
set -euo pipefail
# Optimizes everything the script can find in a folder, # Optimizes everything the script can find in a folder,
# meaning it will compress files as much as possible, # meaning it will compress files as much as possible,
@ -15,13 +13,14 @@ set -euo pipefail
# TODO Lots of dupplicated code there # TODO Lots of dupplicated code there
# TODO Maybe replace part with https://github.com/toy/image_optim? # TODO Maybe replace part with https://github.com/toy/image_optim?
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
dir=${1:-$PWD} dir=${1:-$PWD}
total=$(mktemp) total=$(mktemp)
echo -n 0 > "$total" echo -n 0 > $total
function showtotal { function showtotal {
echo "Total saved: $(cat "$total") bytes" echo "Total saved: $(cat "$total") bytes"
rm "$total" rm $total
exit exit
} }
@ -29,11 +28,11 @@ trap showtotal SIGTERM SIGINT SIGFPE
function doReplace { # candidate original function doReplace { # candidate original
mv "$c" "$o" mv "$c" "$o"
saved=$((os - cs)) saved=$(($os - $cs))
perc=$((100 * saved / os)) perc=$((100 * $saved / $os))
echo "→ $os ⇒ $cs (saved $saved bytes, or ${perc}%)" echo "→ $os ⇒ $cs (saved $saved bytes, or ${perc}%)"
newtotal=$(($(cat "$total") + saved)) newtotal=$(($(cat $total) + $saved))
echo -n $newtotal > "$total" echo -n $newtotal > $total
} }
function replace { # candidate original function replace { # candidate original
@ -53,17 +52,17 @@ function replace { # candidate original
# Size verifications # Size verifications
cs=$(wc -c "$c" | cut -d' ' -f1) cs=$(wc -c "$c" | cut -d' ' -f1)
os=$(wc -c "$o" | cut -d' ' -f1) os=$(wc -c "$o" | cut -d' ' -f1)
if [ "$cs" -le 0 ]; then if [ $cs -le 0 ]; then
echo "→ Candidate is empty, skipping!" echo "→ Candidate is empty, skipping!"
rm "$c" rm "$c"
return return
fi fi
if [ "$cs" -eq "$os" ]; then if [ $cs -eq $os ]; then
echo "→ Candidate weight the same, skipping." echo "→ Candidate weight the same, skipping."
rm "$c" rm "$c"
return return
fi fi
if [ "$cs" -gt "$os" ]; then if [ $cs -gt $os ]; then
echo "→ Candidate is larger, skipping." echo "→ Candidate is larger, skipping."
rm "$c" rm "$c"
return return
@ -72,75 +71,76 @@ function replace { # candidate original
doReplace "$c" "$o" doReplace "$c" "$o"
} }
# function replaceImg { # candidate original function replaceImg { # candidate original
# # With bitmap verification # With bitmap verification
#
# c="$1" c="$1"
# o="$2" o="$2"
#
# # File verifications # File verifications
# if [ ! -f "$o" ]; then if [ ! -f "$o" ]; then
# echo "→ Original is inexistant, skipping!" echo "→ Original is inexistant, skipping!"
# return return
# fi fi
# if [ ! -f "$c" ]; then if [ ! -f "$c" ]; then
# echo "→ Candidate is inexistant, skipping!" echo "→ Candidate is inexistant, skipping!"
# return return
# fi fi
#
# # Size verifications # Size verifications
# cs=$(wc -c "$c" | cut -d' ' -f1) cs=$(wc -c "$c" | cut -d' ' -f1)
# os=$(wc -c "$o" | cut -d' ' -f1) os=$(wc -c "$o" | cut -d' ' -f1)
# if [ $cs -le 0 ]; then if [ $cs -le 0 ]; then
# echo "→ Candidate is empty, skipping!" echo "→ Candidate is empty, skipping!"
# rm "$c" rm "$c"
# return return
# fi fi
# if [ $cs -eq $os ]; then if [ $cs -eq $os ]; then
# echo "→ Candidate weight the same, skipping." echo "→ Candidate weight the same, skipping."
# rm "$c" rm "$c"
# return return
# fi fi
# if [ $cs -gt $os ]; then if [ $cs -gt $os ]; then
# echo "→ Candidate is larger, skipping." echo "→ Candidate is larger, skipping."
# rm "$c" rm "$c"
# return return
# fi fi
#
# # Bitmap verification # Bitmap verification
# ppmc="$(mktemp --suffix .ppm)" ppmc="$(mktemp --suffix .ppm)"
# ppmo="$(mktemp --suffix .ppm)" ppmo="$(mktemp --suffix .ppm)"
# convert "$c" "$ppmc" convert "$c" "$ppmc"
# convert "$o" "$ppmo" convert "$o" "$ppmo"
#
# if cmp --silent "$ppmo" "$ppmc"; then if cmp --silent "$ppmo" "$ppmc"; then
# doReplace "$c" "$o" doReplace "$c" "$o"
# else else
# echo "→ Candidate don't have the same bit map as original, skipping!" echo "→ Candidate don't have the same bit map as original, skipping!"
# fi fi
# rm -f "$ppmc" "$ppmo" "$c" rm -f "$ppmc" "$ppmo" "$c"
#
# } }
# JPEG (requires jpegtran) # JPEG (requires jpegtran)
while read -r image while read image
do do
if [ -z "$image" ]; then continue; fi if [ -z "$image" ]; then continue; fi
echo Processing "$image" echo Processing $image
prog=$(mktemp --suffix .jpg) prog=$(mktemp --suffix .jpg)
jpegtran -copy all -progressive "$image" > "$prog" jpegtran -copy all -progressive "$image" > "$prog"
echo "→ Progressive done" echo "→ Progressive done"
progs=$(wc -c "$prog" | cut -d' ' -f1)
replace "$prog" "$image" replace "$prog" "$image"
done <<< "$(find "$dir/" -type f -iregex ".+.jpe?g$")" done <<< "$(find "$dir/" -type f -iregex ".+.jpe?g$")"
# PNG (requires optipng) # PNG (requires optipng)
while read -r image while read image
do do
if [ -z "$image" ]; then continue; fi if [ -z "$image" ]; then continue; fi
echo Processing "$image" echo Processing $image
temp=$(mktemp --suffix .png) temp=$(mktemp --suffix .png)
cp "$image" "$temp" cp "$image" "$temp"
@ -152,13 +152,13 @@ do
done <<< "$(find "$dir/" -type f -iname "*.png")" done <<< "$(find "$dir/" -type f -iname "*.png")"
# FLAC (requires ffmpeg) # FLAC (requires ffmpeg)
while read -r music while read music
do do
if [ -z "$music" ]; then continue; fi if [ -z "$music" ]; then continue; fi
echo "Processing $music" echo Processing $music
temp=$(mktemp --suffix .flac) temp=$(mktemp --suffix .flac)
ffmpeg -nostdin -y -i "$music" -compression_level 8 "$temp" ffmpeg -y -i "$music" -compression_level 8 "$temp"
echo "→ Optimize done" echo "→ Optimize done"
replace "$temp" "$music" replace "$temp" "$music"
@ -186,6 +186,6 @@ done <<< "$(find "$dir/" -type f -iname "*.flac")"
# - I might want to keep editor data and/or ids for some of them # - I might want to keep editor data and/or ids for some of them
# So rather use scour explicitely when needed # So rather use scour explicitely when needed
cleandev ${SCRIPT_DIR}/cleandev
showtotal showtotal