Update scripts

This commit is contained in:
Thomas Dehaeze 2022-02-06 21:46:59 +01:00
parent f23b158a0a
commit 6ece088848
2 changed files with 22 additions and 59 deletions

View File

@ -71,14 +71,17 @@ else
fi fi
#+end_src #+end_src
* =screen-select= - Xrandr pre-defined scripts * =screen-select= - Xrandr pre-defined scripts
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: screen-select :CUSTOM_ID: screen-select
:END: :END:
#+begin_src bash :tangle ~/.local/bin/screen-select #+begin_src bash :tangle ~/.local/bin/screen-select
option=$(echo -e "Work\nXPS\nHome" | rofi -i -dmenu) option=$(echo -e "Work\nLaptop\nHome" | rofi -dmenu -no-custom -p 'Screen:' -l 20)
if [[ -z "$option" ]]; then
exit 1
fi
after_screen_change () { after_screen_change () {
# Fix background if screen size/arangement has changed. # Fix background if screen size/arangement has changed.
@ -115,70 +118,22 @@ esac
exit 0 exit 0
#+end_src #+end_src
* =print-rnice= - Print on Rnice * =print-esrf= - Print on Rnice
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: print-rnice :CUSTOM_ID: print-esrf
:END: :END:
#+begin_src bash :tangle ~/.local/bin/print-rnice #+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); 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); 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); 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);
# First copy the file to Rnice if [[ -z "$nbpage" || -z "$side" || -z "$media" || -z "$printer" ]]; then
if sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" scp $1 dehaeze@rnice:/home/esrf/dehaeze/Downloads/; then exit 1
# Then print on Rnice
sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" ssh dehaeze@rnice "lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P ctb127c1w \"/home/esrf/dehaeze/Downloads/$1\"";
# Finally, delete the file
else
echo "Command Failed"
fi fi
#+end_src
* =torrent-add= - Download Torrent lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P $printer "$1";
:PROPERTIES:
:CUSTOM_ID: torrent-add
:END:
#+begin_src bash :tangle ~/.local/bin/torrent-add :noweb yes
transmission-remote <<get-password(passname="ip/homelab")>>:9091 --auth tdehaeze:$(pass nas/transmission | sed -n 1p) -a $1 && \
dunstify 'Torrent' 'Successfully added' || \
dunstify 'Torrent' 'Error'
#+end_src
* =dl-add= - Direct Download with Aria2
:PROPERTIES:
:CUSTOM_ID: dl-add
:END:
#+begin_src bash :tangle ~/.local/bin/dl-add
aria2p --port 6800 --host http://dl.tdehaeze.xyz --secret $(pass dl.tdehaeze.xyz/tdehaeze | sed -n 1p) add $1
#+end_src
* =note-extract-fig= - Extract Figure from note file
:PROPERTIES:
:CUSTOM_ID: note-extract-fig
:END:
Script used to convert a figure drawn on my Boox note2 to a png file that can then be imported into a document.
#+begin_src bash :tangle ~/.local/bin/note-extract-fig
# First check that the first argument is a pdf file
if [[ -f $1 && $1 == *.pdf ]]; then
pngfile=$(echo $1 | cut -f 1 -d '.' | sed 's/$/.png/')
# Convert to png and crop png
pdf2png $1 && convert -trim "$pngfile" "$pngfile"
fi
#+end_src
* =color-picker= - Pick color and copy to clipboard
:PROPERTIES:
:CUSTOM_ID: color-picker
:END:
#+begin_src bash :tangle ~/.local/bin/color-picker
xcolor | tr -d '\n' | xsel -b
#+end_src #+end_src
* =readbib= - Open Bibliography File * =readbib= - Open Bibliography File

View File

@ -227,6 +227,15 @@ rofi -dmenu \
-p "$(printf "$1" | sed s/://)" -p "$(printf "$1" | sed s/://)"
#+END_SRC #+END_SRC
* =get-pass= - Get Stored Password
:PROPERTIES:
:CUSTOM_ID: get-pass
:END:
#+BEGIN_SRC bash :tangle ~/.local/bin/get-pass
pass $1 | sed -n 1p
#+END_SRC
* =screenshot= - Take Screenshot * =screenshot= - Take Screenshot
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: screenshot :CUSTOM_ID: screenshot
@ -1235,10 +1244,9 @@ fi
# Send the password to the clipboard # Send the password to the clipboard
printf "$pass" | xclip -sel clip && \ printf "$pass" | xclip -sel clip && \
dunstify 'Password' 'Generated' notify-send 'Password' 'Generated'
#+end_src #+end_src
* =sxhkd-help= - List of keybindings using Rofi * =sxhkd-help= - List of keybindings using Rofi
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: sxhkd-help :CUSTOM_ID: sxhkd-help