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
|
|
|
|
2022-05-09 10:06:19 +02:00
|
|
|
* =phonebook= ESRF phone-book
|
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: phonebook
|
|
|
|
:END:
|
|
|
|
|
|
|
|
The phone-list is taken from =scp opid21@lid21nano:/mnt/multipath-shares/sware/pub/phonelist/share/annuaire.txt /home/thomas/.local/data/annuaire.txt=
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/phonebook
|
|
|
|
cat ~/.local/data/annuaire.txt | fzf --header="NAME Phone Box department roomNumber description mail"
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/phonebook-gui
|
|
|
|
$TERMINAL --title esrf-phonebook -e phonebook
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* =contacts= Personnal phone-book
|
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: contacts
|
|
|
|
:END:
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/contacts
|
|
|
|
khard | fzf --header="Index Name Phone E-Mail"
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/contacts-gui
|
|
|
|
$TERMINAL --title esrf-phonebook -e contacts
|
|
|
|
#+end_src
|
|
|
|
|
2022-02-06 21:51:52 +01:00
|
|
|
* =qutebrowser=
|
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: qutebrowser
|
|
|
|
:END:
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/qutebrowser
|
|
|
|
~/.local/soft/qutebrowser/.venv/bin/python3 -m qutebrowser "$@"
|
|
|
|
#+end_src
|
|
|
|
|
2022-05-09 10:06:19 +02:00
|
|
|
* =remote-home= - Remote Desktop to Home PC
|
|
|
|
:PROPERTIES:
|
|
|
|
:CUSTOM_ID: remote-home
|
|
|
|
:END:
|
|
|
|
|
|
|
|
#+begin_src bash :tangle ~/.local/bin/remote-home
|
|
|
|
notify-send 'Rdesktop' "Connection to Home PC..."
|
|
|
|
|
|
|
|
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_PC /grab-keyboard /cert:ignore"
|
|
|
|
|
|
|
|
xfreerdp $common_arg /u:thomas /p:$(pass home_pc/thomas | sed -n 1p) /v:192.168.1.72 > /tmp/freerdp_home_pc.log 2>&1 &
|
|
|
|
#+end_src
|
|
|
|
|
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
|
2022-05-09 10:06:19 +02:00
|
|
|
computer=$(echo -e 'WID21SPEEDGOAT1\nWBM23SPEEDGOAT1\nWID24SPEEDGOAT1\nPCMEL1\nRNICE\nPCDEHAEZE\nLAPPAMU1\nPCNASS1\nDesktop-W10' | rofi -i -dmenu -no-custom -p 'Computer:' -l 20);
|
2021-01-08 01:26:27 +01:00
|
|
|
|
2022-02-06 21:46:32 +01:00
|
|
|
if [[ -z "$computer" ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
notify-send 'Rdesktop' "Connection to ${computer}..."
|
|
|
|
|
|
|
|
proxy_arg=""
|
2022-05-09 10:06:19 +02:00
|
|
|
if [ "$computer" = "Desktop-W10" ]; then
|
|
|
|
# If connect to local PC
|
|
|
|
if [ ping -c 1 -t 1 desktop-w10.lan &> /dev/null ]; then
|
|
|
|
# And outside of local network, use proxy
|
|
|
|
proxy_arg="/proxy:socks5://localhost:8080"
|
|
|
|
fi
|
|
|
|
elif [ -z "$(timeout 1s dig +short proxy.esrf.fr.)" ]; then
|
|
|
|
# Outside the ESRF network
|
|
|
|
proxy_arg="/proxy:socks5://localhost:8081"
|
2022-02-06 21:46:32 +01:00
|
|
|
fi
|
|
|
|
|
2022-05-09 10:06:19 +02:00
|
|
|
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"
|
|
|
|
|
2022-02-22 13:17:25 +01:00
|
|
|
case "$computer" in
|
|
|
|
"RNICE" | "PCDEHAEZE" | "PCNASS1")
|
2022-05-09 10:06:19 +02:00
|
|
|
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 & ;;
|
2022-02-22 13:17:25 +01:00
|
|
|
|
|
|
|
"PCMEL1")
|
2022-05-09 10:06:19 +02:00
|
|
|
xfreerdp $proxy_arg $common_arg /d:ESRF /u:OPPEL /p:TonicPEL /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
2022-02-22 13:17:25 +01:00
|
|
|
|
|
|
|
"WID21SPEEDGOAT1")
|
2022-05-09 10:06:19 +02:00
|
|
|
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid21 /p:tonic21 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
|
|
|
|
|
|
|
"WBM23SPEEDGOAT1")
|
|
|
|
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opd23 /p:tonic23 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
2022-02-22 13:17:25 +01:00
|
|
|
|
|
|
|
"WID24SPEEDGOAT1")
|
2022-05-09 10:06:19 +02:00
|
|
|
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid24 /p:tonic24 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
|
|
|
|
|
|
|
"LAPPAMU1")
|
|
|
|
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid00 /p:tonic00 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
|
|
|
|
|
|
|
"Desktop-W10")
|
|
|
|
xfreerdp $proxy_arg $common_arg /d:ESRF /u:thomas /p:$(pass windows/Desktop-W10 | sed -n 1p) /v:192.168.1.72 > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
2022-02-22 13:17:25 +01:00
|
|
|
|
|
|
|
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>
|
2022-02-06 21:46:32 +01:00
|
|
|
homelab:/srv/storage/ /home/thomas/mnt/homelab fuse.sshfs noauto,allow_other,user,default_permissions 0 0
|
2021-11-03 10:58:30 +01:00
|
|
|
#+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>
|
2022-02-06 21:46:32 +01:00
|
|
|
dehaeze@rnice:/tmp_14_days/ /home/thomas/mnt/tmp_14_days fuse.sshfs noauto,allow_other,user,default_permissions 0 0
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src text :tangle no
|
|
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
|
|
dehaeze@rnice:/home/esrf/dehaeze/ /home/thomas/mnt/unix_home fuse.sshfs noauto,allow_other,user,default_permissions 0 0
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src text :tangle no
|
|
|
|
# <file system> <mount point> <type> <options> <dump> <pass>
|
|
|
|
//wfiles/groupshare /home/thomas/mnt/groupshare vsifs noauto,user,credentials=/home/thomas/.smbcredentials,uid=1001,gid=1001,forceuid,forcegid 0 0
|
2021-11-03 10:58:30 +01:00
|
|
|
#+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
|
2022-02-06 21:46:32 +01:00
|
|
|
if [ $# -eq 0 ]; then
|
2022-05-09 10:06:19 +02:00
|
|
|
drive=$(echo -e 'monochromators\ntmp_14_days\nhomelab\ngroupshare\nunix_home\ndata_id21' | rofi -dmenu -no-custom -p 'Drive:' -l 20);
|
2022-02-06 21:46:32 +01:00
|
|
|
if [[ -z "$drive" ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
drive=$1
|
|
|
|
fi
|
|
|
|
|
2021-11-03 10:58:30 +01:00
|
|
|
|
|
|
|
if grep -qs "/home/thomas/mnt/$drive" /proc/mounts; then
|
|
|
|
umount "/home/thomas/mnt/$drive" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send "$drive " 'Successfully unmounted' || \
|
|
|
|
notify-send --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" && \
|
2022-02-06 21:45:41 +01:00
|
|
|
notify-send "$drive " 'Successfully mounted' || \
|
|
|
|
notify-send --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
|
2022-02-06 21:46:59 +01:00
|
|
|
option=$(echo -e "Work\nLaptop\nHome" | rofi -dmenu -no-custom -p 'Screen:' -l 20)
|
|
|
|
|
|
|
|
if [[ -z "$option" ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
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")
|
2022-02-20 22:06:56 +01:00
|
|
|
xrandr --output eDP-1 --off --output DP-3-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
|
2021-11-03 10:58:30 +01:00
|
|
|
after_screen_change
|
|
|
|
;;
|
2022-02-06 21:46:32 +01:00
|
|
|
"Laptop")
|
2022-05-09 10:06:19 +02:00
|
|
|
xrandr --output DP-1-2 --off --output DP-3-2 --off --output eDP-1 --primary --mode 1920x1200 --pos 0x0 --rotate normal && \
|
2021-11-03 10:58:30 +01:00
|
|
|
after_screen_change
|
|
|
|
;;
|
|
|
|
"Home")
|
2022-02-20 22:06:56 +01:00
|
|
|
xrandr --output eDP-1 --off --output DP-3-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
|
2021-11-03 10:58:30 +01:00
|
|
|
after_screen_change
|
|
|
|
;;
|
|
|
|
,*)
|
|
|
|
echo "== ! missing or invalid argument ! =="
|
|
|
|
exit 2
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
#+end_src
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2022-02-06 21:46:59 +01:00
|
|
|
* =print-esrf= - Print on Rnice
|
2021-01-01 20:12:34 +01:00
|
|
|
:PROPERTIES:
|
2022-02-06 21:46:59 +01:00
|
|
|
:CUSTOM_ID: print-esrf
|
2021-01-01 20:12:34 +01:00
|
|
|
:END:
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2022-02-06 21:46:59 +01:00
|
|
|
#+begin_src bash :tangle ~/.local/bin/print-esrf
|
2021-11-03 10:58:30 +01:00
|
|
|
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);
|
2022-02-06 21:46:59 +01:00
|
|
|
printer=$(echo -e 'ctb127c1u\nctb110c1u' | rofi -dmenu -no-custom -p 'Size:' -l 20);
|
2020-05-26 08:33:31 +02:00
|
|
|
|
2022-02-06 21:46:59 +01:00
|
|
|
if [[ -z "$nbpage" || -z "$side" || -z "$media" || -z "$printer" ]]; then
|
|
|
|
exit 1
|
2021-01-08 01:26:27 +01:00
|
|
|
fi
|
2021-01-01 20:12:34 +01:00
|
|
|
|
2022-02-06 21:46:59 +01:00
|
|
|
lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P $printer "$1";
|
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
|
2022-05-09 10:06:19 +02:00
|
|
|
|