Add few scripts

This commit is contained in:
Thomas Dehaeze 2019-07-12 13:26:49 +02:00
parent 1d32be45f0
commit a8b3ac13b1

View File

@ -560,6 +560,7 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already
killall -SIGUSR1 dunst && echo "off" > $tmpfile;
fi
#+end_src
* Take Screenshot
:PROPERTIES:
:header-args: :tangle ~/bin/screenshot
@ -568,12 +569,12 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already
:END:
#+begin_src bash
status=$(echo -e "All\nSelection\nCropped\nCopy\nShadow\nActive" | rofi -i -dmenu)
status=$(echo -e "All\nSelection\nCropped\nCopy\nShadow\nActive" | rofi -i -dmenu -p "Type")
if [ -z "$status" ]; then
exit;
fi
name=$(echo -e "screenshot-$(date +"%m-%d-%y_%H-%M-%S")" | rofi -i -dmenu)
name=$(echo -e "screenshot-$(date +"%m-%d-%y_%H-%M-%S")" | rofi -i -dmenu -p "Filename")
if [ -z "$name" ]; then
exit;
fi
@ -593,3 +594,57 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already
maim -i $(xdotool getactivewindow) ~/Pictures/$name.png ;;
esac
#+end_src
* Remote Desktop Connect
:PROPERTIES:
:header-args: :tangle ~/bin/remote-desktop
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
rdesktop -a 16 -P -z -x m -r sound:off -g "80%" -u "ESRF\DEHAEZE" -p $(pass ssl.esrf.fr/dehaeze | sed -n 1p) 172.24.4.69
#+end_src
* Toggle Network
:PROPERTIES:
:header-args: :tangle ~/bin/network-toggle
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash :results output
result=$(nmcli device | sed '1d' | dmenu -l 20);
interface=$(echo $result | awk -F ' ' '{print $1}');
status=$(echo $result | awk -F ' ' '{print $3}');
if [ $status == 'disconnected' ]; then
nmcli device connect $interface
else
nmcli device disconnect $interface
fi
#+end_src
#+RESULTS:
: Device 'enp0s20f0u1u4' successfully disconnected.
* Print on Rnice
:PROPERTIES:
:header-args: :tangle ~/bin/print-rnice
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
nbpage=$(echo -e '1\n2\n4' | dmenu -p 'Number of pages per sheet' -l 20);
sides=$(echo -e 'one-sided\ntwo-sided-long-edge\ntwo-sided-short-edge' | dmenu -p 'Two Sided:' -l 20);
# First copy the file to Rnice
if sshpass -p "$(pass ssl.esrf.fr/dehaeze | sed -n 1p)" scp $1 dehaeze@160.103.228.221:~/Downloads/; then
# Then print on Rnice
sshpass -p "$(pass ssl.esrf.fr/dehaeze | sed -n 1p)" ssh dehaeze@160.103.228.221 "lpr -o media=A4 -o sides=$sides -o outputorder=reverse -o number-up=$nbpage -P ctb110c1u ~/Downloads/$1";
# Finally, delete the file
else
echo "Command Failed"
fi
#+end_src