screenshot2app: new package

This commit is contained in:
Adrian Kuschelyagi Malacoda 2021-10-07 17:03:21 -05:00
parent b09e68119f
commit 76adb5cd3a
3 changed files with 138 additions and 0 deletions

View File

@ -0,0 +1,45 @@
(define-module (mason packages screenshot2app)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix build-system copy)
#:use-module (guix utils)
#:use-module (guix gexp)
#:use-module (gnu packages gtk)
#:use-module (gnu packages image))
(define-public screenshot2app
(package
(name "screenshot2app")
(version "0.0.1")
(home-page "https://wiki.mobian-project.org/doku.php?id=tweaks#taking-screenshots-v3")
(source
(local-file "scripts/screenshot2app" #:recursive? #t))
(build-system copy-build-system)
(arguments
'(#:install-plan
'(("screenshot2app" "bin/")
("screenshot2app.desktop" "share/applications/"))
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'configure
(lambda* (#:key inputs outputs #:allow-other-keys)
(substitute* (list "screenshot2app")
(("@EXTRA_PATH@")
(string-append (assoc-ref inputs "grim")
"/bin:"
(assoc-ref inputs "yad")
"/bin")))
(substitute* (list "screenshot2app.desktop")
(("@EXEC@")
(string-append (assoc-ref outputs "out")
"/bin/screenshot2app")))
#t)))))
(inputs
`(("yad" ,yad)
("grim" ,grim)))
(synopsis "")
(description
"")
(license license:gpl2+)))
screenshot2app

View File

@ -0,0 +1,79 @@
#!/bin/bash
# This script make a screen shot
#
# Authors: Kyle Rankin & @mo2mo:matrix.org
# https://puri.sm/posts/easy-librem-5-app-development-take-a-screenshot/
# https://wiki.mobian-project.org/doku.php?id=tweaks#taking-screenshots-v3
#
# dependencies: grim libnotify-bin yad
#
# License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law."
# make the info
LNG=$(echo $LANG | cut -d_ -f1)
case $LNG in
de) INFO="Ein Bildschirmfoto nach X Sekunden machen:\nName (auch mit Pfad)" ;;
es) INFO="Tomar una captura de pantalla después de X segundos:\nnombre (también con la ruta)" ;;
fr) INFO="Prendre une capture d'écran après X secondes:\nnom (également avec le chemin)" ;;
it) INFO="Scatta lo screenshot dopo X secondi:\nnome (anche con percorso)" ;;
ru) INFO="Снимок экрана через X секунд:\nимя (также с указанием пути)" ;;
*) INFO="Take screenshot after X seconds:\nname (also with path)"
esac
export PATH="$PATH:@EXTRA_PATH@"
# start with yad
INPUT=`yad --title Screenshot --text="$INFO" --form --field=filename:SFL --field=seconds:NUM "Screenshot" "5" --focus-field=1`
SCREENSHOT=`echo $INPUT | cut -d '|' -f1`
SECONDS=`echo $INPUT | cut -d '|' -f2`
[ "$SECONDS" -eq 0 ] && exit 1
# check & make a folder
if [ -f "${HOME}/.config/user-dirs.dirs" ]
then PICTURE_DIR=$(cat ${HOME}/.config/user-dirs.dirs | grep PICTURES | cut -d/ -f2 | cut -d\" -f1)
else PICTURE_DIR="Pictures"
fi
if [ -d "${HOME}/$PICTURE_DIR" ]
then FOLDER="$PICTURE_DIR/Screenshot"
else FOLDER="Screenshot"
fi
[ ! -d "${HOME}/$FOLDER" ] && mkdir "${HOME}/$FOLDER"
# check the target
if [ -d "$(echo ${SCREENSHOT%/*} | grep '/')" ]
then INFO=${SCREENSHOT##*/}
elif [ ! "$(echo "$SCREENSHOT" | grep "/home/")" ]
then SCREENSHOT="${HOME}/$FOLDER/${SCREENSHOT##*/}"
INFO="\n~/$FOLDER/${SCREENSHOT##*/}"
else exit 2
fi
# check the extensions
EXT="${SCREENSHOT##*.}"
case "$EXT" in
png|ppm) SCREENSHOT="$SCREENSHOT" ;;
*) EXT="png"
SCREENSHOT="$SCREENSHOT.$EXT" ;;
esac
# make a screenshot
sleep $SECONDS
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
if [ -f "$SCREENSHOT" ]
then SCREENSHOT="${SCREENSHOT%.*}_$TIMESTAMP.$EXT"
INFO="${INFO%.*}_$TIMESTAMP"
fi
grim -t $EXT "$SCREENSHOT"
case $LNG in
de) info="Bildschirmfoto gespeichert unter:" ;;
es) info="Captura de pantalla almacenada en:" ;;
fr) info="Capture d'écran stockée à:" ;;
it) info="Screenshot memorizzato su:" ;;
ru) info="Скриншот, сохраненный в:" ;;
*) info="Screenshot stored at:"
esac
notify-send screenshot "$info\n$INFO.$EXT"

View File

@ -0,0 +1,14 @@
[Desktop Entry]
Name=Screen Shot
Name[de]=Bildschirmfoto
Name[en_CA]=Screen Shot
Name[en_GB]=Screen Shot
Name[es]=Captura de pantalla
Name[fr]=Capture d'écran
Name[it]=Schermata
Type=Application
Icon=applets-screenshooter
Exec=@EXEC@
Terminal=false
Keywords=screenshooter;Bildschirmfoto;screen;
Categories=Utility;