2020-05-26 08:33:31 +02:00
|
|
|
#+TITLE: My own specific binaries
|
2021-01-01 20:12:34 +01:00
|
|
|
#+SETUPFILE: ./setup/org-setup-file.org
|
2020-05-26 08:33:31 +02:00
|
|
|
|
|
|
|
#+PROPERTY: header-args:bash :comments both :mkdirp yes
|
|
|
|
#+PROPERTY: header-args:bash+ :shebang "#!/usr/bin/env bash"
|
2021-01-08 01:26:27 +01:00
|
|
|
#+PROPERTY: header-args:bash+ :tangle-mode (identity #o555)
|
2020-05-26 08:33:31 +02:00
|
|
|
|
|
|
|
* =remote-desktop= - Remote Desktop Connect
|
2021-01-01 20:12:34 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: remote-desktop
|
|
|
|
:END:
|
|
|
|
|
2020-05-26 08:33:31 +02:00
|
|
|
#+begin_src bash :tangle ~/.local/bin/remote-desktop
|
2021-11-03 10:58:30 +01:00
|
|
|
computer=$(echo -e 'RNICE\nPCDEHAEZE\nPCNASS1' | rofi -dmenu -no-custom -p 'Computer:' -l 20);
|
2021-01-08 01:26:27 +01:00
|
|
|
|
|
|
|
dunstify --replace=89891 'Rdesktop' "Connection to ${computer}..."
|
|
|
|
|
|
|
|
case $computer in
|
2021-11-03 10:58:30 +01:00
|
|
|
PCDEHAEZE)
|
|
|
|
xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:PCDEHAEZE.esrf.fr > /tmp/freerdp_pcdehaeze.log 2>&1 &
|
2021-01-08 01:26:27 +01:00
|
|
|
;;
|
|
|
|
PCNASS1)
|
2021-11-03 10:58:30 +01:00
|
|
|
xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:PCNASS1.esrf.fr > /tmp/freerdp_pcnass1.log 2>&1 &
|
2021-01-08 01:26:27 +01:00
|
|
|
;;
|
|
|
|
RNICE)
|
2021-11-03 10:58:30 +01:00
|
|
|
xfreerdp /u:dehaeze /d:ESRF /clipboard /bpp:8 /bpp:16 /compression -themes -wallpaper /async-update /async-input -glyph-cache /audio-mode:1 /dynamic-resolution /auto-reconnect /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:rnice.esrf.fr > /tmp/freerdp_rnice.log 2>&1 &
|
2021-01-08 01:26:27 +01:00
|
|
|
;;
|
|
|
|
,*)
|
|
|
|
echo "Not existing" && \
|
|
|
|
dunstify --replace=89891 --urgency=critical 'Rdesktop' "No config for $computer";
|
|
|
|
;;
|
|
|
|
esac
|
2020-05-26 08:33:31 +02:00
|
|
|
#+end_src
|
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
* =mount-dir= - Mount/Unmout directories
|
|
|
|
#+begin_src text :tangle no
|
|
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
|
|
homelab:/srv/storage/ /home/thomas/mnt/NAS fuse.sshfs noauto,allow_other,default_permissions 0 0
|
|
|
|
#+end_src
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
#+begin_src text :tangle no
|
|
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
|
|
dehaeze@rnice:/tmp_14_days/ /home/thomas/mnt/ESRF fuse.sshfs noauto,allow_other,default_permissions 0 0
|
|
|
|
#+end_src
|
2021-01-08 01:26:27 +01:00
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
#+begin_src bash :tangle ~/.local/bin/mount-dir
|
|
|
|
drive=$(echo -e 'ESRF\nNAS' | rofi -dmenu -no-custom -p 'Drive:' -l 20);
|
|
|
|
|
|
|
|
if grep -qs "/home/thomas/mnt/$drive" /proc/mounts; then
|
|
|
|
umount "/home/thomas/mnt/$drive" && \
|
|
|
|
dunstify --replace=58249 "$drive " 'Successfully unmounted' || \
|
|
|
|
dunstify --replace=58249 --urgency=critical "$drive " 'Error while unmounted'
|
2021-01-08 01:26:27 +01:00
|
|
|
else
|
2021-11-03 10:58:30 +01:00
|
|
|
echo "It's not mounted."
|
|
|
|
mount "/home/thomas/mnt/$drive" && \
|
|
|
|
dunstify --replace=58249 "$drive " 'Successfully mounted' || \
|
|
|
|
dunstify --replace=58249 --urgency=critical "$drive " 'Error while mounted'
|
2021-01-08 01:26:27 +01:00
|
|
|
fi
|
2020-05-26 08:33:31 +02:00
|
|
|
#+end_src
|
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
|
|
|
|
* =screen-select= - Xrandr pre-defined scripts
|
2021-01-01 20:12:34 +01:00
|
|
|
:PROPERTIES:
|
2021-11-03 10:58:30 +01:00
|
|
|
:CUSTOM_ID: screen-select
|
2021-01-01 20:12:34 +01:00
|
|
|
:END:
|
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
#+begin_src bash :tangle ~/.local/bin/screen-select
|
|
|
|
option=$(echo -e "Work\nXPS\nHome" | rofi -i -dmenu)
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
after_screen_change () {
|
|
|
|
# Fix background if screen size/arangement has changed.
|
|
|
|
setbg
|
|
|
|
|
|
|
|
# Kill polybar
|
|
|
|
killall -q polybar
|
|
|
|
|
|
|
|
# Wait until the processes have been shut down
|
|
|
|
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
|
|
|
|
|
|
|
# Launch bars
|
|
|
|
polybar top &
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$option" in
|
|
|
|
"Work")
|
|
|
|
xrandr --output eDP1 --off --output DP1 --off --output DP2 --off --output DP2-1 --off --output VIRTUAL1 --off --output DP2-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
|
|
|
|
after_screen_change
|
|
|
|
;;
|
|
|
|
"XPS")
|
|
|
|
xrandr --output DP1 --off --output DP2 --off --output DP2-1 --off --output VIRTUAL1 --off --output DP2-2 --off --output eDP1 --primary --mode 1920x1080 --pos 0x0 --rotate normal && \
|
|
|
|
after_screen_change
|
|
|
|
;;
|
|
|
|
"Home")
|
|
|
|
xrandr --output eDP1 --off --output DP1 --off --output DP2 --off --output DP2-2 --off --output VIRTUAL1 --off --output DP2-1 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
|
|
|
|
after_screen_change
|
|
|
|
;;
|
|
|
|
,*)
|
|
|
|
echo "== ! missing or invalid argument ! =="
|
|
|
|
exit 2
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
#+end_src
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
* =print-rnice= - Print on Rnice
|
2021-01-01 20:12:34 +01:00
|
|
|
:PROPERTIES:
|
2021-11-03 10:58:30 +01:00
|
|
|
:CUSTOM_ID: print-rnice
|
2021-01-01 20:12:34 +01:00
|
|
|
:END:
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
#+begin_src bash :tangle ~/.local/bin/print-rnice
|
|
|
|
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);
|
|
|
|
media=$(echo -e 'A4\nA3' | rofi -dmenu -no-custom -p 'Size:' -l 20);
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
# First copy the file to Rnice
|
|
|
|
if sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" scp $1 dehaeze@rnice:/home/esrf/dehaeze/Downloads/; then
|
|
|
|
# Then print on Rnice
|
|
|
|
sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" ssh dehaeze@rnice "lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P ctb127c1w \"/home/esrf/dehaeze/Downloads/$1\"";
|
|
|
|
# Finally, delete the file
|
|
|
|
else
|
|
|
|
echo "Command Failed"
|
2021-01-08 01:26:27 +01:00
|
|
|
fi
|
2020-05-26 08:33:31 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* =torrent-add= - Download Torrent
|
2021-01-01 20:12:34 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: torrent-add
|
|
|
|
:END:
|
|
|
|
|
2021-05-02 11:27:39 +02:00
|
|
|
#+begin_src bash :tangle ~/.local/bin/torrent-add :noweb yes
|
2021-10-25 14:32:51 +02:00
|
|
|
transmission-remote <<get-password(passname="ip/homelab")>>:9091 --auth tdehaeze:$(pass nas/transmission | sed -n 1p) -a $1 && \
|
2021-01-08 01:26:27 +01:00
|
|
|
dunstify 'Torrent' 'Successfully added' || \
|
|
|
|
dunstify 'Torrent' 'Error'
|
2021-01-01 20:12:34 +01:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* =dl-add= - Direct Download with Aria2
|
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: dl-add
|
|
|
|
:END:
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2021-01-01 20:12:34 +01:00
|
|
|
#+begin_src bash :tangle ~/.local/bin/dl-add
|
2021-01-08 01:26:27 +01:00
|
|
|
aria2p --port 6800 --host http://dl.tdehaeze.xyz --secret $(pass dl.tdehaeze.xyz/tdehaeze | sed -n 1p) add $1
|
2020-05-26 08:33:31 +02:00
|
|
|
#+end_src
|
2020-11-03 11:39:08 +01:00
|
|
|
|
|
|
|
* =note-extract-fig= - Extract Figure from note file
|
2021-01-01 20:12:34 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: note-extract-fig
|
|
|
|
:END:
|
|
|
|
|
2020-11-03 11:39:08 +01:00
|
|
|
Script used to convert a figure drawn on my Boox note2 to a png file that can then be imported into a document.
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/note-extract-fig
|
2021-01-08 01:26:27 +01:00
|
|
|
# First check that the first argument is a pdf file
|
|
|
|
if [[ -f $1 && $1 == *.pdf ]]; then
|
|
|
|
pngfile=$(echo $1 | cut -f 1 -d '.' | sed 's/$/.png/')
|
2020-11-03 11:39:08 +01:00
|
|
|
|
2021-01-08 01:26:27 +01:00
|
|
|
# Convert to png and crop png
|
|
|
|
pdf2png $1 && convert -trim "$pngfile" "$pngfile"
|
|
|
|
fi
|
2020-11-03 11:39:08 +01:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* =color-picker= - Pick color and copy to clipboard
|
2021-01-01 20:12:34 +01:00
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: color-picker
|
|
|
|
:END:
|
|
|
|
|
2020-11-03 11:39:08 +01:00
|
|
|
#+begin_src bash :tangle ~/.local/bin/color-picker
|
2021-01-08 01:26:27 +01:00
|
|
|
xcolor | tr -d '\n' | xsel -b
|
2020-11-03 11:39:08 +01:00
|
|
|
#+end_src
|
2021-02-10 18:00:14 +01:00
|
|
|
|
|
|
|
* =readbib= - Open Bibliography File
|
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: readbib
|
|
|
|
:END:
|
|
|
|
|
|
|
|
List all =pdf= files and open selected one with zathura.
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/readbib
|
|
|
|
cd ~/Cloud/pdfs/ && ls | rofi -dmenu -lines 20 | xargs -I {} zathura {}
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* =readnotes= - Open Note
|
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: readnotes
|
|
|
|
:END:
|
|
|
|
|
|
|
|
List all =pdf= files and open selected one with zathura.
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/readnotes
|
2021-10-25 14:32:51 +02:00
|
|
|
cd ~/Cloud/brain/pdfs/ && ls *.pdf | rofi -dmenu -lines 20 | xargs -I {} zathura {}
|
2021-02-10 18:00:14 +01:00
|
|
|
#+end_src
|