Update binaries and scripts
This commit is contained in:
parent
d72261c3a6
commit
097d90aa8e
@ -532,8 +532,6 @@ mode=bookmarks main
|
|||||||
cd ~/Cloud/thesis/ressources/notes/ && ls *.pdf | rofi -dmenu -lines 20 | xargs -I {} zathura {}
|
cd ~/Cloud/thesis/ressources/notes/ && ls *.pdf | rofi -dmenu -lines 20 | xargs -I {} zathura {}
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+RESULTS:
|
|
||||||
|
|
||||||
* askpass
|
* askpass
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle ~/bin/askpass-rofi
|
:header-args: :tangle ~/bin/askpass-rofi
|
||||||
@ -666,3 +664,127 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already
|
|||||||
sudo -A mkdir ~/tmp_14_days;
|
sudo -A mkdir ~/tmp_14_days;
|
||||||
sudo -A mount -o rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=160.103.232.103,mountvers=3,mountport=597,mountproto=tcp,local_lock=none,addr=160.103.232.103 rnice:/hz/tmp_14_days ~/tmp_14_days;
|
sudo -A mount -o rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=160.103.232.103,mountvers=3,mountport=597,mountproto=tcp,local_lock=none,addr=160.103.232.103 rnice:/hz/tmp_14_days ~/tmp_14_days;
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
* Make GIF
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args: :tangle ~/bin/make-gif
|
||||||
|
:header-args+: :comments both :mkdirp yes
|
||||||
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
|
:END:
|
||||||
|
http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
palette="/tmp/palette.png"
|
||||||
|
|
||||||
|
filters="fps=15,scale=320:-1:flags=lanczos"
|
||||||
|
|
||||||
|
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
|
||||||
|
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
|
||||||
|
#+end_src
|
||||||
|
* Download-Audio
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args: :tangle ~/bin/yt-audio
|
||||||
|
:header-args+: :comments both :mkdirp yes
|
||||||
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
if [ $TMUX ]; then
|
||||||
|
tmux split -v -l 1 "cd ~/Downloads/ && youtube-dl --add-metadata -xic -f bestaudio/best $1" && tmux select-pane -U
|
||||||
|
else
|
||||||
|
cd ~/Downloads/;
|
||||||
|
setsid nohup youtube-dl --add-metadata -xic -f bestaudio/best $1 &> /dev/null &
|
||||||
|
fi
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
* Download-Video
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args: :tangle ~/bin/yt-video
|
||||||
|
:header-args+: :comments both :mkdirp yes
|
||||||
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
if [ $TMUX ]; then
|
||||||
|
tmux split -v -l 1 "cd ~/Downloads/ && youtube-dl --add-metadata -ic $1" && tmux select-pane -U
|
||||||
|
else
|
||||||
|
cd ~/Downloads/;
|
||||||
|
setsid nohup youtube-dl --add-metadata -ic $1 &> /dev/null &
|
||||||
|
fi
|
||||||
|
#+end_src
|
||||||
|
* Pdf Shrink
|
||||||
|
:PROPERTIES:
|
||||||
|
:header-args: :tangle ~/bin/pdf-shrink
|
||||||
|
:header-args+: :comments both :mkdirp yes
|
||||||
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
|
:END:
|
||||||
|
|
||||||
|
#+begin_src bash
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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]"
|
||||||
|
}
|
||||||
|
|
||||||
|
IFILE="$1"
|
||||||
|
|
||||||
|
# Need an input file:
|
||||||
|
if [ -z "$IFILE" ]; then
|
||||||
|
usage "$0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Output filename defaults to "-" (stdout) unless given:
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
OFILE="$2"
|
||||||
|
else
|
||||||
|
OFILE="-"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Output resolution defaults to 72 unless given:
|
||||||
|
if [ ! -z "$3" ]; then
|
||||||
|
res="$3"
|
||||||
|
else
|
||||||
|
res="90"
|
||||||
|
fi
|
||||||
|
|
||||||
|
shrink "$IFILE" "$OFILE" "$res" || exit $?
|
||||||
|
|
||||||
|
check_smaller "$IFILE" "$OFILE"
|
||||||
|
#+end_src
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
:header-args+: :comments both :mkdirp yes
|
:header-args+: :comments both :mkdirp yes
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
while true; do
|
while true; do
|
||||||
nitrogen --set-zoom-fill --random ".wallpapers"
|
nitrogen --set-zoom-fill --random ".wallpapers"
|
||||||
@ -30,13 +31,12 @@
|
|||||||
done
|
done
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* TODO [#A] LockScreen
|
* LockScreen
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle ~/scripts/lockscreen.sh
|
:header-args: :tangle ~/scripts/lockscreen.sh
|
||||||
:header-args+: :comments both :mkdirp yes
|
:header-args+: :comments both :mkdirp yes
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
:END:
|
:END:
|
||||||
- [ ] Does not work well with multiple screen
|
|
||||||
|
|
||||||
First, turn off dunst
|
First, turn off dunst
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
@ -63,7 +63,7 @@ Then take a screenshot and process it.
|
|||||||
|
|
||||||
Finally, lock the screen using =i3lock=.
|
Finally, lock the screen using =i3lock=.
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
i3lock -e -n -i $temp_file && killall -SIGUSR2 dunst && echo "on" > /tmp/dunststatus
|
i3lock --no-unlock-indicator --ignore-empty-password --nofork --image=$temp_file && killall -SIGUSR2 dunst && echo "on" > /tmp/dunststatus
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+begin_src bash :tangle no
|
#+begin_src bash :tangle no
|
||||||
@ -100,33 +100,12 @@ Finally, lock the screen using =i3lock=.
|
|||||||
revert
|
revert
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Delete first page of PDF
|
* Lock / Exit / Suspend / ...
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle ~/scripts/pdf-delete-first-page.sh
|
:header-args: :tangle ~/scripts/quit.sh
|
||||||
:header-args+: :comments both :mkdirp yes
|
:header-args+: :comments both :mkdirp yes
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
:END:
|
:END:
|
||||||
The requirement is to have =pdftk= or =stapler= installed.
|
|
||||||
|
|
||||||
#+begin_src bash
|
|
||||||
if [[ -f $1 && $1 == *.pdf ]]; then
|
|
||||||
# Argument if a file
|
|
||||||
if type stapler > /dev/null 2>&1; then
|
|
||||||
stapler del "$1" 1 /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1"
|
|
||||||
elif type pdftk > /dev/null 2>&1; then
|
|
||||||
pdftk "$1" cat 2-end output /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1"
|
|
||||||
else
|
|
||||||
echo "Neither pdftk nor stapler are installed"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Lock / Exit / Suspend / ...
|
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :tangle ~/scripts/quit.sh
|
|
||||||
:header-args+: :comments both :mkdirp yes
|
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
||||||
:END:
|
|
||||||
|
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
option=$(echo -e "Lock\nExit\nLogout\nSuspend\nHibernate\nReboot\nShutdown" | rofi -i -dmenu)
|
option=$(echo -e "Lock\nExit\nLogout\nSuspend\nHibernate\nReboot\nShutdown" | rofi -i -dmenu)
|
||||||
@ -149,62 +128,13 @@ The requirement is to have =pdftk= or =stapler= installed.
|
|||||||
esac
|
esac
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+RESULTS:
|
* NAS - Mount
|
||||||
* TODO [#C] Copy Figures
|
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :tangle ~/scripts/cp-figs.sh
|
|
||||||
:header-args+: :comments both :mkdirp yes
|
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
||||||
:END:
|
|
||||||
|
|
||||||
Things to do:
|
|
||||||
- [ ] Display all the figures at once and ask for confirmation to copy them all
|
|
||||||
- [ ] Display the not found figures
|
|
||||||
|
|
||||||
#+begin_src bash :results output
|
|
||||||
latexpath="$HOME/Cloud/thesis/latex/ressources/Figures";
|
|
||||||
|
|
||||||
figures=`awk 'match($0, /(fig.*\.(png|svg|pdf))/, a) {print a[1];}' $1 \
|
|
||||||
| awk '{ print gensub(/\s*\]\]\s*\|\s*\[\[\s*\.?\/?/, "\n", "g") }'`;
|
|
||||||
|
|
||||||
for figure in $figures
|
|
||||||
do
|
|
||||||
figurename=`echo $figure | awk 'match($0, /(fig.*\/)(.*\.(png|svg|pdf))/, a) {print a[2];}'`;
|
|
||||||
if [ -f $latexpath/$figurename ]
|
|
||||||
then
|
|
||||||
figurepath=`echo $figure | awk 'match($0, /(fig.*)\/(.*\.(png|svg|pdf))/, a) {print a[1];}'`;
|
|
||||||
|
|
||||||
# echo $latexpath/$figurename
|
|
||||||
# echo $figurepath/$figurename
|
|
||||||
cp $latexpath/$figurename $figurepath/$figurename
|
|
||||||
|
|
||||||
# read -r -p "Are You Sure? [Y/n] " input
|
|
||||||
|
|
||||||
# case $input in
|
|
||||||
# [yY][eE][sS]|[yY])
|
|
||||||
# cp $latexpath/$figurename $figurepath/$figurename
|
|
||||||
# ;;
|
|
||||||
# [nN][oO]|[nN])
|
|
||||||
# exit 1
|
|
||||||
# ;;
|
|
||||||
# *)
|
|
||||||
# echo "Invalid input..."
|
|
||||||
# exit 1
|
|
||||||
# ;;
|
|
||||||
# esac
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
#+RESULTS:
|
|
||||||
|
|
||||||
* NAS
|
|
||||||
** Mount
|
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle ~/scripts/nas.sh
|
:header-args: :tangle ~/scripts/nas.sh
|
||||||
:header-args+: :comments both :mkdirp yes
|
:header-args+: :comments both :mkdirp yes
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
if [ $1 == "mount" ]; then
|
if [ $1 == "mount" ]; then
|
||||||
if sudo -A mount 192.168.1.2:/volume1/Downloads/ /mnt/NAS/; then
|
if sudo -A mount 192.168.1.2:/volume1/Downloads/ /mnt/NAS/; then
|
||||||
@ -220,102 +150,33 @@ Things to do:
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#+end_src
|
#+end_src
|
||||||
* Buku Git Push
|
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :tangle ~/scripts/buku_git_push.sh
|
|
||||||
:header-args+: :comments both :mkdirp yes
|
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
||||||
:END:
|
|
||||||
#+begin_src bash
|
|
||||||
cd ~/.local/share/buku/
|
|
||||||
|
|
||||||
if [[ ! -z $(git status -s bookmarks.db) ]]
|
|
||||||
then
|
|
||||||
git add bookmarks.db
|
|
||||||
git commit -m "Changed bookmarks - $(date +%F)"
|
|
||||||
git push
|
|
||||||
dunstify --replace=79248 "Buku Git" "Updated"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
#+end_src
|
|
||||||
* Icons Unicode
|
* Icons Unicode
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle ~/scripts/icons.sh
|
:header-args: :tangle ~/scripts/icons.sh
|
||||||
:header-args+: :comments both :mkdirp yes
|
:header-args+: :comments both :mkdirp yes
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
:END:
|
:END:
|
||||||
#+begin_src bash
|
|
||||||
command -v xclip >/dev/null 2>&1 || { echo >&2 "I require xclip but it's not installed. Aborting."; exit 1; }
|
|
||||||
|
|
||||||
chosen=$(grep -v "#" ~/.config/emoji | dmenu -i -l 20)
|
#+begin_src bash
|
||||||
|
# The famous "get a menu of emojis to copy" script.
|
||||||
|
|
||||||
|
# Must have xclip installed to even show menu.
|
||||||
|
xclip -h 2>/dev/null || exit 1
|
||||||
|
|
||||||
|
chosen=$(cut -d ';' -f1 ~/.local/share/emoji | rofi -dmenu -i -l 20 | sed "s/ .*//")
|
||||||
|
|
||||||
[ "$chosen" != "" ] || exit
|
[ "$chosen" != "" ] || exit
|
||||||
|
|
||||||
c=$(echo "$chosen" | sed "s/ .*//")
|
# If you run this command with an argument, it will automatically insert the character.
|
||||||
echo "$c" | tr -d '\n' | xclip -selection clipboard
|
if [ -n "$1" ]; then
|
||||||
dunstify --replace=05896 "'$c' copied to clipboard." &
|
xdotool key Shift+Insert
|
||||||
|
else
|
||||||
|
echo "$chosen" | tr -d '\n' | xclip -selection clipboard
|
||||||
|
notify-send "'$chosen' copied to clipboard." &
|
||||||
|
fi
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Make GIF
|
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :tangle ~/scripts/gifenc.sh
|
|
||||||
:header-args+: :comments both :mkdirp yes
|
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
||||||
:END:
|
|
||||||
http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
|
|
||||||
|
|
||||||
#+begin_src bash
|
|
||||||
palette="/tmp/palette.png"
|
|
||||||
|
|
||||||
filters="fps=15,scale=320:-1:flags=lanczos"
|
|
||||||
|
|
||||||
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette
|
|
||||||
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Org-Capture
|
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :tangle ~/scripts/org-capture-selection.sh
|
|
||||||
:header-args+: :comments both :mkdirp yes
|
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
||||||
:END:
|
|
||||||
|
|
||||||
#+begin_src bash
|
|
||||||
xclip -o -selection primary | xclip -o -selection clipboard -i
|
|
||||||
emacsclient -ne '(org-capture "" "Q")' && dunstify "Emacs" "Text Successfully Captured"
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Download-Audio
|
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :tangle ~/scripts/download-audio.sh
|
|
||||||
:header-args+: :comments both :mkdirp yes
|
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
||||||
:END:
|
|
||||||
|
|
||||||
#+begin_src bash
|
|
||||||
if [ $TMUX ]; then
|
|
||||||
tmux split -v -l 1 "cd ~/Downloads/ && youtube-dl --add-metadata -xic -f bestaudio/best $1" && tmux select-pane -U
|
|
||||||
else
|
|
||||||
cd ~/Downloads/;
|
|
||||||
setsid nohup youtube-dl --add-metadata -xic -f bestaudio/best $1 &> /dev/null &
|
|
||||||
fi
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
* Download-Video
|
|
||||||
:PROPERTIES:
|
|
||||||
:header-args: :tangle ~/scripts/download-video.sh
|
|
||||||
:header-args+: :comments both :mkdirp yes
|
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
||||||
:END:
|
|
||||||
|
|
||||||
#+begin_src bash
|
|
||||||
if [ $TMUX ]; then
|
|
||||||
tmux split -v -l 1 "cd ~/Downloads/ && youtube-dl --add-metadata -ic $1" && tmux select-pane -U
|
|
||||||
else
|
|
||||||
cd ~/Downloads/;
|
|
||||||
setsid nohup youtube-dl --add-metadata -ic $1 &> /dev/null &
|
|
||||||
fi
|
|
||||||
#+end_src
|
|
||||||
* Org-Protocol-Capture-HTML
|
* Org-Protocol-Capture-HTML
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle ~/scripts/org-protocol-capture-html.sh
|
:header-args: :tangle ~/scripts/org-protocol-capture-html.sh
|
||||||
@ -446,79 +307,25 @@ Send to Emacs
|
|||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
emacsclient "org-protocol://capture?template=$template&url=$url&title=$heading&body=$body"
|
emacsclient "org-protocol://capture?template=$template&url=$url&title=$heading&body=$body"
|
||||||
#+end_src
|
#+end_src
|
||||||
* Pdf Shrink
|
|
||||||
|
* Restart Mopidy
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:header-args: :tangle ~/scripts/pdf-shrink.sh
|
:header-args: :tangle ~/scripts/mopidy-restart.sh
|
||||||
:header-args+: :comments both :mkdirp yes
|
:header-args+: :comments both :mkdirp yes
|
||||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
#+begin_src bash
|
#+begin_src bash
|
||||||
shrink ()
|
pids=( $(pgrep -f mopidy) )
|
||||||
{
|
|
||||||
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 ()
|
for pid in "${pids[@]}"; do
|
||||||
{
|
if [[ $pid != $$ ]]; then
|
||||||
# If $1 and $2 are regular files, we can compare file sizes to
|
kill "$pid"
|
||||||
# see if we succeeded in shrinking. If not, we copy $1 over $2:
|
|
||||||
if [ ! -f "$1" -o ! -f "$2" ]; then
|
|
||||||
return 0;
|
|
||||||
fi
|
fi
|
||||||
ISIZE="$(echo $(wc -c "$1") | cut -f1 -d\ )"
|
done
|
||||||
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 "Killed mopidy."
|
||||||
{
|
echo "Restarting mopidy..."
|
||||||
echo "Reduces PDF filesize by lossy recompressing with Ghostscript."
|
mopidy --config ~/.config/mopidy/mopidy.conf >/dev/null 2>&1 &
|
||||||
echo "Not guaranteed to succeed, but usually works."
|
echo "Done"
|
||||||
echo " Usage: $1 infile [outfile] [resolution_in_dpi]"
|
|
||||||
}
|
|
||||||
|
|
||||||
IFILE="$1"
|
|
||||||
|
|
||||||
# Need an input file:
|
|
||||||
if [ -z "$IFILE" ]; then
|
|
||||||
usage "$0"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Output filename defaults to "-" (stdout) unless given:
|
|
||||||
if [ ! -z "$2" ]; then
|
|
||||||
OFILE="$2"
|
|
||||||
else
|
|
||||||
OFILE="-"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Output resolution defaults to 72 unless given:
|
|
||||||
if [ ! -z "$3" ]; then
|
|
||||||
res="$3"
|
|
||||||
else
|
|
||||||
res="90"
|
|
||||||
fi
|
|
||||||
|
|
||||||
shrink "$IFILE" "$OFILE" "$res" || exit $?
|
|
||||||
|
|
||||||
check_smaller "$IFILE" "$OFILE"
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
Loading…
Reference in New Issue
Block a user