forked from mirrors_public/oddlama_nix-config
feat: use flameshot for screenshotting (twice as fast for fullscreen)
This commit is contained in:
parent
667fa26f14
commit
d081e70d78
5 changed files with 43 additions and 16 deletions
13
pkgs/scripts/assets/qr-scan.svg
Normal file
13
pkgs/scripts/assets/qr-scan.svg
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill="#e3e6eb" d="m23 4c0-1.6568-1.3431-3-3-3h-4c-0.5523 0-1 0.44772-1 1s0.4477 1 1 1h4c0.5523 0 1 0.44772 1 1v4c0 0.55228 0.4477 1 1 1s1-0.44772 1-1v-4z"/>
|
||||
<path fill="#e3e6eb" d="m23 16c0-0.5523-0.4477-1-1-1s-1 0.4477-1 1v4c0 0.5523-0.4477 1-1 1h-4c-0.5523 0-1 0.4477-1 1s0.4477 1 1 1h4c1.6569 0 3-1.3431 3-3v-4z"/>
|
||||
<path fill="#e3e6eb" d="m4 21c-0.55228 0-1-0.4477-1-1v-4c0-0.5523-0.44772-1-1-1s-1 0.4477-1 1v4c0 1.6569 1.3432 3 3 3h4c0.55228 0 1-0.4477 1-1s-0.44772-1-1-1h-4z"/>
|
||||
<path fill="#e3e6eb" d="m1 8c0 0.55228 0.44772 1 1 1s1-0.44772 1-1v-4c0-0.55228 0.44772-1 1-1h4c0.55228 0 1-0.44772 1-1s-0.44772-1-1-1h-4c-1.6568 0-3 1.3432-3 3v4z"/>
|
||||
<path fill="#e3e6eb" d="M11 6C11 5.44772 10.5523 5 10 5H6C5.44772 5 5 5.44772 5 6V10C5 10.5523 5.44772 11 6 11H10C10.5523 11 11 10.5523 11 10V6ZM9 7.5C9 7.22386 8.77614 7 8.5 7H7.5C7.22386 7 7 7.22386 7 7.5V8.5C7 8.77614 7.22386 9 7.5 9H8.5C8.77614 9 9 8.77614 9 8.5V7.5Z" clip-rule="evenodd" fill="#fff" fill-rule="evenodd"/>
|
||||
<path fill="#e3e6eb" d="m18 13c0.5523 0 1 0.4477 1 1v4c0 0.5523-0.4477 1-1 1h-4c-0.5523 0-1-0.4477-1-1v-4c0-0.5523 0.4477-1 1-1h4zm-3 2.5c0-0.2761 0.2239-0.5 0.5-0.5h1c0.2761 0 0.5 0.2239 0.5 0.5v1c0 0.2761-0.2239 0.5-0.5 0.5h-1c-0.2761 0-0.5-0.2239-0.5-0.5v-1z" clip-rule="evenodd" fill="#fff" fill-rule="evenodd"/>
|
||||
<path fill="#e3e6eb" d="m14 5c-0.5523 0-1 0.44772-1 1 0 0.55229 0.4477 1 1 1h2.5c0.2761 0 0.5 0.22386 0.5 0.5v2.5c0 0.5523 0.4477 1 1 1s1-0.4477 1-1v-4c0-0.55228-0.4477-1-1-1h-4z"/>
|
||||
<path fill="#e3e6eb" d="m14 8c-0.5523 0-1 0.44771-1 1v1c0 0.5523 0.4477 1 1 1s1-0.4477 1-1v-1c0-0.55228-0.4477-1-1-1z"/>
|
||||
<path fill="#e3e6eb" d="m6 13c-0.55228 0-1 0.4477-1 1v2c0 0.5523 0.44772 1 1 1 0.55229 0 1-0.4477 1-1v-0.5c0-0.2761 0.22386-0.5 0.5-0.5h2.5c0.5523 0 1-0.4477 1-1s-0.4477-1-1-1h-4z"/>
|
||||
<path fill="#e3e6eb" d="m10 17c-0.55229 0-1 0.4477-1 1s0.44771 1 1 1c0.5523 0 1-0.4477 1-1s-0.4477-1-1-1z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2 KiB |
|
@ -1,10 +1,11 @@
|
|||
{
|
||||
lib,
|
||||
writeShellApplication,
|
||||
flameshot,
|
||||
libnotify,
|
||||
xclip,
|
||||
maim,
|
||||
zbar,
|
||||
yq,
|
||||
zbar,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "screenshot-area-scan-qr";
|
||||
|
@ -19,10 +20,12 @@ writeShellApplication {
|
|||
TMPFILE=/dev/fd/3
|
||||
|
||||
date=$(date +"%Y-%m-%dT%H:%M:%S%:z")
|
||||
out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$date-selection.png"
|
||||
mkdir -p "$(dirname "$out")"
|
||||
|
||||
if ${maim}/bin/maim --color=.4,.7,1 --bordersize=1.0 --nodecorations=1 --hidecursor --format=png --quality=10 --noopengl --select \
|
||||
# Always use native scaling to ensure flameshot is fullscreen across monitors
|
||||
export QT_AUTO_SCREEN_SCALE_FACTOR=0
|
||||
export QT_SCREEN_SCALE_FACTORS=""
|
||||
|
||||
if ${lib.getExe flameshot} gui --raw \
|
||||
| ${zbar}/bin/zbarimg --xml - > "$TMPFILE"; then
|
||||
N=$(${yq}/bin/xq -r '.barcodes.source.index.symbol | if type == "array" then length else 1 end' < "$TMPFILE")
|
||||
# Append codes Copy data separated by ---
|
||||
|
@ -33,7 +36,7 @@ writeShellApplication {
|
|||
${xclip}/bin/xclip -selection clipboard <<< "$DATA"
|
||||
${libnotify}/bin/notify-send \
|
||||
"🔍 QR Code scan" "✅ $N codes detected\n📋 copied ''${#DATA} bytes" \
|
||||
--hint="string:image-path:$out" \
|
||||
--hint="string:image-path:"${./assets/qr-scan.svg} \
|
||||
--hint="string:wired-tag:screenshot-$date" \
|
||||
|| true
|
||||
else
|
||||
|
@ -41,14 +44,14 @@ writeShellApplication {
|
|||
"4")
|
||||
${libnotify}/bin/notify-send \
|
||||
"🔍 QR Code scan" "❌ 0 codes detected" \
|
||||
--hint="string:image-path:$out" \
|
||||
--hint="string:image-path:"${./assets/qr-scan.svg} \
|
||||
--hint="string:wired-tag:screenshot-$date" \
|
||||
|| true
|
||||
;;
|
||||
*)
|
||||
${libnotify}/bin/notify-send \
|
||||
"🔍 QR Code scan" "❌ Error while processing image: zbarimg exited with code $?" \
|
||||
--hint="string:image-path:$out" \
|
||||
--hint="string:image-path:"${./assets/qr-scan.svg} \
|
||||
--hint="string:wired-tag:screenshot-$date" \
|
||||
|| true
|
||||
;;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
lib,
|
||||
writeShellApplication,
|
||||
flameshot,
|
||||
libnotify,
|
||||
xclip,
|
||||
moreutils,
|
||||
tesseract,
|
||||
maim,
|
||||
xclip,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "screenshot-area";
|
||||
|
@ -15,8 +17,12 @@ writeShellApplication {
|
|||
out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$date-selection.png"
|
||||
mkdir -p "$(dirname "$out")"
|
||||
|
||||
${maim}/bin/maim --color=.4,.7,1,0.2 --bordersize=1.0 --nodecorations=1 \
|
||||
--hidecursor --format=png --quality=10 --noopengl --select "$out"
|
||||
# Always use native scaling to ensure flameshot is fullscreen across monitors
|
||||
export QT_AUTO_SCREEN_SCALE_FACTOR=0
|
||||
export QT_SCREEN_SCALE_FACTORS=""
|
||||
|
||||
# Use sponge to create the file on success only
|
||||
${lib.getExe flameshot} gui --raw | ${moreutils}/bin/sponge "$out"
|
||||
${xclip}/bin/xclip -selection clipboard -t image/png < "$out"
|
||||
action=$(${libnotify}/bin/notify-send \
|
||||
"📷 Screenshot captured" "📋 copied to clipboard" \
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
lib,
|
||||
writeShellApplication,
|
||||
flameshot,
|
||||
libnotify,
|
||||
maim,
|
||||
moreutils,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "screenshot-screen";
|
||||
|
@ -9,12 +11,14 @@ writeShellApplication {
|
|||
set -euo pipefail
|
||||
umask 077
|
||||
|
||||
out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$(date +"%Y-%m-%dT%H:%M:%S%:z")-fullscreen.png"
|
||||
date=$(date +"%Y-%m-%dT%H:%M:%S%:z")
|
||||
out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$date-fullscreen.png"
|
||||
mkdir -p "$(dirname "$out")"
|
||||
|
||||
${maim}/bin/maim --hidecursor --format=png --quality=10 --noopengl "$out"
|
||||
${lib.getExe flameshot} full --raw | ${moreutils}/bin/sponge "$out"
|
||||
${libnotify}/bin/notify-send \
|
||||
"📷 Screenshot captured" "💾 Saved to $out" \
|
||||
--hint="string:wired-tag:screenshot-$date" \
|
||||
|| true
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue