286 lines
9.1 KiB
Org Mode
286 lines
9.1 KiB
Org Mode
#+TITLE: Scripts
|
|
|
|
* Wallpapers
|
|
:PROPERTIES:
|
|
:header-args: :tangle ~/scripts/wallpapers.sh
|
|
:header-args+: :comments both :mkdirp yes
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
:END:
|
|
#+begin_src bash
|
|
while true; do
|
|
nitrogen --set-zoom-fill --random ".wallpapers"
|
|
sleep 10m
|
|
done
|
|
#+end_src
|
|
|
|
* TODO [#A] LockScreen
|
|
:PROPERTIES:
|
|
:header-args: :tangle ~/scripts/lockscreen.sh
|
|
:header-args+: :comments both :mkdirp yes
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
:END:
|
|
- [ ] Does not work well with multiple screen
|
|
|
|
#+begin_src bash
|
|
revert() {
|
|
xset dpms 0 0 0
|
|
}
|
|
trap revert HUP INT TERM
|
|
# turn off screen after 5 seconds
|
|
xset +dpms dpms 5 5 5
|
|
|
|
# Parameters
|
|
temp_file="/tmp/screen.png"
|
|
icon="$HOME/Pictures/Evil_Rick_Sprite.png"
|
|
width=1920
|
|
height=1080
|
|
blur_factor=6
|
|
lock_blur_factor=0
|
|
|
|
# Take the screen shot, blur the image and add the icon
|
|
ffmpeg -f x11grab -video_size "${width}x${height}" -y -i $DISPLAY -i $icon -filter_complex "boxblur=$blur_factor:$blur_factor,overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2,boxblur=$lock_blur_factor:$lock_blur_factor" -vframes 1 $temp_file
|
|
|
|
# Alternative
|
|
# scrot -d 1 $temp_file
|
|
# convert -blur 0x8 $temp_file $temp_file
|
|
# convert -composite $temp_file $icon -gravity South -geometry -20x1200 $temp_file
|
|
|
|
# Lock the screen with the image
|
|
i3lock --no-unlock-indicator --ignore-empty-password --show-failed-attempts --nofork --image=$temp_file
|
|
|
|
# Remove the screenshot
|
|
rm $temp_file
|
|
|
|
# Don't turn off screen when back from lock
|
|
revert
|
|
#+end_src
|
|
|
|
* Delete first page of PDF
|
|
:PROPERTIES:
|
|
:header-args: :tangle ~/scripts/pdf-delete-first-page.sh
|
|
:header-args+: :comments both :mkdirp yes
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
:END:
|
|
The requirement is to have =pdftk= installed.
|
|
|
|
#+begin_src bash
|
|
if [[ -f $1 && $1 == *.pdf ]]; then
|
|
# Argument if a file
|
|
pdftk "$1" cat 2-end output /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1"
|
|
fi
|
|
#+end_src
|
|
|
|
* Take Screenshot
|
|
:PROPERTIES:
|
|
:header-args: :tangle ~/scripts/screenshot.sh
|
|
:header-args+: :comments both :mkdirp yes
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
:END:
|
|
|
|
#+begin_src bash
|
|
status=$(echo -e "All\nSelection\nCopy\nShadow\nActive" | rofi -i -dmenu)
|
|
|
|
name=$(echo -e "screenshot-$(date +"%m-%d-%y_%H-%M-%S")" | rofi -i -dmenu)
|
|
|
|
case "$status" in
|
|
"All")
|
|
maim ~/Pictures/$name.png ;;
|
|
"Selection")
|
|
maim -s ~/Pictures/$name.png ;;
|
|
"Copy")
|
|
maim -s | xclip -selection clipboard -t image/png ;;
|
|
"Shadow")
|
|
maim -st 9999999 | convert - \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage ~/Pictures/$name.png ;;
|
|
"Active")
|
|
maim -i $(xdotool getactivewindow) ~/Pictures/$name.png ;;
|
|
esac
|
|
#+end_src
|
|
|
|
#+RESULTS:
|
|
* 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
|
|
option=$(echo -e "Lock\nExit\nLogout\nSuspend\nHibernate\nReboot\nShutdown" | rofi -i -dmenu)
|
|
|
|
case "$option" in
|
|
"Lock")
|
|
i3exit lock ;;
|
|
"Exit")
|
|
i3exit switch_user ;;
|
|
"Logout")
|
|
i3exit logout ;;
|
|
"Suspend")
|
|
i3exit suspend ;;
|
|
"Hibernate")
|
|
i3exit hibernate ;;
|
|
"Reboot")
|
|
i3exit reboot ;;
|
|
"Shutdown")
|
|
i3exit shutdown ;;
|
|
esac
|
|
#+end_src
|
|
|
|
#+RESULTS:
|
|
* 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/MEGA/These/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:
|
|
#+begin_example
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_alt.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_2dof_alt.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_sep.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_bis.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_names.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_plant_weights.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_Mdelta.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_stability.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_meas.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_output_uncertainty.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_uncertainty_set.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_uncertainty_set_feedback.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/inverse_uncertainty_set.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_delta.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_Ndelta.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_Mdelta.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/additive_uncertainty.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_uncertainty.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/output_uncertainty.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/inv_additive_uncertainty.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/inv_input_uncertainty.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/inv_output_uncertainty.pdf
|
|
/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_uncertainty_set_feedback_weight.pdf
|
|
#+end_example
|
|
* NAS
|
|
** Mount
|
|
:PROPERTIES:
|
|
:header-args: :tangle ~/scripts/nas.sh
|
|
:header-args+: :comments both :mkdirp yes
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
:END:
|
|
#+begin_src bash
|
|
if [ $1 == "mount" ]; then
|
|
if sudo -A mount 192.168.1.2:/volume1/Downloads/ /mnt/NAS/; then
|
|
dunstify --replace=58249 'NAS' 'Successfully mounted'
|
|
else
|
|
dunstify --replace=58249 'NAS' 'Error while mounted'
|
|
fi
|
|
elif [ $1 == "umount" ]; then
|
|
if sudo -A umount /mnt/NAS/; then
|
|
dunstify --replace=58249 'NAS' 'Successfully unmounted'
|
|
else
|
|
dunstify --replace=58249 'NAS' 'Error while unmounted'
|
|
fi
|
|
fi
|
|
#+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
|
|
:PROPERTIES:
|
|
:header-args: :tangle ~/scripts/icons.sh
|
|
:header-args+: :comments both :mkdirp yes
|
|
:header-args+: :shebang "#!/usr/bin/env bash"
|
|
: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)
|
|
|
|
[ "$chosen" != "" ] || exit
|
|
|
|
c=$(echo "$chosen" | sed "s/ .*//")
|
|
echo "$c" | tr -d '\n' | xclip -selection clipboard
|
|
dunstify --replace=05896 "'$c' copied to clipboard." &
|
|
#+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
|