Improve screen-select script

This commit is contained in:
Thomas Dehaeze 2021-10-25 14:32:51 +02:00
parent e55d95cd6e
commit 9f37a18198

View File

@ -46,9 +46,9 @@ sides=$(echo -e 'one-sided\ntwo-sided-long-edge\ntwo-sided-short-edge' | dmenu -
media=$(echo -e 'A4\nA3' | dmenu -p 'Size:' -l 20); media=$(echo -e 'A4\nA3' | dmenu -p 'Size:' -l 20);
# First copy the file to Rnice # First copy the file to Rnice
if sshpass -p "$(pass ssl.esrf.fr/dehaeze | sed -n 1p)" scp $1 dehaeze@rnice:~/Downloads/; then if sshpass -p "$(pass esrf.fr/dehaeze | sed -n 1p)" scp $1 dehaeze@rnice:/home/esrf/dehaeze/Downloads/; then
# Then print on Rnice # Then print on Rnice
sshpass -p "$(pass ssl.esrf.fr/dehaeze | sed -n 1p)" ssh dehaeze@rnice "lpr -o media=$media -o sides=$sides -o number-up=$nbpage -P ctb110c1u ~/Downloads/$1"; 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 # Finally, delete the file
else else
echo "Command Failed" echo "Command Failed"
@ -89,13 +89,13 @@ sshfs -o allow_other,default_permissions nas:/Data ~/mnt/NAS
#+begin_src bash :tangle ~/.local/bin/nas #+begin_src bash :tangle ~/.local/bin/nas
if [ $1 == "mount" ]; then if [ $1 == "mount" ]; then
if mount /home/thomas/mnt/NAS/; then if sshfs -o allow_other,default_permissions homelab:/srv/storage/ ~/mnt/NAS; then
dunstify --replace=58249 'NAS ' 'Successfully mounted' dunstify --replace=58249 'NAS ' 'Successfully mounted'
else else
dunstify --replace=58249 --urgency=critical 'NAS ' 'Error while mounted' dunstify --replace=58249 --urgency=critical 'NAS ' 'Error while mounted'
fi fi
elif [ $1 == "umount" ]; then elif [ $1 == "umount" ]; then
if umount /home/thomas/mnt/NAS/; then if umount ~/mnt/NAS/; then
dunstify --replace=58249 'NAS ' 'Successfully unmounted' dunstify --replace=58249 'NAS ' 'Successfully unmounted'
else else
dunstify --replace=58249 --urgency=critical 'NAS ' 'Error while unmounted' dunstify --replace=58249 --urgency=critical 'NAS ' 'Error while unmounted'
@ -109,7 +109,7 @@ fi
:END: :END:
#+begin_src bash :tangle ~/.local/bin/torrent-add :noweb yes #+begin_src bash :tangle ~/.local/bin/torrent-add :noweb yes
transmission-remote <<get-password(passname="ip/grenoble")>>:9091 --auth tdehaeze:$(pass nas/transmission | sed -n 1p) -a $1 && \ transmission-remote <<get-password(passname="ip/homelab")>>:9091 --auth tdehaeze:$(pass nas/transmission | sed -n 1p) -a $1 && \
dunstify 'Torrent' 'Successfully added' || \ dunstify 'Torrent' 'Successfully added' || \
dunstify 'Torrent' 'Error' dunstify 'Torrent' 'Error'
#+end_src #+end_src
@ -140,21 +140,6 @@ if [[ -f $1 && $1 == *.pdf ]]; then
fi fi
#+end_src #+end_src
* =share= - Share file with self-hosted =transfer.sh=
:PROPERTIES:
:CUSTOM_ID: share
:END:
#+begin_src bash :tangle ~/.local/bin/share
if [ $TMUX ]; then
tmux split -v -l 1 "curl --progress-bar -F\"file=@$1\" https://file.tdehaeze.xyz/ | xsel -ib && dunstify 'Upload' 'Successful' || dunstify --urgency=critical 'Upload' 'Failed';" && tmux select-pane -U
else
curl --progress-bar -F"file=@$1" https://file.tdehaeze.xyz/ | xsel -ib && \
dunstify 'Upload' 'Successful' || \
dunstify --urgency=critical 'Upload' 'Failed'
fi
#+end_src
* =screen-select= - Xrandr pre-defined scripts * =screen-select= - Xrandr pre-defined scripts
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: screen-select :CUSTOM_ID: screen-select
@ -163,24 +148,38 @@ fi
#+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\nXPS\nHome" | rofi -i -dmenu)
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 case "$option" in
"Work") "Work")
xrandr --output eDP1 --off --output DP1 --off --output DP1-1 --primary --mode 2560x1440 --pos 0x0 --rotate normal --output DP1-2 --off --output DP2 --off --output VIRTUAL1 --off xrandr --output eDP1 --off --output DP1 --off --output DP2 --off --output DP2-1 --off --output VIRTUAL1 --off --output DP2-2 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
after_screen_change
;; ;;
"XPS") "XPS")
xrandr --output eDP1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP1 --off --output DP1-1 --off --output DP1-2 --off --output DP2 --off --output VIRTUAL1 --off xrandr --output DP1 --off --output DP2 --off --output DP2-1 --off --output VIRTUAL1 --off --output DP2-2 --off --output eDP1 --primary --mode 1920x1080 --pos 0x0 --rotate normal && \
after_screen_change
;; ;;
"Home") "Home")
xrandr --output eDP1 --off --output DP2-1 --primary --mode 2560x1440 --pos 0x0 --rotate normal --output DP1 --off --output VIRTUAL1 --off xrandr --output eDP1 --off --output DP1 --off --output DP2 --off --output DP2-2 --off --output VIRTUAL1 --off --output DP2-1 --primary --mode 2560x1440 --pos 0x0 --rotate normal && \
after_screen_change
;; ;;
,*) ,*)
echo "== ! missing or invalid argument ! ==" echo "== ! missing or invalid argument ! =="
exit 2 exit 2
esac esac
setbg && \ # Fix background if screen size/arangement has changed.
polybar-msg cmd restart # restart polybar
exit 0 exit 0
#+end_src #+end_src
@ -212,5 +211,5 @@ cd ~/Cloud/pdfs/ && ls | rofi -dmenu -lines 20 | xargs -I {} zathura {}
List all =pdf= files and open selected one with zathura. List all =pdf= files and open selected one with zathura.
#+begin_src bash :tangle ~/.local/bin/readnotes #+begin_src bash :tangle ~/.local/bin/readnotes
cd ~/Cloud/brain/pdfs/ && ls | rofi -dmenu -lines 20 | xargs -I {} zathura {} cd ~/Cloud/brain/pdfs/ && ls *.pdf | rofi -dmenu -lines 20 | xargs -I {} zathura {}
#+end_src #+end_src