From 58a9e65b5554b2c9552540dfea96b562375cf321 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Mon, 2 Dec 2019 14:23:33 +0100 Subject: Mon 02 Dec 2019 02:23:33 PM CET --- asPDF.sh | 14 -------------- cmusPlay.sh | 3 ++- i3blocks/i3internet.sh | 31 +++++++++++++++++++------------ i3blocks/i3music.sh | 7 ++++--- pdfSxiv.sh | 30 ------------------------------ pdfs/asPDF.sh | 14 ++++++++++++++ pdfs/pdfSxiv.sh | 30 ++++++++++++++++++++++++++++++ pdfs/toPDF.sh | 25 +++++++++++++++++++++++++ tmuxSetups/cards | 4 ++++ 9 files changed, 98 insertions(+), 60 deletions(-) delete mode 100755 asPDF.sh delete mode 100755 pdfSxiv.sh create mode 100755 pdfs/asPDF.sh create mode 100755 pdfs/pdfSxiv.sh create mode 100755 pdfs/toPDF.sh create mode 100755 tmuxSetups/cards diff --git a/asPDF.sh b/asPDF.sh deleted file mode 100755 index 3391d43..0000000 --- a/asPDF.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -outdir="/tmp/pdf" -opener="zathura" -name="${1%.*}" -ext="${1##*.}" - -case "$ext" in - "md") - pandoc -s -o "$outdir/$name.pdf" "$1" 1>/dev/null 2>&1 ;; - *) - lowriter --convert-to pdf --outdir "$outdir" "$1" 1>/dev/null 2>&1 ;; -esac -"$opener" "$outdir/$name.pdf" diff --git a/cmusPlay.sh b/cmusPlay.sh index 64f5b2c..5a8f8fa 100755 --- a/cmusPlay.sh +++ b/cmusPlay.sh @@ -1,7 +1,8 @@ #!/bin/sh +[ -f "/usr/bin/tmux" ] && tmux="tmux new-session -s cmus" if ! pgrep -x cmus ; then - urxvt -title floating -sh 20 -geometry "185x15+30-28" -cd ~/music -e cmus + urxvt -title floating -sh 20 -geometry "185x15+30-28" -cd ~/music -e $tmux cmus else cmus-remote -u fi diff --git a/i3blocks/i3internet.sh b/i3blocks/i3internet.sh index 2f55fd2..4065a31 100755 --- a/i3blocks/i3internet.sh +++ b/i3blocks/i3internet.sh @@ -8,30 +8,37 @@ case $BLOCK_BUTTON in esac wifiDev="wlp2s0" -ethDev="enp3s0" -wstatus=$(cat /sys/class/net/$wifiDev/operstate) -estatus=$(cat /sys/class/net/$ethDev/operstate) +ethDev="" +wstatus="$(cat /sys/class/net/$wifiDev/operstate)" +estatus="$(cat /sys/class/net/$ethDev/operstate)" +tick=✅ +wifiSymbol="📶" +ethSymbol="🌐" if [ "$wstatus" = "down" ]; then wifi="❌" -elif [ "$(nmcli | grep "$wifiDev: connecting ")" ]; then - step="$(nmcli | grep "$wifiDev: connecting " | sed 's/^.*(/(/;s/).*$/)/')" - wifi="⚙️ $(nmcli | grep "$wifiDev: " | cut -d' ' -f5-) $step" +elif [ "$(nmcli | fgrep "$wifiDev: connecting ")" ]; then + step="$(nmcli | fgrep "$wifiDev: connecting " | sed 's/^.*(/(/;s/).*$/)/')" + wifi="$tick $(nmcli | fgrep "$wifiDev: " | cut -d' ' -f5-) $step" else # with IP - #wifi="✔️$(nmcli | grep "$wifiDev: connected to " | cut -d' ' -f4-) ($(ip addr show $wifiDev | grep "inet " | cut -d' ' -f6)) ($(grep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))" + #wifi="$tick$(nmcli | fgrep "$wifiDev: connected to " | cut -d' ' -f4-) ($(ip addr show $wifiDev | fgrep "inet " | cut -d' ' -f6)) ($(egrep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))" # with name - wifi="✔️ $(nmcli | grep "$wifiDev: connected to " | cut -d' ' -f4-) ($(grep "^\s*w" /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))" + wifi="$tick $(nmcli | fgrep "$wifiDev: connected to " | cut -d' ' -f4-) ($(egrep '^\s*w' /proc/net/wireless | awk '{print int($3 * 100 / 70)"%"}'))" fi -if [ -z "$(nmcli | grep $ethDev)" ]; then + +[ -z "$ethDev" ] && echo "$wifiSymbol$wifi" && exit 0 + +if [ -z "$(nmcli | fgrep "$ethDev")" ]; then en="❌❗ No $ethDev" elif [ "$estatus" = "down" ]; then en="❌" else # with IP - #en=$(ip addr show $ethDev | grep "inet " | cut -d' ' -f6) + #en=$(ip addr show $ethDev | fgrep "inet " | cut -d' ' -f6) # no IP - en=✔️ + en=$tick fi -echo "📶$wifi 🌐$en" +echo "$wifiSymbol$wifi $ethSymbol$en" +exit 0 diff --git a/i3blocks/i3music.sh b/i3blocks/i3music.sh index cad0b66..d446b50 100755 --- a/i3blocks/i3music.sh +++ b/i3blocks/i3music.sh @@ -7,18 +7,19 @@ case $BLOCK_BUTTON in esac symbol=🎵 -ampersand="I" +ampersand='and' # & in echo messes up script pgrep -x cmus >/dev/null || exit 0 stat="$(cmus-remote -Q | grep "^status " | awk '{print $2}' | sed "s/&/$ampersand/")" artist="$(cmus-remote -Q | grep "^tag artist " | cut -d' ' -f3- | sed "s/&/$ampersand/")" title="$(cmus-remote -Q | grep "^tag title " | cut -d' ' -f3- | sed "s/&/$ampersand/")" [ -z "$artist" ] && artist="(unknown)" -[ -z "$title" ] && title="$(basename "$(cmus-remote -Q | grep "^file" | cut -d' ' -f2- | sed "s/&/$ampersand/")")" # sed to fix & in title messing up script +[ -z "$title" ] && title="$(basename "$(cmus-remote -Q | grep "^file" | cut -d' ' -f2- | sed "s/&/$ampersand/")")" if [ "$stat" = "playing" ]; then - #echo "$symbol $artist ─ $title" echo "$symbol $artist ─ $title" + echo "$symbol ...$title" elif [ "$stat" = "paused" ]; then echo "$symbol ( $artist ─ $title )" + echo "$symbol ( ...$title )" else echo "$symbol $stat" fi diff --git a/pdfSxiv.sh b/pdfSxiv.sh deleted file mode 100755 index 0a63586..0000000 --- a/pdfSxiv.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -# -# pdfSxiv.sh -# -# Usage: pdfSxiv.sh FILE -# -# Opens all images of a pdf with sxiv - -[ -z "$1" ] && exit 1 - -baseDir="/tmp/pdfSxiv" -directory="${1##*/}" -directory="${directory%%.*}" -fullPath="${baseDir}/001-${directory}" -if [ -d "$fullPath" ]; then - last="$(ls "${fullPath}/.." | sort | tail -n 1)" - last="${last%%-*}" - while echo "$last" | grep -E -q '^0'; do - last="${last#0}" - done - index="$((last+1))" - while ! echo "$index" | grep -E -q '.{3}'; do - index="0$index" - done - fullPath="${baseDir}/${index}-${directory}" -fi - -mkdir -p "$fullPath" -pdfimages -png "$1" "${fullPath}/pdfSxiv" -sxiv "${fullPath}"/* diff --git a/pdfs/asPDF.sh b/pdfs/asPDF.sh new file mode 100755 index 0000000..a03f0aa --- /dev/null +++ b/pdfs/asPDF.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +outdir="/tmp/pdf" +name="${1%.*}" +ext="${1##*.}" +[ -d "$outdir" ] || mkdir -p "$outdir" + +case "$ext" in + "md") + pandoc -s -o "$outdir/$name.pdf" "$1" 1>/dev/null 2>&1 ;; + *) + lowriter --convert-to pdf --outdir "$outdir" "$1" 1>/dev/null 2>&1 ;; +esac +"$READER" "$outdir/$name.pdf" diff --git a/pdfs/pdfSxiv.sh b/pdfs/pdfSxiv.sh new file mode 100755 index 0000000..0a63586 --- /dev/null +++ b/pdfs/pdfSxiv.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# pdfSxiv.sh +# +# Usage: pdfSxiv.sh FILE +# +# Opens all images of a pdf with sxiv + +[ -z "$1" ] && exit 1 + +baseDir="/tmp/pdfSxiv" +directory="${1##*/}" +directory="${directory%%.*}" +fullPath="${baseDir}/001-${directory}" +if [ -d "$fullPath" ]; then + last="$(ls "${fullPath}/.." | sort | tail -n 1)" + last="${last%%-*}" + while echo "$last" | grep -E -q '^0'; do + last="${last#0}" + done + index="$((last+1))" + while ! echo "$index" | grep -E -q '.{3}'; do + index="0$index" + done + fullPath="${baseDir}/${index}-${directory}" +fi + +mkdir -p "$fullPath" +pdfimages -png "$1" "${fullPath}/pdfSxiv" +sxiv "${fullPath}"/* diff --git a/pdfs/toPDF.sh b/pdfs/toPDF.sh new file mode 100755 index 0000000..e4e6ece --- /dev/null +++ b/pdfs/toPDF.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# toPDF.sh +# +# Usage: toPDF.sh [-o] INPUTFILE +# +# Compiles a file to a temporal PDF using pandoc, updating the temporal file if +# it already exists. +# Opens the file with $READER if -o option is given. + +if [ "$1" = "-o" ]; then + open="1" + shift +fi + +[ -z "$1" ] && exit 1 + +targetDir="/tmp/toPDF" +sourceFile="$1" +targetFile="${targetDir}/${sourceFile##*/}" +targetFile="${targetFile%.*}.pdf" + +[ -d "$targetDir" ] || mkdir -p "$targetDir" +pandoc "$sourceFile" -o "$targetFile" +[ -n "$open" ] && "$READER" "$targetFile" & diff --git a/tmuxSetups/cards b/tmuxSetups/cards new file mode 100755 index 0000000..4658c56 --- /dev/null +++ b/tmuxSetups/cards @@ -0,0 +1,4 @@ +#!/bin/sh +tmux new-window "cd $HOME/proyects/cards/web; nvim" +tmux previous-window +ranger "$HOME/proyects/cards/" -- cgit v1.2.1