Update some scripts
This commit is contained in:
parent
5da5ac0e5b
commit
bdebbb6342
@ -876,14 +876,13 @@ Finally, lock the screen using =i3lock=.
|
||||
curl "$address"
|
||||
fi
|
||||
#+end_src
|
||||
* =readbib= - Open Bibliography File
|
||||
|
||||
* =readbib= - Open Bibliography File
|
||||
#+begin_src bash :tangle ~/.local/bin/readbib
|
||||
cd ~/Cloud/pdfs/ && ls | rofi -dmenu -lines 20 | xargs -I {} zathura {}
|
||||
#+end_src
|
||||
|
||||
* =readnotes= - Open Note File
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/readnotes
|
||||
cd ~/Cloud/thesis/ressources/notes/pdfs/ && ls *.pdf | rofi -dmenu -lines 20 | xargs -I {} zathura {}
|
||||
#+end_src
|
||||
@ -921,75 +920,75 @@ Finally, lock the screen using =i3lock=.
|
||||
|
||||
* =pdf2png= - Convert a PDF to PNG
|
||||
#+begin_src bash :tangle ~/.local/bin/pdf2png
|
||||
if [[ -f $1 && $1 == *.pdf ]]; then
|
||||
pdftoppm -png $1 > $(echo $1 | cut -f 1 -d '.' | sed 's/$/.png/')
|
||||
if [[ -f "$1" && "$1" == *.pdf ]]; then
|
||||
pdftoppm -png "$1" > "$(echo "$1" | cut -f 1 -d '.' | sed 's/$/.png/')"
|
||||
fi
|
||||
#+end_src
|
||||
* =pdf-shrink= - Pdf Shrink
|
||||
|
||||
* =pdf-shrink= - Pdf Shrink
|
||||
#+begin_src bash :tangle ~/.local/bin/pdf-shrink
|
||||
shrink ()
|
||||
{
|
||||
gs \
|
||||
-q -dNOPAUSE -dBATCH -dSAFER \
|
||||
-sDEVICE=pdfwrite \
|
||||
-dCompatibilityLevel=1.3 \
|
||||
-dPDFSETTINGS=/screen \
|
||||
-dEmbedAllFonts=true \
|
||||
-dSubsetFonts=true \
|
||||
-dAutoRotatePages=/None \
|
||||
-dColorImageDownsampleType=/Bicubic \
|
||||
-dColorImageResolution=$3 \
|
||||
-dGrayImageDownsampleType=/Bicubic \
|
||||
-dGrayImageResolution=$3 \
|
||||
-dMonoImageDownsampleType=/Subsample \
|
||||
-dMonoImageResolution=$3 \
|
||||
-sOutputFile="$2" \
|
||||
"$1"
|
||||
gs \
|
||||
-q -dNOPAUSE -dBATCH -dSAFER \
|
||||
-sDEVICE=pdfwrite \
|
||||
-dCompatibilityLevel=1.3 \
|
||||
-dPDFSETTINGS=/screen \
|
||||
-dEmbedAllFonts=true \
|
||||
-dSubsetFonts=true \
|
||||
-dAutoRotatePages=/None \
|
||||
-dColorImageDownsampleType=/Bicubic \
|
||||
-dColorImageResolution=$3 \
|
||||
-dGrayImageDownsampleType=/Bicubic \
|
||||
-dGrayImageResolution=$3 \
|
||||
-dMonoImageDownsampleType=/Subsample \
|
||||
-dMonoImageResolution=$3 \
|
||||
-sOutputFile="$2" \
|
||||
"$1"
|
||||
}
|
||||
|
||||
check_smaller ()
|
||||
{
|
||||
# If $1 and $2 are regular files, we can compare file sizes to
|
||||
# see if we succeeded in shrinking. If not, we copy $1 over $2:
|
||||
if [ ! -f "$1" -o ! -f "$2" ]; then
|
||||
return 0;
|
||||
fi
|
||||
ISIZE="$(echo $(wc -c "$1") | cut -f1 -d\ )"
|
||||
OSIZE="$(echo $(wc -c "$2") | cut -f1 -d\ )"
|
||||
if [ "$ISIZE" -lt "$OSIZE" ]; then
|
||||
echo "Input smaller than output, doing straight copy" >&2
|
||||
cp "$1" "$2"
|
||||
fi
|
||||
# If $1 and $2 are regular files, we can compare file sizes to
|
||||
# see if we succeeded in shrinking. If not, we copy $1 over $2:
|
||||
if [ ! -f "$1" -o ! -f "$2" ]; then
|
||||
return 0;
|
||||
fi
|
||||
ISIZE="$(echo $(wc -c "$1") | cut -f1 -d\ )"
|
||||
OSIZE="$(echo $(wc -c "$2") | cut -f1 -d\ )"
|
||||
if [ "$ISIZE" -lt "$OSIZE" ]; then
|
||||
echo "Input smaller than output, doing straight copy" >&2
|
||||
cp "$1" "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
usage ()
|
||||
{
|
||||
echo "Reduces PDF filesize by lossy recompressing with Ghostscript."
|
||||
echo "Not guaranteed to succeed, but usually works."
|
||||
echo " Usage: $1 infile [outfile] [resolution_in_dpi]"
|
||||
echo "Reduces PDF filesize by lossy recompressing with Ghostscript."
|
||||
echo "Not guaranteed to succeed, but usually works."
|
||||
echo " Usage: $1 infile [outfile] [resolution_in_dpi]"
|
||||
}
|
||||
|
||||
IFILE="$1"
|
||||
|
||||
# Need an input file:
|
||||
if [ -z "$IFILE" ]; then
|
||||
usage "$0"
|
||||
exit 1
|
||||
usage "$0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Output filename defaults to "-" (stdout) unless given:
|
||||
if [ ! -z "$2" ]; then
|
||||
OFILE="$2"
|
||||
OFILE="$2"
|
||||
else
|
||||
OFILE="-"
|
||||
OFILE="-"
|
||||
fi
|
||||
|
||||
# Output resolution defaults to 72 unless given:
|
||||
if [ ! -z "$3" ]; then
|
||||
res="$3"
|
||||
res="$3"
|
||||
else
|
||||
res="90"
|
||||
res="90"
|
||||
fi
|
||||
|
||||
shrink "$IFILE" "$OFILE" "$res" || exit $?
|
||||
@ -1021,3 +1020,25 @@ The requirement is to have =pdftk= or =stapler= installed.
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
* =rofi-calc= - Simple Calculation using Rofi
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/rofi-calc
|
||||
rofi -show calc -mode calc -no-show-match -no-sort
|
||||
#+end_src
|
||||
|
||||
* =pass-gen= - Generate Random Alphanumeric Password
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/pass-gen
|
||||
num=$(rofi -dmenu -p "Number of caracters")
|
||||
pass=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
|
||||
|
||||
re='^[0-9]+$'
|
||||
if [[ $num =~ $re ]] ; then
|
||||
pass=${pass:0:$num}
|
||||
fi
|
||||
|
||||
printf "$pass" | xclip -sel clip && \
|
||||
dunstify 'Password' 'Generated'
|
||||
#+end_src
|
||||
|
Loading…
Reference in New Issue
Block a user