Add installation scripts
This commit is contained in:
181
binaries-laptop.org
Normal file
181
binaries-laptop.org
Normal file
@@ -0,0 +1,181 @@
|
||||
#+TITLE: Binaries specific to my ESRF Laptop
|
||||
#+SETUPFILE: ./setup/org-setup-file.org
|
||||
|
||||
#+PROPERTY: header-args:bash :comments both :mkdirp yes
|
||||
#+PROPERTY: header-args:bash+ :shebang "#!/usr/bin/env bash"
|
||||
#+PROPERTY: header-args:bash+ :tangle-mode (identity #o555)
|
||||
|
||||
* =phonebook= ESRF phone-book
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: phonebook
|
||||
:END:
|
||||
|
||||
*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 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
|
||||
: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
|
||||
|
||||
* =wake-on-lan= - Wake on LAN
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: wake-on-lan
|
||||
:END:
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/wake-on-lan
|
||||
computer=$(echo -e 'ZOTAC' | rofi -i -dmenu -p 'Computer:' -l 20);
|
||||
|
||||
if [[ -z "$computer" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dunstify --replace=99425 'Wake On Lan' "${computer}..."
|
||||
|
||||
case "$computer" in
|
||||
"ZOTAC")
|
||||
ssh homelab 'wakeonlan 00:01:2E:A2:42:9C' ;;
|
||||
|
||||
esac
|
||||
#+end_src
|
||||
|
||||
* =screen-select= - Xrandr pre-defined scripts
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: screen-select
|
||||
:END:
|
||||
|
||||
#+begin_src bash :tangle ~/.local/bin/screen-select
|
||||
option=$(echo -e "Work\nLaptop\nHome\nAouste" | rofi -i -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 \
|
||||
--output DP-3-1 --primary --mode 2560x1440 --pos 2560x0 --rotate normal && \
|
||||
after_screen_change
|
||||
;;
|
||||
"Laptop")
|
||||
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-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 ! =="
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit 0
|
||||
#+end_src
|
||||
|
||||
* =print-esrf= - Print on Rnice
|
||||
:PROPERTIES:
|
||||
: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);
|
||||
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 "$sides" || -z "$media" || -z "$printer" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rsync -zaP "$1" dehaeze@rnice:/home/esrf/dehaeze/Downloads/to-be-printed.pdf && \
|
||||
ssh rnice "lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P $printer /home/esrf/dehaeze/Downloads/to-be-printed.pdf";
|
||||
#+end_src
|
||||
|
||||
Reference in New Issue
Block a user