From 328c03392f34806decf9e465c77f2999ac603653 Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Sun, 5 Apr 2020 15:39:08 +0200 Subject: [PATCH] change NAS from scripts to binaries --- dotfiles/binaries.org | 173 ++++++++++++------------------------------ dotfiles/scripts.org | 42 +--------- 2 files changed, 50 insertions(+), 165 deletions(-) diff --git a/dotfiles/binaries.org b/dotfiles/binaries.org index 6df852b..72aa239 100644 --- a/dotfiles/binaries.org +++ b/dotfiles/binaries.org @@ -15,18 +15,15 @@ #+HTML_HEAD: #+HTML_HEAD: #+HTML_HEAD: + +#+PROPERTY: header-args:bash :comments both :mkdirp yes +#+PROPERTY: header-args:bash+ :shebang "#!/usr/bin/env bash" :END: * =displayselect= - Select Screen -:PROPERTIES: -:header-args: :tangle ~/bin/displayselect -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: - Script taken from Luke Smith. -#+begin_src bash +#+begin_src bash :tangle ~/bin/displayselect twoscreen() { # If multi-monitor is selected and there are two screens. mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") @@ -96,13 +93,8 @@ Script taken from Luke Smith. #+end_src * TODO =getbib= -:PROPERTIES: -:header-args: :tangle ~/bin/getbib -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/getbib [ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit if [ -f "$1" ]; then @@ -119,13 +111,8 @@ Script taken from Luke Smith. #+end_src * =vpntoggle= - Connect to VPN using NordVPN -:PROPERTIES: -:header-args: :tangle ~/bin/vpntoggle -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/vpntoggle if [[ $(nordvpn status) == *"Connected"* ]]; then nordvpn disconnect && dunstify --replace=23198 "VPN" "Disconnected"; else @@ -136,13 +123,8 @@ Script taken from Luke Smith. #+end_src * =bukurun= - Open link from Buku -:PROPERTIES: -:header-args: :tangle ~/bin/bukurun -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/bukurun _rofi () { rofi -dmenu -i -no-levenshtein-sort -width 1000 "$@" } @@ -474,14 +456,10 @@ getTagsFromId () { mode=bookmarks main #+end_src -* =i3exit= - Manage lock, suspend, reboot, ... -:PROPERTIES: -:header-args: :tangle ~/bin/i3exit -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +* =i3exit= - Manage lock, suspend, reboot, ... + +#+begin_src bash :tangle ~/bin/i3exit # with openrc use loginctl case "$1" in lock) @@ -515,39 +493,23 @@ mode=bookmarks main #+end_src * =readbib= - Open Bibliography File -:PROPERTIES: -:header-args: :tangle ~/bin/readbib -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/readbib cd ~/Cloud/thesis/ressources/pdfs/ && ls | rofi -dmenu -lines 20 | xargs -I {} zathura {} #+end_src * =readnotes= - Open Note File -:PROPERTIES: -:header-args: :tangle ~/bin/readnotes -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/readnotes cd ~/Cloud/thesis/ressources/notes/pdfs/ && ls *.pdf | rofi -dmenu -lines 20 | xargs -I {} zathura {} #+end_src * TODO askpass -:PROPERTIES: -:header-args: :tangle ~/bin/askpass-rofi -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: - - [ ] Should be a script Take password prompt from STDIN, print password to STDOUT. The sed piece just removes the colon from the provided prompt: =rofi -p= already gives us a colon -#+BEGIN_SRC bash +#+BEGIN_SRC bash :tangle ~/bin/askpass-rofi rofi -dmenu \ -password \ -no-fixed-num-lines \ @@ -555,13 +517,8 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already #+END_SRC * =screenshot= - Take Screenshot -:PROPERTIES: -:header-args: :tangle ~/bin/screenshot -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/screenshot status=$(echo -e "All\nGUI\nSelection\nCropped\nCopy\nShadow\nActive" | rofi -i -dmenu -p "Type") if [ -z "$status" ]; then exit; @@ -591,13 +548,8 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already #+end_src * =remote-desktop= - 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 +#+begin_src bash :tangle ~/bin/remote-desktop computer=$(echo -e 'RNICE\nPCMEL1\nPCNASS1\nPCMEG01' | dmenu -p 'Computer:' -l 20); case $computer in @@ -620,13 +572,8 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already #+end_src * =network-toggle= - 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 +#+begin_src bash :tangle ~/bin/network-toggle result=$(nmcli device | sed '1d' | dmenu -l 20); interface=$(echo $result | awk -F ' ' '{print $1}'); @@ -640,13 +587,8 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already #+end_src * =print-rnice= - 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 +#+begin_src bash :tangle ~/bin/print-rnice 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); @@ -661,28 +603,17 @@ The sed piece just removes the colon from the provided prompt: =rofi -p= already #+end_src * TODO Mount TMP14DAYS -:PROPERTIES: -:header-args: :tangle ~/bin/mnt_tmp_14_days -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: - - [ ] Put that as a script? -#+begin_src bash +#+begin_src bash :tangle ~/bin/mnt_tmp_14_days sudo -A mkdir ~/tmp_14_days; sudo -A mount -o rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=160.103.232.103,mountvers=3,mountport=597,mountproto=tcp,local_lock=none,addr=160.103.232.103 rnice:/hz/tmp_14_days ~/tmp_14_days; #+end_src * =make-gif= - Make GIF -:PROPERTIES: -:header-args: :tangle ~/bin/make-gif -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html -#+begin_src bash +#+begin_src bash :tangle ~/bin/make-gif palette="/tmp/palette.png" filters="fps=15,scale=320:-1:flags=lanczos" @@ -691,13 +622,8 @@ http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2 #+end_src * =yt-audio= - Download-Audio from youtube -:PROPERTIES: -:header-args: :tangle ~/bin/yt-audio -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/yt-audio if [ $TMUX ]; then tmux split -v -l 5 "cd ~/Downloads/ && youtube-dl --add-metadata -xic -f bestaudio/best $1" && tmux select-pane -U else @@ -707,13 +633,8 @@ fi #+end_src * =yt-video= - Download-Video from youtube -:PROPERTIES: -:header-args: :tangle ~/bin/yt-video -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/yt-video if [ $TMUX ]; then tmux split -v -l 5 "cd ~/Downloads/ && youtube-dl --add-metadata -ic $1" && tmux select-pane -U else @@ -722,13 +643,8 @@ else fi #+end_src * =pdf-shrink= Pdf Shrink -:PROPERTIES: -:header-args: :tangle ~/bin/pdf-shrink -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/pdf-shrink shrink () { gs \ @@ -798,13 +714,8 @@ fi check_smaller "$IFILE" "$OFILE" #+end_src * =setbg= - Set Background -:PROPERTIES: -:header-args: :tangle ~/bin/setbg -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/setbg bgloc="${XDG_CACHE_HOME:-$HOME/.cache/}/bg" [ -f "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc" @@ -814,15 +725,8 @@ fi xwallpaper --zoom "$bgloc" #+end_src * Insert Unicode Icon -:PROPERTIES: -:header-args: :tangle ~/bin/insert-unicode -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: - -#+begin_src bash - # The famous "get a menu of emojis to copy" script. +#+begin_src bash :tangle ~/bin/insert-unicode # Must have xclip installed to even show menu. xclip -h 2>/dev/null || exit 1 @@ -840,13 +744,8 @@ fi #+end_src * Insert Nerd Font Icon -:PROPERTIES: -:header-args: :tangle ~/bin/insert-nerd-fonts -:header-args+: :comments both :mkdirp yes -:header-args+: :shebang "#!/usr/bin/env bash" -:END: -#+begin_src bash +#+begin_src bash :tangle ~/bin/insert-nerd-fonts # Must have xsel installed to even show menu. xsel -h 2>/dev/null || exit 1 @@ -862,3 +761,25 @@ fi dunstify "'$chosen' copied to clipboard." & fi #+end_src +* =nas= - Interact with the NAS + +As an alternative, =sshfs= can be used: +#+begin_src bash :tangle no + sshfs -o allow_other,default_permissions nas:/Data ~/mnt/NAS +#+end_src + +#+begin_src bash :tangle ~/bin/nas + if [ $1 == "mount" ]; then + if mount /home/thomas/mnt/NAS/; then + dunstify --replace=58249 'NAS ' 'Successfully mounted' + else + dunstify --replace=58249 --urgency=critical 'NAS ' 'Error while mounted' + fi + elif [ $1 == "umount" ]; then + if umount /home/thomas/mnt/NAS/; then + dunstify --replace=58249 'NAS ' 'Successfully unmounted' + else + dunstify --replace=58249 --urgency=critical 'NAS ' 'Error while unmounted' + fi + fi +#+end_src diff --git a/dotfiles/scripts.org b/dotfiles/scripts.org index 853a2f0..34cafad 100644 --- a/dotfiles/scripts.org +++ b/dotfiles/scripts.org @@ -88,13 +88,9 @@ Finally, lock the screen using =i3lock=. #+end_src * TODO Lock / Exit / Suspend / ... -:PROPERTIES: -:header-args: :tangle ~/scripts/quit.sh -:END: - - [ ] Seems duplicated with [[file:binaries.org::*=i3exit= - Manage lock, suspend, reboot, ...][=i3exit= - Manage lock, suspend, reboot, ...]] -#+begin_src bash +#+begin_src bash :tangle ~/scripts/quit.sh option=$(echo -e "Lock\nExit\nLogout\nSuspend\nHibernate\nReboot\nShutdown" | rofi -i -dmenu) case "$option" in @@ -115,38 +111,9 @@ Finally, lock the screen using =i3lock=. esac #+end_src -* NAS - Mount -:PROPERTIES: -:header-args: :tangle ~/scripts/nas.sh -:END: - -As an alternative, =sshfs= can be used: -#+begin_src bash :tangle no - sshfs -o allow_other,default_permissions nas:/Data ~/mnt/NAS -#+end_src - -#+begin_src bash - if [ $1 == "mount" ]; then - if mount /home/thomas/mnt/NAS/; then - dunstify --replace=58249 'NAS' 'Successfully mounted' - else - dunstify --replace=58249 'NAS' 'Error while mounted' - fi - elif [ $1 == "umount" ]; then - if umount /home/thomas/mnt/NAS/; then - dunstify --replace=58249 'NAS' 'Successfully unmounted' - else - dunstify --replace=58249 'NAS' 'Error while unmounted' - fi - fi -#+end_src - * Download Torrent -:PROPERTIES: -:header-args: :tangle ~/scripts/torrent-add.sh -:END: -#+begin_src bash +#+begin_src bash :tangle ~/scripts/torrent-add.sh transmission-remote 82.64.103.2:9091 --auth tdehaeze:$(pass nas/transmission | sed -n 1p) -a $1 && \ dunstify 'Torrent' 'Successfully added' || \ dunstify 'Torrent' 'Error' @@ -283,11 +250,8 @@ Send to Emacs #+end_src * Restart Mopidy -:PROPERTIES: -:header-args: :tangle ~/scripts/mopidy-restart.sh -:END: -#+begin_src bash +#+begin_src bash :tangle ~/scripts/mopidy-restart.sh pids=( $(pgrep -f mopidy) ) for pid in "${pids[@]}"; do