Add nice binaries

This commit is contained in:
2022-05-09 10:06:19 +02:00
parent 18025dbc56
commit b57650cced
3 changed files with 184 additions and 9 deletions

View File

@@ -1102,6 +1102,79 @@ case "$in_ext" in
esac
#+end_src
* =preview-file= - Preview any file
:PROPERTIES:
:CUSTOM_ID: preview-file
:header-args: :tangle ~/.local/bin/preview-file
:END:
** Get basic information about the file
#+begin_src bash
# Get filename
filename_with_extension=$(basename -- "$1")
# Extract extension of the file
in_ext="${filename_with_extension##*.}"
# filename without extension
filename_without_extension=${filename_with_extension%.*}
#+end_src
** SVG files
#+begin_src bash
# Convert SVG Files
svg2() { \
if command -v inkscape &> /dev/null; then
inkscape --export-type="$out_ext" "$filename_with_extension" --export-filename="/tmp/$filename_without_extension.pdf" && zathura "/tmp/$filename_without_extension.pdf"
fi
}
#+end_src
** DOCX files
#+begin_src bash
# Convert DOCX/PPTX Files
docx2() { \
if command -v lowriter &> /dev/null; then
lowriter --convert-to pdf "$filename_with_extension" --outdir /tmp/ && zathura "/tmp/$filename_without_extension.pdf"
fi
}
#+end_src
** Case statement
#+begin_src bash
case "$in_ext" in
"svg")
svg2
;;
"gif")
gif2
;;
"dvi")
dvi2
;;
"pdf")
pdf2
;;
"mp4")
mp42
;;
"png")
png2
;;
"jpg")
jpg2
;;
"jpeg")
jpg2
;;
"docx")
docx2
;;
"pttx")
docx2
;;
esac
#+end_src
* =pdf-shrink= - Pdf Shrink
:PROPERTIES:
:CUSTOM_ID: pdf-shrink
@@ -1257,3 +1330,44 @@ awk '/^[a-z]/ && last {print "<small>",$0,"\t",last,"</small>"} {last=""} /^#/{l
column -t -s $'\t' |
rofi -dmenu -i -markup-rows -no-show-icons -width 1000 -lines 15 -yoffset 40
#+end_src
* =qrdecode= - Decode QRcode by taking screenshot
- =zbar-tools=
- =main=
- =xclip=
- =notify-send=
#+begin_src bash :tangle ~/.local/bin/qrdecode
image_file="/tmp/ocr.png"
# Take screenshot by selecting the area
maim -s "$image_file"
# Get the exit code of the previous command.
# So in this case, it is the screenshot command. If it did not exit with an
# exit code 0, then it means the user canceled the process of taking a
# screenshot by doing something like pressing the escape key
status=$?
# If the user pressed the escape key or did something to terminate the proccess
# taking a screenshot, then just exit
[ $status -ne 0 ] && exit 1
# Use zbarimg to decode the text from the QR code
decoded_text=$(zbarimg "$image_file" -q --raw)
if [ -z "$decoded_text" ]; then
notify-send "qrshot" "no text was detected"
rm $image_file && exit 1
fi
# Copy text to clipboard
printf %b "$decoded_text" | xclip -selection clip
# Let us know that something was decoded
notify-send "qrshot" "$decoded_text"
# Cleaning up the trash that was left behind
rm $image_file
#+end_src