update theme
This commit is contained in:
468
binaries.org
468
binaries.org
@@ -5,123 +5,6 @@
|
||||
#+PROPERTY: header-args:bash+ :shebang "#!/usr/bin/env bash"
|
||||
#+PROPERTY: header-args:bash+ :tangle-mode (identity #o555)
|
||||
|
||||
* =dmenumount= - Mount USB and Android
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: dmenumount
|
||||
:END:
|
||||
|
||||
Script taken from Luke Smith.
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/dmenumount
|
||||
getmount() { \
|
||||
[ -z "$chosen" ] && exit 1
|
||||
# shellcheck disable=SC2086
|
||||
mp="$(find $1 2>/dev/null | dmenu -i -p "Type in mount point.")" || exit 1
|
||||
[ "$mp" = "" ] && exit 1
|
||||
if [ ! -d "$mp" ]; then
|
||||
mkdiryn=$(printf "No\\nYes" | dmenu -i -p "$mp does not exist. Create it?") || exit 1
|
||||
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || sudo -A mkdir -p "$mp")
|
||||
fi
|
||||
}
|
||||
|
||||
mountusb() { \
|
||||
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?")" || exit 1
|
||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||
sudo -A mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
|
||||
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not ( -path *%s -prune ) ",$3}')
|
||||
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
|
||||
partitiontype="$(lsblk -no "fstype" "$chosen")"
|
||||
case "$partitiontype" in
|
||||
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
|
||||
,*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
|
||||
esac
|
||||
notify-send "💻 USB mounting" "$chosen mounted to $mp."
|
||||
}
|
||||
|
||||
mountandroid() { \
|
||||
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
|
||||
chosen="$(echo "$chosen" | cut -d : -f 1)"
|
||||
getmount "$HOME -maxdepth 3 -type d"
|
||||
simple-mtpfs --device "$chosen" "$mp"
|
||||
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
|
||||
simple-mtpfs --device "$chosen" "$mp"
|
||||
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Mount a USB drive or Android device?")" || exit 1
|
||||
case $choice in
|
||||
USB) mountusb ;;
|
||||
Android) mountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
anddrives=$(simple-mtpfs -l 2>/dev/null)
|
||||
usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
|
||||
|
||||
if [ -z "$usbdrives" ]; then
|
||||
[ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit
|
||||
echo "Android device(s) detected."
|
||||
mountandroid
|
||||
else
|
||||
if [ -z "$anddrives" ]; then
|
||||
echo "USB drive(s) detected."
|
||||
mountusb
|
||||
else
|
||||
echo "Mountable USB drive(s) and Android device(s) detected."
|
||||
asktype
|
||||
fi
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* =dmenuumount= - Unmount USB and Android devices
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: dmenuumount
|
||||
:END:
|
||||
|
||||
Script taken from Luke Smith.
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/dmenuumount
|
||||
unmountusb() {
|
||||
[ -z "$drives" ] && exit
|
||||
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
||||
chosen="$(echo "$chosen" | awk '{print $1}')"
|
||||
[ -z "$chosen" ] && exit
|
||||
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
|
||||
}
|
||||
|
||||
unmountandroid() { \
|
||||
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
|
||||
[ -z "$chosen" ] && exit
|
||||
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
|
||||
}
|
||||
|
||||
asktype() { \
|
||||
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1
|
||||
case "$choice" in
|
||||
USB) unmountusb ;;
|
||||
Android) unmountandroid ;;
|
||||
esac
|
||||
}
|
||||
|
||||
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
||||
|
||||
if ! grep simple-mtpfs /etc/mtab; then
|
||||
[ -z "$drives" ] && echo "No drives to unmount." && exit
|
||||
echo "Unmountable USB drive detected."
|
||||
unmountusb
|
||||
else
|
||||
if [ -z "$drives" ]
|
||||
then
|
||||
echo "Unmountable Android device detected."
|
||||
unmountandroid
|
||||
else
|
||||
echo "Unmountable USB drive(s) and Android device(s) detected."
|
||||
asktype
|
||||
fi
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* =dmenukill= - Kill program using Dmenu
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: dmenukill
|
||||
@@ -135,7 +18,7 @@ if [ ! -z "$ps_line" ]; then
|
||||
name=$(echo $ps_line | awk '{print $4}')
|
||||
|
||||
kill -15 $pid && \
|
||||
notify-send "Kill" "$name (PID $pid)" &
|
||||
dunstify "Kill" "$name (PID $pid)" &
|
||||
fi
|
||||
|
||||
#+end_src
|
||||
@@ -147,19 +30,21 @@ fi
|
||||
|
||||
To use this this, =nordvpn= must be installed: =yay -S nordvpn-bin=.
|
||||
|
||||
In order to populate the country list, =nordvpn countries | tr '\t' '\n' | sed -r '/^\s*$/d' > ~/.local/data/nordvpn_countries.txt=.
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/nordvpn-toggle
|
||||
tmpfile="/tmp/vpnstatus";
|
||||
|
||||
if [[ $(nordvpn status) == *"Connected"* ]]; then
|
||||
nordvpn disconnect && \
|
||||
notify-send "VPN" "Disconnected" && \
|
||||
dunstify --replace=23198 "VPN" "Disconnected" && \
|
||||
echo "off" > $tmpfile;
|
||||
else
|
||||
# Select Country to connect to
|
||||
country=`cat ~/.local/data/nordvpn_countries.txt | rofi -i -dmenu | sed 's/\s/_/g'`;
|
||||
notify-send "VPN" "Connecting to $country...";
|
||||
dunstify --replace=23198 "VPN" "Connecting to $country...";
|
||||
nordvpn connect $country && \
|
||||
notify-send "VPN" "Connected to $country" && \
|
||||
dunstify --replace=23198 "VPN" "Connected to $country" && \
|
||||
echo "on" > $tmpfile;
|
||||
fi
|
||||
#+end_src
|
||||
@@ -254,7 +139,7 @@ if [[ $status != "Copy" ]]; then
|
||||
if [ -z "$name" ]; then
|
||||
exit;
|
||||
fi
|
||||
filename=~/Pictures/$name.png
|
||||
filename=~/Cloud/pictures/screenshots/$name.png
|
||||
fi
|
||||
|
||||
case "$status" in
|
||||
@@ -322,10 +207,10 @@ ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/yt-audio
|
||||
if [ $TMUX ]; then
|
||||
tmux split -v -l 5 "cd ~/Downloads/ && youtube-dl --add-metadata -xic -f bestaudio/best $1" && tmux select-pane -U
|
||||
tmux split -v -l 5 "cd ~/Downloads/ && yt-dlp --add-metadata -xic --audio-format best $1" && tmux select-pane -U
|
||||
else
|
||||
cd ~/Downloads/;
|
||||
setsid nohup youtube-dl --add-metadata -xic -f bestaudio/best $1 &> /dev/null &
|
||||
setsid nohup yt-dlp --add-metadata -xic --audio-format flac $1 &> /dev/null &
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
@@ -336,12 +221,13 @@ fi
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/yt-video
|
||||
if [ $TMUX ]; then
|
||||
tmux split -v -l 5 "cd ~/Downloads/ && youtube-dl --add-metadata -ic $1" && tmux select-pane -U
|
||||
tmux split -v -l 5 "cd ~/Downloads/ && yt-dlp --add-metadata -ic $1" && tmux select-pane -U
|
||||
else
|
||||
cd ~/Downloads/;
|
||||
setsid nohup youtube-dl --add-metadata -ic $1 &> /dev/null &
|
||||
setsid nohup yt-dlp --add-metadata -ic $1 &> /dev/null &
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* =setbg= - Set Background
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: setbg
|
||||
@@ -384,7 +270,7 @@ if [ -n "$1" ]; then
|
||||
xdotool key Shift+Insert
|
||||
else
|
||||
echo "$chosen" | tr -d '\n' | xsel -ib
|
||||
notify-send "'$chosen' copied to clipboard." &
|
||||
dunstify "'$chosen' copied to clipboard." &
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
@@ -408,7 +294,7 @@ if [ -n "$1" ]; then
|
||||
xdotool key Shift+Insert
|
||||
else
|
||||
echo "$chosen" | tr -d '\n' | xsel -ib
|
||||
notify-send "'$chosen' copied to clipboard." &
|
||||
dunstify "'$chosen' copied to clipboard." &
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
@@ -432,6 +318,8 @@ case "$1" in
|
||||
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
|
||||
,*svg)
|
||||
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && inkview "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
|
||||
,*torrent)
|
||||
stig add "$1" >/dev/null 2>&1 & ;;
|
||||
,*mp3|*flac|*opus|*mp3?source*)
|
||||
setsid curl -LO "$1" >/dev/null 2>&1 & ;;
|
||||
,*)
|
||||
@@ -519,8 +407,8 @@ if [ $TMUX ]; then
|
||||
tmux split -v -l 1 "curl --progress-bar -F\"file=@$1\" https://0x0.st | xsel -ib;" && tmux select-pane -U
|
||||
else
|
||||
curl --progress-bar -F"file=@$1" https://0x0.st | xsel -ib && \
|
||||
notify-send 'Upload' 'Successful' || \
|
||||
notify-send --urgency=critical 'Upload' 'Failed'
|
||||
dunstify 'Upload' 'Successful' || \
|
||||
dunstify --urgency=critical 'Upload' 'Failed'
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
@@ -553,54 +441,7 @@ else
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* =pdf2bib= - Extract bibtex entry from PDF file
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: pdf2bib
|
||||
:END:
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/pdf2bib
|
||||
pdf2doi () {
|
||||
pdfinfo "$1" | grep -io "doi:.*" | grep -Poi "10.\d+/[^\s]+" || \
|
||||
pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1 | grep -Poi "10.\d+/[^\s]+" || \
|
||||
pdftotext "$1" 2>/dev/null - | grep -Poi "10.\d+/[^\s]+"
|
||||
}
|
||||
|
||||
doi2bib () {
|
||||
# curl -LHs "Accept: application/x-bibtex" http://dx.doi.org/$1 -w "\\n"
|
||||
curl -s "http://api.crossref.org/works/$1/transform/application/x-bibtex" -w "\\n"
|
||||
}
|
||||
|
||||
# If a file is specified, try to extract DOI from the file
|
||||
if [ -f "$1" ]; then
|
||||
doi=$(pdf2doi "$1")
|
||||
fi
|
||||
|
||||
if hash rofi 2>/dev/null; then
|
||||
doi=$(echo "$doi" | rofi -i -dmenu -p "DOI")
|
||||
else
|
||||
doi=$(echo "$doi" | dmenu -i -p "DOI")
|
||||
fi
|
||||
|
||||
if [ -n "$1" ]; then
|
||||
doi2bib $doi | xsel -ib && \
|
||||
notify-send 'BibTeX' 'Copied to Clipboard' || \
|
||||
notify-send --urgency=critical 'BibTeX' 'Failed'
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* =pdf2png= - Convert a PDF to PNG
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: pdf2png
|
||||
:END:
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/pdf2png
|
||||
# Check if the input argumetn is a PDF file
|
||||
if [[ -f "$1" && "$1" == *.pdf ]]; then
|
||||
pdftoppm -png "$1" > "$(echo "$1" | cut -f 1 -d '.' | sed 's/$/.png/')"
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* TODO =convert-file= - Convert any file to another filetype
|
||||
* =convert-file= - Convert any file to another filetype
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: convert-file
|
||||
:header-args: :tangle ~/.local/bin/convert-file
|
||||
@@ -612,6 +453,8 @@ fi
|
||||
filename_with_extension=$(basename -- "$1")
|
||||
# Extract extension of the file
|
||||
in_ext="${filename_with_extension##*.}"
|
||||
# To lowercase
|
||||
in_ext="${in_ext,,}"
|
||||
# filename without extension
|
||||
filename_without_extension=${filename_with_extension%.*}
|
||||
#+end_src
|
||||
@@ -624,7 +467,7 @@ List of useful programs:
|
||||
#+begin_src bash
|
||||
svg2png_function() { \
|
||||
if command -v inkscape &> /dev/null; then
|
||||
inkscape --export-type="$out_ext" --export-dpi=200 --export-area-drawing "$filename_with_extension"
|
||||
inkscape --export-type="png" --export-filename="$filename_without_extension.png" --export-dpi=500 --export-area-drawing "$filename_with_extension"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
@@ -633,7 +476,7 @@ svg2png_function() { \
|
||||
#+begin_src bash
|
||||
svg2pdf_function() { \
|
||||
if command -v inkscape &> /dev/null; then
|
||||
inkscape --export-type="$out_ext" "$filename_with_extension"
|
||||
inkscape --export-type="pdf" --export-filename="$filename_without_extension.pdf" "$filename_with_extension"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
@@ -890,11 +733,22 @@ gif2png_function() { \
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** GIF to mp4
|
||||
#+begin_src bash
|
||||
gif2mp4_function() { \
|
||||
if command -v ffmpeg &> /dev/null; then
|
||||
loop_num=$(rofi -dmenu -p "Number of loops")
|
||||
|
||||
ffmpeg -stream_loop $loop_num -i $filename_with_extension -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" "$filename_without_extension.mp4"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** Main function
|
||||
#+begin_src bash
|
||||
# Convert GIF Files
|
||||
gif2() { \
|
||||
out_ext=$(echo -e "png" | rofi -i -dmenu -p "Convert GIF to")
|
||||
out_ext=$(echo -e "png\nmp4" | rofi -i -dmenu -p "Convert GIF to")
|
||||
|
||||
if [ -z "$out_ext" ]; then
|
||||
exit;
|
||||
@@ -904,6 +758,9 @@ gif2() { \
|
||||
"png")
|
||||
gif2png_function
|
||||
;;
|
||||
"mp4")
|
||||
gif2mp4_function
|
||||
;;
|
||||
esac
|
||||
}
|
||||
#+end_src
|
||||
@@ -952,11 +809,20 @@ pngresize_function() { \
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** PNG Crop
|
||||
#+begin_src bash
|
||||
pngcrop_function() { \
|
||||
if command -v cropgui &> /dev/null; then
|
||||
cropgui "$filename_with_extension"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** Main function
|
||||
#+begin_src bash
|
||||
# Convert PNG Files
|
||||
png2() { \
|
||||
out_ext=$(echo -e "pdf\njpg\ntrim\nresize" | rofi -i -dmenu -p "Convert PNG to")
|
||||
out_ext=$(echo -e "pdf\njpg\ntrim\nresize\ncrop" | rofi -i -dmenu -p "Convert PNG to")
|
||||
|
||||
if [ -z "$out_ext" ]; then
|
||||
exit;
|
||||
@@ -969,6 +835,9 @@ png2() { \
|
||||
"jpg")
|
||||
png2jpg_function
|
||||
;;
|
||||
"crop")
|
||||
pngcrop_function
|
||||
;;
|
||||
"trim")
|
||||
pngtrim_function
|
||||
;;
|
||||
@@ -989,6 +858,15 @@ jpg2pdf_function() { \
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** JPG to PNG
|
||||
#+begin_src bash
|
||||
jpg2png_function() { \
|
||||
if command -v convert &> /dev/null; then
|
||||
convert "$filename_with_extension" "$filename_without_extension.png"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** JPG Resize
|
||||
#+begin_src bash
|
||||
jpgresize_function() { \
|
||||
@@ -1005,11 +883,39 @@ jpgresize_function() { \
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** JPG Rotate
|
||||
#+begin_src bash
|
||||
jpgrotate_function() { \
|
||||
if command -v convert &> /dev/null; then
|
||||
# convert "$filename_with_extension" -rotate 90 /tmp/output.jpg && mv /tmp/output.jpg "$filename_with_extension"
|
||||
convert "$filename_with_extension" -rotate 90 "$filename_with_extension"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** JPG Trim
|
||||
#+begin_src bash
|
||||
jpgtrim_function() { \
|
||||
if command -v convert &> /dev/null; then
|
||||
convert -trim "$filename_with_extension" "$filename_with_extension"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** JPG Crop
|
||||
#+begin_src bash
|
||||
jpgcrop_function() { \
|
||||
if command -v cropgui &> /dev/null; then
|
||||
cropgui "$filename_with_extension"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** Main function
|
||||
#+begin_src bash
|
||||
# Convert JPG Files
|
||||
jpg2() { \
|
||||
out_ext=$(echo -e "pdf\nresize" | rofi -i -dmenu -p "Convert JPG to")
|
||||
out_ext=$(echo -e "pdf\npng\nresize\ncrop\ntrim\nrotate" | rofi -i -dmenu -p "Convert JPG to")
|
||||
|
||||
if [ -z "$out_ext" ]; then
|
||||
exit;
|
||||
@@ -1019,9 +925,49 @@ jpg2() { \
|
||||
"pdf")
|
||||
jpg2pdf_function
|
||||
;;
|
||||
"png")
|
||||
jpg2png_function
|
||||
;;
|
||||
"resize")
|
||||
jpgresize_function
|
||||
;;
|
||||
"crop")
|
||||
jpgcrop_function
|
||||
;;
|
||||
"trim")
|
||||
jpgtrim_function
|
||||
;;
|
||||
"rotate")
|
||||
jpgrotate_function
|
||||
;;
|
||||
esac
|
||||
}
|
||||
#+end_src
|
||||
|
||||
** XOPP files
|
||||
*** XOPP to PDF
|
||||
#+begin_src bash
|
||||
xopp2pdf_function() { \
|
||||
if command -v xournalpp &> /dev/null; then
|
||||
xournalpp -p "$filename_without_extension.pdf" "$filename_with_extension"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** Main function
|
||||
#+begin_src bash
|
||||
# Convert XOPP Files
|
||||
xopp2() { \
|
||||
out_ext=$(echo -e "pdf" | rofi -i -dmenu -p "Convert XOPP to")
|
||||
|
||||
if [ -z "$out_ext" ]; then
|
||||
exit;
|
||||
fi
|
||||
|
||||
case "$out_ext" in
|
||||
"pdf")
|
||||
xopp2pdf_function
|
||||
;;
|
||||
esac
|
||||
}
|
||||
#+end_src
|
||||
@@ -1048,11 +994,20 @@ mp42gif_function() { \
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** MP4 remove sound
|
||||
#+begin_src bash
|
||||
mp4nosound_function() { \
|
||||
if command -v ffmpeg &> /dev/null; then
|
||||
ffmpeg -i "$filename_with_extension" -c copy -an "$filename_without_extension-nosound.mp4"
|
||||
fi
|
||||
}
|
||||
#+end_src
|
||||
|
||||
*** Main function
|
||||
#+begin_src bash
|
||||
# Convert MP4 Files
|
||||
mp42() { \
|
||||
out_ext=$(echo -e "gif" | rofi -i -dmenu -p "Convert MP4 to")
|
||||
out_ext=$(echo -e "gif\nremove sound" | rofi -i -dmenu -p "Convert MP4 to")
|
||||
|
||||
if [ -z "$out_ext" ]; then
|
||||
exit;
|
||||
@@ -1062,6 +1017,9 @@ mp42() { \
|
||||
"gif")
|
||||
mp42gif_function
|
||||
;;
|
||||
"remove sound")
|
||||
mp4nosound_function
|
||||
;;
|
||||
esac
|
||||
}
|
||||
#+end_src
|
||||
@@ -1096,9 +1054,12 @@ case "$in_ext" in
|
||||
"docx")
|
||||
docx2
|
||||
;;
|
||||
"pttx")
|
||||
"pptx")
|
||||
docx2
|
||||
;;
|
||||
"xopp")
|
||||
xopp2
|
||||
;;
|
||||
esac
|
||||
#+end_src
|
||||
|
||||
@@ -1107,6 +1068,7 @@ esac
|
||||
:CUSTOM_ID: preview-file
|
||||
:header-args: :tangle ~/.local/bin/preview-file
|
||||
:END:
|
||||
|
||||
** Get basic information about the file
|
||||
#+begin_src bash
|
||||
# Get filename
|
||||
@@ -1175,129 +1137,6 @@ case "$in_ext" in
|
||||
esac
|
||||
#+end_src
|
||||
|
||||
* =pdf-shrink= - Pdf Shrink
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: pdf-shrink
|
||||
:END:
|
||||
|
||||
Simply reduces the size of a given pdf file.
|
||||
|
||||
#+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"
|
||||
}
|
||||
|
||||
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 90 unless given:
|
||||
if [ ! -z "$3" ]; then
|
||||
res="$3"
|
||||
else
|
||||
res="90"
|
||||
fi
|
||||
|
||||
shrink "$IFILE" "$OFILE" "$res" || exit $?
|
||||
|
||||
check_smaller "$IFILE" "$OFILE"
|
||||
#+end_src
|
||||
* =pdf-delete-annotations= - Delete Annotations from PDFs
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: pdf-delete-annotations
|
||||
:END:
|
||||
|
||||
Taken from this [[https://gist.github.com/stefanschmidt/5248592][gist]].
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/pdf-delete-annotations
|
||||
# Check if the input argumetn is a PDF file
|
||||
if [[ -f "$1" && "$1" == *.pdf ]]; then
|
||||
pdftk $1 output /tmp/uncompressed.pdf uncompress
|
||||
LANG=C sed -n '/^\/Annots/!p' /tmp/uncompressed.pdf > /tmp/stripped.pdf
|
||||
pdftk /tmp/stripped.pdf output $1 compress
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* =pdf-delete-first-page= - Delete first page of PDF
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: pdf-delete-first-page
|
||||
:END:
|
||||
|
||||
The requirement is to have =pdftk= or =stapler= installed.
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/pdf-delete-first-page
|
||||
# Check if the input argumetn is a PDF file
|
||||
if [[ -f $1 && $1 == *.pdf ]]; then
|
||||
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
|
||||
|
||||
* =rofi-calc= - Simple Calculation using Rofi
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: rofi-calc
|
||||
:END:
|
||||
|
||||
Run some simple calculations with =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
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: pass-gen
|
||||
@@ -1317,7 +1156,7 @@ fi
|
||||
|
||||
# Send the password to the clipboard
|
||||
printf "$pass" | xclip -sel clip && \
|
||||
notify-send 'Password' 'Generated'
|
||||
dunstify 'Password' 'Generated'
|
||||
#+end_src
|
||||
|
||||
* =sxhkd-help= - List of keybindings using Rofi
|
||||
@@ -1332,11 +1171,10 @@ awk '/^[a-z]/ && last {print "<small>",$0,"\t",last,"</small>"} {last=""} /^#/{l
|
||||
#+end_src
|
||||
|
||||
* =qrdecode= - Decode QRcode by taking screenshot
|
||||
|
||||
- =zbar-tools=
|
||||
- =main=
|
||||
- =xclip=
|
||||
- =notify-send=
|
||||
To install:
|
||||
#+begin_src bash :tangle no
|
||||
paru -S zbar maim xclip dunstify
|
||||
#+end_src
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/qrdecode
|
||||
image_file="/tmp/ocr.png"
|
||||
@@ -1366,7 +1204,7 @@ fi
|
||||
printf %b "$decoded_text" | xclip -selection clip
|
||||
|
||||
# Let us know that something was decoded
|
||||
notify-send "qrshot" "$decoded_text"
|
||||
dunstify "qrshot" "$decoded_text"
|
||||
|
||||
# Cleaning up the trash that was left behind
|
||||
rm $image_file
|
||||
|
||||
Reference in New Issue
Block a user