literate-dotfiles/binaries-private.org

6.6 KiB

My own specific binaries

qutebrowser

~/.local/soft/qutebrowser/.venv/bin/python3 -m qutebrowser "$@"

remote-desktop - Remote Desktop Connect

computer=$(echo -e 'WID21SPEEDGOAT1\nWID24SPEEDGOAT1\nPCMEL1\nRNICE\nPCDEHAEZE\nPCNASS1' | rofi -dmenu -no-custom -p 'Computer:' -l 20);

if [[ -z "$computer" ]]; then
    exit 1
fi

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

case "$computer" in
    "RNICE" | "PCDEHAEZE" | "PCNASS1")
        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 & ;;

    "PCMEL1")
        xfreerdp $proxy_arg /u:OPPEL /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:TonicPEL /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;

    "WID21SPEEDGOAT1")
        xfreerdp $proxy_arg /u:opid21 /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:tonic21 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;

    "WID24SPEEDGOAT1")
        xfreerdp $proxy_arg /u:opid24 /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:tonic24 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;

esac

mount-dir - Mount/Unmout directories

# <file system>                <mount point>          <type>     <options>                                 <dump>  <pass>
homelab:/srv/storage/          /home/thomas/mnt/homelab   fuse.sshfs noauto,allow_other,user,default_permissions    0       0
# <file system>                <mount point>          <type>     <options>                                 <dump>  <pass>
dehaeze@rnice:/tmp_14_days/    /home/thomas/mnt/tmp_14_days  fuse.sshfs noauto,allow_other,user,default_permissions    0       0
# <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
# <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
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" && \
        notify-send "$drive " 'Successfully unmounted' || \
        notify-send --urgency=critical "$drive " 'Error while unmounted'
else
    echo "It's not mounted."
    mount "/home/thomas/mnt/$drive" && \
        notify-send "$drive " 'Successfully mounted' || \
        notify-send --urgency=critical "$drive " 'Error while mounted'
fi

screen-select - Xrandr pre-defined scripts

option=$(echo -e "Work\nLaptop\nHome" | rofi -dmenu -no-custom -p 'Screen:' -l 20)

if [[ -z "$option" ]]; then
    exit 1
fi

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 eDP-1 --off --output DP-3-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
            after_screen_change
        ;;
    "Laptop")
        xrandr --output DP-1-2 --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
        ;;
    ,*)
        echo "== ! missing or invalid argument ! =="
        exit 2
esac

exit 0

print-esrf - Print on 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);
printer=$(echo -e 'ctb127c1u\nctb110c1u' | rofi -dmenu -no-custom -p 'Size:' -l 20);

if [[ -z "$nbpage" || -z "$side" || -z "$media" || -z "$printer" ]]; then
    exit 1
fi

lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P $printer "$1";

readbib - Open Bibliography File

List all pdf files and open selected one with zathura.

cd ~/Cloud/pdfs/ && ls | rofi -dmenu -lines 20 | xargs -I {} zathura {}

readnotes - Open Note

List all pdf files and open selected one with zathura.

cd ~/Cloud/brain/pdfs/ && ls *.pdf | rofi -dmenu -lines 20 | xargs -I {} zathura {}