Rework remove connection script

This commit is contained in:
Thomas Dehaeze 2022-02-06 21:46:32 +01:00
parent bcb0c53079
commit f23b158a0a

View File

@ -13,38 +13,51 @@
#+begin_src bash :tangle ~/.local/bin/remote-desktop
computer=$(echo -e 'RNICE\nPCDEHAEZE\nPCNASS1' | rofi -dmenu -no-custom -p 'Computer:' -l 20);
dunstify --replace=89891 'Rdesktop' "Connection to ${computer}..."
if [[ -z "$computer" ]]; then
exit 1
fi
case $computer in
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 &
;;
PCNASS1)
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 &
;;
RNICE)
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 &
;;
,*)
echo "Not existing" && \
dunstify --replace=89891 --urgency=critical 'Rdesktop' "No config for $computer";
;;
esac
notify-send 'Rdesktop' "Connection to ${computer}..."
proxy_arg=""
if [ -z "$(timeout 1s dig +short proxy.esrf.fr.)" ]; then
proxy_arg="/proxy:socks5://localhost:8080"
fi
xfreerdp $proxy_arg /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 /wm-class:RDP_$computer /grab-keyboard /p:$(pass esrf.fr/dehaeze | sed -n 1p) /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 &
#+end_src
* =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
homelab:/srv/storage/ /home/thomas/mnt/homelab 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:/tmp_14_days/ /home/thomas/mnt/ESRF fuse.sshfs noauto,allow_other,default_permissions 0 0
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
#+end_src
#+begin_src bash :tangle ~/.local/bin/mount-dir
drive=$(echo -e 'ESRF\nNAS' | rofi -dmenu -no-custom -p 'Drive:' -l 20);
if [ $# -eq 0 ]; then
drive=$(echo -e 'tmp_14_days\nhomelab\ngroupshare\nunix_home\ndata_id21' | rofi -dmenu -no-custom -p 'Drive:' -l 20);
if [[ -z "$drive" ]]; then
exit 1
fi
else
drive=$1
fi
if grep -qs "/home/thomas/mnt/$drive" /proc/mounts; then
umount "/home/thomas/mnt/$drive" && \
@ -83,15 +96,15 @@ after_screen_change () {
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 && \
xrandr --output eDP-1 --off --output DP-1-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 && \
"Laptop")
xrandr --output DP-1-2 --off --output eDP-1 --primary --mode 1920x1200 --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 && \
xrandr --output eDP-1 --off --output DP-1-1 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
after_screen_change
;;
,*)