Update scripts in ~/.local/bin/
This commit is contained in:
@@ -10,16 +10,57 @@
|
||||
:CUSTOM_ID: phonebook
|
||||
:END:
|
||||
|
||||
The phone-list is taken from =scp rnice@esrf.fr:/mnt/multipath-shares/sware/pub/phonelist/share/annuaire.txt /home/thomas/.local/data/annuaire.txt=
|
||||
*Old phonebook*: The phone-list is taken from =scp rnice@esrf.fr:/mnt/multipath-shares/sware/pub/phonelist/share/annuaire.txt /home/thomas/.local/data/annuaire.txt=
|
||||
*new phonebook*: Use the =etd= script
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/phonebook
|
||||
cat ~/.local/data/annuaire.txt | fzf --header="NAME Phone Box department roomNumber description mail"
|
||||
cat ~/.local/data/annuaire.txt | fzf --header="NAME Surname Phone Office Room Email"
|
||||
#+end_src
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/phonebook-gui
|
||||
$TERMINAL --title esrf-phonebook -e phonebook
|
||||
#+end_src
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/etd
|
||||
#!/bin/bash
|
||||
|
||||
ROOT_URL='https://phonedirectory.esrf.fr'
|
||||
API_ENDPOINT="$ROOT_URL/api"
|
||||
USAGE="
|
||||
ESRF Telephone Directory
|
||||
|
||||
CLI to search $ROOT_URL
|
||||
|
||||
Usage :
|
||||
# Search for <search term> in first name or last name
|
||||
$0 <search term>
|
||||
|
||||
"
|
||||
|
||||
function fail {
|
||||
echo "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
function json_curl { curl --get --fail --silent --show-error -H "Content-Type:application/json" -H "Accept: application/json" "$@"; }
|
||||
|
||||
function lspersons {
|
||||
# List users and output result in csv
|
||||
json_curl --data-urlencode "search=$1" "$API_ENDPOINT/searchUsers" |\
|
||||
jq -r '. | (map(keys) | add | unique | sort) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $rows[] | @csv' 2>/dev/null
|
||||
}
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
fail "$USAGE"
|
||||
fi
|
||||
|
||||
# Print the list of persons as a table
|
||||
|
||||
lspersons $1 | awk 'BEGIN { FS=OFS="," }; {print $4,$3,$5,$1,$6,$2,$7}' | sed 's/"//g' | column -t -s "," | sort
|
||||
|
||||
exit $?
|
||||
#+end_src
|
||||
|
||||
* =contacts= Personnal phone-book
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: contacts
|
||||
@@ -39,7 +80,7 @@ $TERMINAL --title esrf-phonebook -e contacts
|
||||
:END:
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/remote-desktop
|
||||
computer=$(echo -e 'WID16A1\nWID21SPEEDGOAT1\nWID24SPEEDGOAT1\nWBM23SPEEDGOAT1\nWMELSPEEDGOAT1\nWID31PC1\nPCOPTRO\nPCMEL1\nRNICE\nPCDEHAEZE\nLAPMEL01\nDesktop-W10' | rofi -i -dmenu -no-custom -p 'Computer:' -l 20);
|
||||
computer=$(echo -e 'PCOPTRO\nPCMEL1\nRNICE\nPCDEHAEZE\nLAPMEL01\nZOTAC' | rofi -i -dmenu -p 'Computer:' -l 20);
|
||||
|
||||
if [[ -z "$computer" ]]; then
|
||||
exit 1
|
||||
@@ -48,9 +89,9 @@ fi
|
||||
dunstify --replace=99425 'Rdesktop' "Connection to ${computer}..."
|
||||
|
||||
proxy_arg=""
|
||||
if [ "$computer" = "Desktop-W10" ]; then
|
||||
if [ "$computer" = "ZOTAC" ]; then
|
||||
# If connect to local PC
|
||||
ping -c 1 desktop-w10.lan &> /dev/null
|
||||
ping -c 1 openwrt.lan &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
# And outside of local network, use proxy
|
||||
proxy_arg="/proxy:socks5://localhost:8080"
|
||||
@@ -63,35 +104,43 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
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"
|
||||
common_arg="/clipboard /bpp:32 /compression -themes -wallpaper /audio-mode:1 /dynamic-resolution /auto-reconnect /wm-class:RDP_$computer -grab-keyboard /cert:ignore /rfx /gfx:avc444"
|
||||
|
||||
case "$computer" in
|
||||
"RNICE" | "PCDEHAEZE")
|
||||
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 & ;;
|
||||
xfreerdp3 $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 & ;;
|
||||
|
||||
"PCMEL1" | "PCOPTRO" | "LAPMEL01")
|
||||
xfreerdp $proxy_arg $common_arg /d:ESRF /u:OPPEL /p:TonicPEL /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
xfreerdp3 $proxy_arg $common_arg /d:ESRF /u:OPPEL /p:$(pass esrf.fr/oppel | sed -n 1p) /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
|
||||
"WMELSPEEDGOAT1")
|
||||
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opd23 /p:tonic23 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
"ZOTAC")
|
||||
xfreerdp3 $proxy_arg $common_arg /u:thomas /p:$(pass windows/zotac | sed -n 1p) /v:192.168.5.75 > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
|
||||
"WID16A1")
|
||||
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid16a /p:tonic16 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
*)
|
||||
user=$(rofi -dmenu -p 'User:');
|
||||
password=$(rofi -dmenu -p 'Password:');
|
||||
xfreerdp3 $proxy_arg $common_arg /u:$user /p:$password /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
|
||||
"WID31PC1")
|
||||
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid31 /p:tonic31 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
esac
|
||||
#+end_src
|
||||
|
||||
"WID21SPEEDGOAT1")
|
||||
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid21 /p:tonic21 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
* =wake-on-lan= - Wake on LAN
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: wake-on-lan
|
||||
:END:
|
||||
|
||||
"WID24SPEEDGOAT1")
|
||||
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opid24 /p:tonic24 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
#+begin_src bash :tangle ~/.local/bin/wake-on-lan
|
||||
computer=$(echo -e 'ZOTAC' | rofi -i -dmenu -p 'Computer:' -l 20);
|
||||
|
||||
"WBM23SPEEDGOAT1")
|
||||
xfreerdp $proxy_arg $common_arg /d:ESRF /u:opd23 /p:tonic23 /v:$computer.esrf.fr > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
if [[ -z "$computer" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"Desktop-W10")
|
||||
xfreerdp $proxy_arg $common_arg /u:thomas /p:$(pass windows/Desktop-W10 | sed -n 1p) /v:192.168.1.72 > /tmp/freerdp_${computer}.log 2>&1 & ;;
|
||||
dunstify --replace=99425 'Wake On Lan' "${computer}..."
|
||||
|
||||
case "$computer" in
|
||||
"ZOTAC")
|
||||
ssh homelab 'wakeonlan 00:01:2E:A2:42:9C' ;;
|
||||
|
||||
esac
|
||||
#+end_src
|
||||
@@ -155,7 +204,9 @@ fi
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/mount-dir
|
||||
if [ $# -eq 0 ]; then
|
||||
drive=$(find ~/mnt/* -maxdepth 0 -type d -empty -printf '%f\n' | rofi -i -dmenu -no-custom -p 'Drive:' -l 20);
|
||||
# Takes a lot of time with "tmp_14_days" is mounted
|
||||
# drive=$(find ~/mnt/* -maxdepth 0 -type d -empty -printf '%f\n' | rofi -i -dmenu -no-custom -p 'Drive:' -l 20);
|
||||
drive=$(ls ~/mnt | rofi -i -dmenu -no-custom -p 'Drive:' -l 20);
|
||||
if [[ -z "$drive" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
@@ -181,7 +232,7 @@ case "$drive" in
|
||||
"monochromators")
|
||||
remote_loc="dehaeze@rnice$proxy_arg:/data/monochromators/" ;;
|
||||
"data_mel")
|
||||
remote_loc="opid00@lmellab$proxy_arg:/data/id00/inhouse/" ;;
|
||||
remote_loc="opid00@lmelcontrol$proxy_arg:/data/id00/inhouse/" ;;
|
||||
"data_jazzy")
|
||||
remote_loc="dehaeze@rnice$proxy_arg:/gpfs/jazzy/data/" ;;
|
||||
"data_easy")
|
||||
@@ -190,12 +241,16 @@ case "$drive" in
|
||||
remote_loc="blissadm@pico3$proxy_arg:/data/id16a/inhouse1/commissioning/ni_endstation/Speedgoat/" ;;
|
||||
"data_id31")
|
||||
remote_loc="opid31@id31$proxy_arg:/data/id31/inhouse/" ;;
|
||||
"data_id24")
|
||||
remote_loc="dehaeze@rnice$proxy_arg:/gpfs/gb/data/id24-dcm/inhouse" ;;
|
||||
"bliss_mel")
|
||||
remote_loc="blissadm@lmellab$proxy_arg:/users/blissadm/local/" ;;
|
||||
remote_loc="blissadm@lmelcontrol$proxy_arg:/users/blissadm/local/" ;;
|
||||
"bliss_id16a")
|
||||
remote_loc="blissadm@pico3$proxy_arg:/users/blissadm/local/" ;;
|
||||
remote_loc="blissadm@id16a$proxy_arg:/users/blissadm/local/" ;;
|
||||
"bliss_id21")
|
||||
remote_loc="blissadm@lid21nano$proxy_arg:/users/blissadm/local/" ;;
|
||||
remote_loc="blissadm@id21$proxy_arg:/users/blissadm/local/" ;;
|
||||
"bliss_bm23")
|
||||
remote_loc="blissadm@bm23$proxy_arg:/users/blissadm/local/" ;;
|
||||
"bliss_id24")
|
||||
remote_loc="blissadm@foucault$proxy_arg:/users/blissadm/local/" ;;
|
||||
"groupshare")
|
||||
@@ -214,8 +269,9 @@ fi
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/umount-dir
|
||||
if [ $# -eq 0 ]; then
|
||||
# drive=$(find ~/mnt/* -maxdepth 0 -type d -not -empty -printf '%f\n' | rofi -dmenu -no-custom -p 'Drive:' -l 20);
|
||||
drive=$(ls ~/mnt/ | rofi -dmenu -no-custom -p 'Drive:' -l 20);
|
||||
# Takes a lot of time with tmp_14_days is mounted...
|
||||
# drive=$(ls ~/mnt/ | rofi -dmenu -no-custom -p 'Drive:' -l 20);
|
||||
drive=$(find ~/mnt/* -maxdepth 0 -type d -not -empty -printf '%f\n' | rofi -dmenu -no-custom -p 'Drive:' -l 20);
|
||||
if [[ -z "$drive" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
@@ -232,7 +288,7 @@ umount /home/thomas/mnt/$drive
|
||||
:END:
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/screen-select
|
||||
option=$(echo -e "Work\nLaptop\nHome" | rofi -i -dmenu -no-custom -p 'Screen:' -l 20)
|
||||
option=$(echo -e "Work\nLaptop\nHome\nAouste" | rofi -i -dmenu -no-custom -p 'Screen:' -l 20)
|
||||
|
||||
if [[ -z "$option" ]]; then
|
||||
exit 1
|
||||
@@ -255,17 +311,31 @@ after_screen_change () {
|
||||
case "$option" in
|
||||
"Work")
|
||||
xrandr --output eDP-1 --off \
|
||||
--output DP-3-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal \
|
||||
--output DP-3-1 --primary --mode 2560x1440 --pos 2560x0 --rotate normal && \
|
||||
after_screen_change
|
||||
--output DP-3-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal \
|
||||
--output DP-3-1 --primary --mode 2560x1440 --pos 2560x0 --rotate normal && \
|
||||
after_screen_change
|
||||
;;
|
||||
"Laptop")
|
||||
xrandr --output DP-1-2 --off --output DP-3-1 --off --output DP-3-2 --off --output eDP-1 --primary --mode 1920x1200 --pos 0x0 --rotate normal && \
|
||||
after_screen_change
|
||||
xrandr --output DP-1-1 --off \
|
||||
--output DP-1-2 --off \
|
||||
--output DP-3-1 --off \
|
||||
--output DP-3-2 --off \
|
||||
--output HDMI-1 --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
|
||||
xrandr --output eDP-1 --off \
|
||||
--output DP-3-1 --off \
|
||||
--output DP-3-2 --off \
|
||||
--output HDMI-1 --off \
|
||||
--output DP-1-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
|
||||
after_screen_change
|
||||
;;
|
||||
"Aouste")
|
||||
xrandr --output eDP-1 --off \
|
||||
--output HDMI-1 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
|
||||
after_screen_change
|
||||
;;
|
||||
,*)
|
||||
echo "== ! missing or invalid argument ! =="
|
||||
@@ -280,6 +350,8 @@ exit 0
|
||||
:CUSTOM_ID: print-esrf
|
||||
:END:
|
||||
|
||||
- To list printers =lpstat -p -d=
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/print-esrf
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user