diff --git a/binaries-private.org b/binaries-private.org index 1cf18ea..eb9672c 100644 --- a/binaries-private.org +++ b/binaries-private.org @@ -10,16 +10,57 @@ :CUSTOM_ID: phonebook :END: -The phone-list is taken from =scp rnice@esrf.fr:/mnt/multipath-shares/sware/pub/phonelist/share/annuaire.txt /home/thomas/.local/data/annuaire.txt= +*Old phonebook*: The phone-list is taken from =scp rnice@esrf.fr:/mnt/multipath-shares/sware/pub/phonelist/share/annuaire.txt /home/thomas/.local/data/annuaire.txt= +*new phonebook*: Use the =etd= script #+begin_src bash :tangle ~/.local/bin/phonebook -cat ~/.local/data/annuaire.txt | fzf --header="NAME Phone Box department roomNumber description mail" +cat ~/.local/data/annuaire.txt | fzf --header="NAME Surname Phone Office Room Email" #+end_src #+begin_src bash :tangle ~/.local/bin/phonebook-gui $TERMINAL --title esrf-phonebook -e phonebook #+end_src +#+begin_src bash :tangle ~/.local/bin/etd +#!/bin/bash + +ROOT_URL='https://phonedirectory.esrf.fr' +API_ENDPOINT="$ROOT_URL/api" +USAGE=" + ESRF Telephone Directory + + CLI to search $ROOT_URL + + Usage : + # Search for in first name or last name + $0 + +" + +function fail { + echo "$1" >&2 + exit 1 +} + +function json_curl { curl --get --fail --silent --show-error -H "Content-Type:application/json" -H "Accept: application/json" "$@"; } + +function lspersons { + # List users and output result in csv + json_curl --data-urlencode "search=$1" "$API_ENDPOINT/searchUsers" |\ + jq -r '. | (map(keys) | add | unique | sort) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $rows[] | @csv' 2>/dev/null +} + +if [ $# -eq 0 ]; then + fail "$USAGE" +fi + +# Print the list of persons as a table + +lspersons $1 | awk 'BEGIN { FS=OFS="," }; {print $4,$3,$5,$1,$6,$2,$7}' | sed 's/"//g' | column -t -s "," | sort + +exit $? +#+end_src + * =contacts= Personnal phone-book :PROPERTIES: :CUSTOM_ID: contacts @@ -39,7 +80,7 @@ $TERMINAL --title esrf-phonebook -e contacts :END: #+begin_src bash :tangle ~/.local/bin/remote-desktop -computer=$(echo -e 'WID16A1\nWID21SPEEDGOAT1\nWID24SPEEDGOAT1\nWBM23SPEEDGOAT1\nWMELSPEEDGOAT1\nWID31PC1\nPCOPTRO\nPCMEL1\nRNICE\nPCDEHAEZE\nLAPMEL01\nDesktop-W10' | rofi -i -dmenu -no-custom -p 'Computer:' -l 20); +computer=$(echo -e 'PCOPTRO\nPCMEL1\nRNICE\nPCDEHAEZE\nLAPMEL01\nZOTAC' | rofi -i -dmenu -p 'Computer:' -l 20); if [[ -z "$computer" ]]; then exit 1 @@ -48,9 +89,9 @@ fi dunstify --replace=99425 'Rdesktop' "Connection to ${computer}..." proxy_arg="" -if [ "$computer" = "Desktop-W10" ]; then +if [ "$computer" = "ZOTAC" ]; then # If connect to local PC - ping -c 1 desktop-w10.lan &> /dev/null + ping -c 1 openwrt.lan &> /dev/null if [ $? -ne 0 ]; then # And outside of local network, use proxy proxy_arg="/proxy:socks5://localhost:8080" @@ -63,35 +104,43 @@ else fi fi -common_arg="/clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /wm-class:RDP_$computer -grab-keyboard /cert:ignore" +common_arg="/clipboard /bpp:32 /compression -themes -wallpaper /audio-mode:1 /dynamic-resolution /auto-reconnect /wm-class:RDP_$computer -grab-keyboard /cert:ignore /rfx /gfx:avc444" case "$computer" in "RNICE" | "PCDEHAEZE") - xfreerdp $proxy_arg $common_arg /d:ESRF /u:dehaeze /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; + xfreerdp3 $proxy_arg $common_arg /d:ESRF /u:dehaeze /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; "PCMEL1" | "PCOPTRO" | "LAPMEL01") - xfreerdp $proxy_arg $common_arg /d:ESRF /u:OPPEL /p:TonicPEL /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; + xfreerdp3 $proxy_arg $common_arg /d:ESRF /u:OPPEL /p:$(pass esrf.fr/oppel | sed -n 1p) /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; - "WMELSPEEDGOAT1") - xfreerdp $proxy_arg $common_arg /d:ESRF /u:opd23 /p:tonic23 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; + "ZOTAC") + xfreerdp3 $proxy_arg $common_arg /u:thomas /p:$(pass windows/zotac | sed -n 1p) /v:192.168.5.75 > /tmp/freerdp_${computer}.log 2>&1 & ;; - "WID16A1") - xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid16a /p:tonic16 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; + *) + user=$(rofi -dmenu -p 'User:'); + password=$(rofi -dmenu -p 'Password:'); + xfreerdp3 $proxy_arg $common_arg /u:$user /p:$password /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; - "WID31PC1") - xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid31 /p:tonic31 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; +esac +#+end_src - "WID21SPEEDGOAT1") - xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid21 /p:tonic21 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; +* =wake-on-lan= - Wake on LAN +:PROPERTIES: +:CUSTOM_ID: wake-on-lan +:END: - "WID24SPEEDGOAT1") - xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid24 /p:tonic24 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; +#+begin_src bash :tangle ~/.local/bin/wake-on-lan +computer=$(echo -e 'ZOTAC' | rofi -i -dmenu -p 'Computer:' -l 20); - "WBM23SPEEDGOAT1") - xfreerdp $proxy_arg $common_arg /d:ESRF /u:opd23 /p:tonic23 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;; +if [[ -z "$computer" ]]; then + exit 1 +fi - "Desktop-W10") - xfreerdp $proxy_arg $common_arg /u:thomas /p:$(pass windows/Desktop-W10 | sed -n 1p) /v:192.168.1.72 > /tmp/freerdp_${computer}.log 2>&1 & ;; +dunstify --replace=99425 'Wake On Lan' "${computer}..." + +case "$computer" in + "ZOTAC") + ssh homelab 'wakeonlan 00:01:2E:A2:42:9C' ;; esac #+end_src @@ -155,7 +204,9 @@ fi #+begin_src bash :tangle ~/.local/bin/mount-dir if [ $# -eq 0 ]; then - drive=$(find ~/mnt/* -maxdepth 0 -type d -empty -printf '%f\n' | rofi -i -dmenu -no-custom -p 'Drive:' -l 20); + # Takes a lot of time with "tmp_14_days" is mounted + # drive=$(find ~/mnt/* -maxdepth 0 -type d -empty -printf '%f\n' | rofi -i -dmenu -no-custom -p 'Drive:' -l 20); + drive=$(ls ~/mnt | rofi -i -dmenu -no-custom -p 'Drive:' -l 20); if [[ -z "$drive" ]]; then exit 1 fi @@ -181,7 +232,7 @@ case "$drive" in "monochromators") remote_loc="dehaeze@rnice$proxy_arg:/data/monochromators/" ;; "data_mel") - remote_loc="opid00@lmellab$proxy_arg:/data/id00/inhouse/" ;; + remote_loc="opid00@lmelcontrol$proxy_arg:/data/id00/inhouse/" ;; "data_jazzy") remote_loc="dehaeze@rnice$proxy_arg:/gpfs/jazzy/data/" ;; "data_easy") @@ -190,12 +241,16 @@ case "$drive" in remote_loc="blissadm@pico3$proxy_arg:/data/id16a/inhouse1/commissioning/ni_endstation/Speedgoat/" ;; "data_id31") remote_loc="opid31@id31$proxy_arg:/data/id31/inhouse/" ;; + "data_id24") + remote_loc="dehaeze@rnice$proxy_arg:/gpfs/gb/data/id24-dcm/inhouse" ;; "bliss_mel") - remote_loc="blissadm@lmellab$proxy_arg:/users/blissadm/local/" ;; + remote_loc="blissadm@lmelcontrol$proxy_arg:/users/blissadm/local/" ;; "bliss_id16a") - remote_loc="blissadm@pico3$proxy_arg:/users/blissadm/local/" ;; + remote_loc="blissadm@id16a$proxy_arg:/users/blissadm/local/" ;; "bliss_id21") - remote_loc="blissadm@lid21nano$proxy_arg:/users/blissadm/local/" ;; + remote_loc="blissadm@id21$proxy_arg:/users/blissadm/local/" ;; + "bliss_bm23") + remote_loc="blissadm@bm23$proxy_arg:/users/blissadm/local/" ;; "bliss_id24") remote_loc="blissadm@foucault$proxy_arg:/users/blissadm/local/" ;; "groupshare") @@ -214,8 +269,9 @@ fi #+begin_src bash :tangle ~/.local/bin/umount-dir if [ $# -eq 0 ]; then - # drive=$(find ~/mnt/* -maxdepth 0 -type d -not -empty -printf '%f\n' | rofi -dmenu -no-custom -p 'Drive:' -l 20); - drive=$(ls ~/mnt/ | rofi -dmenu -no-custom -p 'Drive:' -l 20); + # Takes a lot of time with tmp_14_days is mounted... + # drive=$(ls ~/mnt/ | rofi -dmenu -no-custom -p 'Drive:' -l 20); + drive=$(find ~/mnt/* -maxdepth 0 -type d -not -empty -printf '%f\n' | rofi -dmenu -no-custom -p 'Drive:' -l 20); if [[ -z "$drive" ]]; then exit 1 fi @@ -232,7 +288,7 @@ umount /home/thomas/mnt/$drive :END: #+begin_src bash :tangle ~/.local/bin/screen-select -option=$(echo -e "Work\nLaptop\nHome" | rofi -i -dmenu -no-custom -p 'Screen:' -l 20) +option=$(echo -e "Work\nLaptop\nHome\nAouste" | rofi -i -dmenu -no-custom -p 'Screen:' -l 20) if [[ -z "$option" ]]; then exit 1 @@ -255,17 +311,31 @@ after_screen_change () { case "$option" in "Work") xrandr --output eDP-1 --off \ - --output DP-3-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal \ - --output DP-3-1 --primary --mode 2560x1440 --pos 2560x0 --rotate normal && \ - after_screen_change + --output DP-3-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal \ + --output DP-3-1 --primary --mode 2560x1440 --pos 2560x0 --rotate normal && \ + after_screen_change ;; "Laptop") - xrandr --output DP-1-2 --off --output DP-3-1 --off --output DP-3-2 --off --output eDP-1 --primary --mode 1920x1200 --pos 0x0 --rotate normal && \ - after_screen_change + xrandr --output DP-1-1 --off \ + --output DP-1-2 --off \ + --output DP-3-1 --off \ + --output DP-3-2 --off \ + --output HDMI-1 --off \ + --output eDP-1 --primary --mode 1920x1200 --pos 0x0 --rotate normal && \ + after_screen_change ;; "Home") - xrandr --output eDP-1 --off --output DP-3-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \ - after_screen_change + xrandr --output eDP-1 --off \ + --output DP-3-1 --off \ + --output DP-3-2 --off \ + --output HDMI-1 --off \ + --output DP-1-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \ + after_screen_change + ;; + "Aouste") + xrandr --output eDP-1 --off \ + --output HDMI-1 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \ + after_screen_change ;; ,*) echo "== ! missing or invalid argument ! ==" @@ -280,6 +350,8 @@ exit 0 :CUSTOM_ID: print-esrf :END: +- To list printers =lpstat -p -d= + #+begin_src bash :tangle ~/.local/bin/print-esrf nbpage=$(echo -e '1\n2\n4' | rofi -dmenu -no-custom -p 'Number of pages per sheet' -l 20); sides=$(echo -e 'one-sided\ntwo-sided-long-edge\ntwo-sided-short-edge' | rofi -dmenu -no-custom -p 'Two Sided:' -l 20); diff --git a/binaries.org b/binaries.org index ae0ed76..d8ea588 100644 --- a/binaries.org +++ b/binaries.org @@ -250,6 +250,17 @@ bgloc="${XDG_CACHE_HOME:-$HOME/.cache/}/bg" xwallpaper --zoom "$bgloc" #+end_src +* =get-otp= +#+begin_src bash :tangle ~/.local/bin/get-otp +passname=$(ls ~/.local/share/pass/totp-* | xargs -n 1 basename | sed -e 's/\..*$//' | rofi -p "TOPT" -dmenu) + +if [ -n "$passname" ]; then + otpnumber=`pass otp $passname` + echo $otpnumber | xsel -i + dunstify 'OTP' "$otpnumber" & +fi +#+end_src + * =insert-unicode= - Insert Unicode Icon :PROPERTIES: :CUSTOM_ID: insert-unicode @@ -313,7 +324,7 @@ case "$1" in ,*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*gif) setsid mpv -quiet "$1" >/dev/null 2>&1 & ;; ,*png|*jpg|*jpe|*jpeg) - curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && nsxiv -a "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; ,*pdf|*cbz|*cbr) 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) @@ -391,7 +402,7 @@ done echo "Killed mopidy." echo "Restarting mopidy..." -mopidy --config ~/.config/mopidy/mopidy.conf >/dev/null 2>&1 & +~/.local/soft/mopidy-jellyfin/env/bin/mopidy -v >/tmp/mopidy.log 2>&1 & echo "Done" #+end_src @@ -427,11 +438,11 @@ else address="wttr.in/" fi -if type sxiv > /dev/null 2>&1; then +if type nsxiv > /dev/null 2>&1; then address+=".png" wget -qO- "$address" > /tmp/weather.png && \ - sxiv -b /tmp/weather.png + nsxiv -b /tmp/weather.png elif type feh > /dev/null 2>&1; then address+=".png" @@ -463,6 +474,15 @@ filename_without_extension=${filename_with_extension%.*} List of useful programs: - =inkscape= +*** SVG to JPG +#+begin_src bash +svg2jpg_function() { \ + if command -v inkscape &> /dev/null; then + inkscape --export-type="png" --export-filename=- --export-dpi=500 --export-area-drawing "$filename_with_extension" | convert - "$filename_without_extension.jpg" + fi +} +#+end_src + *** SVG to PNG #+begin_src bash svg2png_function() { \ @@ -481,23 +501,38 @@ svg2pdf_function() { \ } #+end_src +*** SVG to EMF +#+begin_src bash +svg2emf_function() { \ + if command -v inkscape &> /dev/null; then + inkscape --export-type="emf" --export-filename="$filename_without_extension.emf" "$filename_with_extension" + fi +} +#+end_src + *** Main function #+begin_src bash # Convert SVG Files svg2() { \ - out_ext=$(echo -e "pdf\npng" | rofi -i -dmenu -p "Convert SVG to") + out_ext=$(echo -e "pdf\njpg\npng\nemf" | rofi -i -dmenu -p "Convert SVG to") if [ -z "$out_ext" ]; then exit; fi case "$out_ext" in + "jpg") + svg2jpg_function + ;; "png") svg2png_function ;; "pdf") svg2pdf_function ;; + "emf") + svg2emf_function + ;; esac } #+end_src @@ -522,7 +557,7 @@ pdf2png_function() { \ elif command -v convert &> /dev/null; then convert -density 100 -trim -antialias "$filename_with_extension" -quality 100 "$filename_without_extension.png" elif command -v inkscape &> /dev/null; then - inkscape --export-type="$out_ext" --export-dpi=200 --export-area-drawing "$filename_with_extension" + inkscape --export-type="$out_ext" --export-dpi=500 --export-area-drawing "$filename_with_extension" fi } #+end_src @@ -540,6 +575,15 @@ pdf2svg_function() { \ } #+end_src +*** PDF to EMF +#+begin_src bash +pdf2emf_function() { \ + if command -v inkscape &> /dev/null; then + inkscape --export-type="emf" --export-filename="$filename_without_extension.emf" "$filename_with_extension" + fi +} +#+end_src + *** PDF Reduce Size #+begin_src bash pdfreduce_function() { \ @@ -615,11 +659,21 @@ pdf_remove_annotations_function() { \ } #+end_src +*** Rasterize +#+begin_src bash +pdf_rasterize_function() { \ + if command -v convert &> /dev/null; then + convert -density 600 +antialias "$filename_with_extension" /tmp/pdf_rasterized.pdf && \ + gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$filename_without_extension.red.pdf" /tmp/pdf_rasterized.pdf + fi +} +#+end_src + *** Main function #+begin_src bash # Convert PDF Files pdf2() { \ - out_ext=$(echo -e "svg\npng\nreduce size\ntrim\nextract pages\ndelete first page\nremove annotations" | rofi -i -dmenu -p "Convert PDF to") + out_ext=$(echo -e "svg\npng\nemf\nreduce size\ntrim\nextract pages\ndelete first page\nrasterize\nremove annotations" | rofi -i -dmenu -p "Convert PDF to") if [ -z "$out_ext" ]; then exit; @@ -629,6 +683,9 @@ pdf2() { \ "svg") pdf2svg_function ;; + "emf") + pdf2emf_function + ;; "png") pdf2png_function ;; @@ -644,6 +701,9 @@ pdf2() { \ "delete first page") pdf_delete_first_page_function ;; + "rasterize") + pdf_rasterize_function + ;; "remove annotations") pdf_remove_annotations_function ;; @@ -797,14 +857,17 @@ pngtrim_function() { \ #+begin_src bash pngresize_function() { \ if command -v convert &> /dev/null; then - size_type=$(echo -e "width\nheight" | rofi -i -dmenu -p "Maximum:") - size_px=$(rofi -dmenu -p "Number of px:") - - if [ "$size_type" = "width" ]; then - convert -resize "$size_px"x "$filename_with_extension" "$filename_with_extension" - elif [ "$size_type" = "height" ]; then - convert -resize x"$size_px" "$filename_with_extension" "$filename_with_extension" - fi + size_type=$(echo -e "width\nheight" | rofi -i -dmenu -p "Maximum:") + size_px=$(rofi -dmenu -p "Number of px:") + # Check if size_px is indeed a number + re='^[0-9]+$' + if [[ $size_px =~ $re ]] ; then + if [ "$size_type" = "width" ]; then + convert -resize "$size_px"x "$filename_with_extension" "$filename_with_extension" + elif [ "$size_type" = "height" ]; then + convert -resize x"$size_px" "$filename_with_extension" "$filename_with_extension" + fi + fi fi } #+end_src @@ -871,14 +934,17 @@ jpg2png_function() { \ #+begin_src bash jpgresize_function() { \ if command -v convert &> /dev/null; then - size_type=$(echo -e "width\nheight" | rofi -i -dmenu -p "Maximum:") - size_px=$(rofi -dmenu -p "Number of px:") - - if [ "$size_type" = "width" ]; then - convert -resize "$size_px"x "$filename_with_extension" "$filename_with_extension" - elif [ "$size_type" = "height" ]; then - convert -resize x"$size_px" "$filename_with_extension" "$filename_with_extension" - fi + size_type=$(echo -e "width\nheight" | rofi -i -dmenu -p "Maximum:") + size_px=$(rofi -dmenu -p "Number of px:") + # Check if size_px is indeed a number + re='^[0-9]+$' + if [[ $size_px =~ $re ]] ; then + if [ "$size_type" = "width" ]; then + convert -resize "$size_px"x "$filename_with_extension" "$filename_with_extension" + elif [ "$size_type" = "height" ]; then + convert -resize x"$size_px" "$filename_with_extension" "$filename_with_extension" + fi + fi fi } #+end_src @@ -893,6 +959,15 @@ jpgrotate_function() { \ } #+end_src +*** JPG Horizontal Flip +#+begin_src bash +jpgfliphor_function() { \ + if command -v convert &> /dev/null; then + convert -flop "$filename_with_extension" "$filename_with_extension" + fi +} +#+end_src + *** JPG Trim #+begin_src bash jpgtrim_function() { \ @@ -915,7 +990,7 @@ jpgcrop_function() { \ #+begin_src bash # Convert JPG Files jpg2() { \ - out_ext=$(echo -e "pdf\npng\nresize\ncrop\ntrim\nrotate" | rofi -i -dmenu -p "Convert JPG to") + out_ext=$(echo -e "pdf\npng\nresize\ncrop\ntrim\nrotate\nflip" | rofi -i -dmenu -p "Convert JPG to") if [ -z "$out_ext" ]; then exit; @@ -940,6 +1015,65 @@ jpg2() { \ "rotate") jpgrotate_function ;; + "flip") + jpgfliphor_function + ;; + esac +} +#+end_src + +** BMP files +*** BMP to PNG +#+begin_src bash +bmp2png_function() { \ + if command -v convert &> /dev/null; then + convert "$filename_with_extension" "$filename_without_extension.png" + fi +} +#+end_src + +*** Main function +#+begin_src bash +# Convert BMP Files +bmp2() { \ + out_ext=$(echo -e "png" | rofi -i -dmenu -p "Convert BMP to") + + if [ -z "$out_ext" ]; then + exit; + fi + + case "$out_ext" in + "png") + bmp2png_function + ;; + esac +} +#+end_src + +** WEBP files +*** WEBP to PNG +#+begin_src bash +webp2png_function() { \ + if command -v convert &> /dev/null; then + convert "$filename_with_extension" "$filename_without_extension.png" + fi +} +#+end_src + +*** Main function +#+begin_src bash +# Convert WEBP Files +webp2() { \ + out_ext=$(echo -e "png" | rofi -i -dmenu -p "Convert WEBP to") + + if [ -z "$out_ext" ]; then + exit; + fi + + case "$out_ext" in + "png") + webp2png_function + ;; esac } #+end_src @@ -973,6 +1107,15 @@ xopp2() { \ #+end_src ** MP4 files +*** MP4 to AVI (powerpoint) +#+begin_src bash +mp42avi_powerpoint_function() { \ + if command -v ffmpeg &> /dev/null; then + ffmpeg -v warning -i "$filename_with_extension" -q:a 2 -q:v 4 -vcodec wmv2 -an -y "$filename_without_extension.avi" + fi +} +#+end_src + *** MP4 to GIF #+begin_src bash mp42gif_function() { \ @@ -1028,7 +1171,7 @@ mp4nosound_function() { \ #+begin_src bash # Convert MP4 Files mp42() { \ - out_ext=$(echo -e "gif\ngif loop\nremove sound" | rofi -i -dmenu -p "Convert MP4 to") + out_ext=$(echo -e "gif\ngif loop\nremove sound\navi" | rofi -i -dmenu -p "Convert MP4 to") if [ -z "$out_ext" ]; then exit; @@ -1041,6 +1184,9 @@ mp42() { \ "gif loop") mp42gifloop_function ;; + "avi") + mp42avi_powerpoint_function + ;; "remove sound") mp4nosound_function ;; @@ -1049,6 +1195,22 @@ mp42() { \ #+end_src ** AVI files +*** Crop AVI +#+begin_src bash +avi2crop_function() { \ + if command -v ffmpeg &> /dev/null; then + cropvalue=$(ffmpeg -i "$filename_with_extension" -frames:v 3 -vf "negate,cropdetect=limit=0:round=2" -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1) + + # Step 2: Apply crop + if [ -n "$cropvalue" ]; then + ffmpeg -i "$filename_with_extension" -q:a 2 -q:v 4 -vcodec wmv2 -an -y -vf "$cropvalue" "${filename_without_extension}_crop.avi" + else + echo "Could not detect crop value." + fi + fi +} +#+end_src + *** AVI to MP4 #+begin_src bash avi2mp4_function() { \ @@ -1100,7 +1262,7 @@ avi2gifloop_function() { \ #+begin_src bash # Convert AVI Files avi2() { \ - out_ext=$(echo -e "gif\ngif loop\nmp4" | rofi -i -dmenu -p "Convert AVI to") + out_ext=$(echo -e "gif\ngif loop\nmp4\ncrop" | rofi -i -dmenu -p "Convert AVI to") if [ -z "$out_ext" ]; then exit; @@ -1116,6 +1278,9 @@ avi2() { \ "mp4") avi2mp4_function ;; + "crop") + avi2crop_function + ;; esac } #+end_src @@ -1153,6 +1318,12 @@ case "$in_ext" in "docx") docx2 ;; + "webp") + webp2 + ;; + "bmp") + bmp2 + ;; "pptx") docx2 ;;