From 51810b5c07e20982ebdf66f0bfb384c4bf55ad7d Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 22 Jul 2020 08:04:08 +0530 Subject: squash again --- scripts/scripts/2bws.sh | 40 ++++++++++++++++++++++ scripts/scripts/bar.sh | 75 +++++++++++++++++++++++++++++++++++++++++ scripts/scripts/bat | 56 ++++++++++++++++++++++++++++++ scripts/scripts/bluetooth.sh | 14 ++++++++ scripts/scripts/blur.sh | 25 ++++++++++++++ scripts/scripts/cmusnp.sh | 45 +++++++++++++++++++++++++ scripts/scripts/date.sh | 4 +++ scripts/scripts/doot | 53 +++++++++++++++++++++++++++++ scripts/scripts/draw.sh | 11 ++++++ scripts/scripts/get_xres | 3 ++ scripts/scripts/hidebars.sh | 23 +++++++++++++ scripts/scripts/img.sh | 32 ++++++++++++++++++ scripts/scripts/music.sh | 16 +++++++++ scripts/scripts/netwrk.sh | 10 ++++++ scripts/scripts/playpause.sh | 17 ++++++++++ scripts/scripts/popups/cover.sh | 14 ++++++++ scripts/scripts/record | 23 +++++++++++++ scripts/scripts/restartbars.sh | 6 ++++ scripts/scripts/time.sh | 6 ++++ scripts/scripts/tmux-fzf.sh | 15 +++++++++ scripts/scripts/up | 20 +++++++++++ scripts/scripts/url.sh | 4 +++ scripts/scripts/vol | 21 ++++++++++++ scripts/scripts/wscycle.sh | 30 +++++++++++++++++ scripts/scripts/zatheme.sh | 37 ++++++++++++++++++++ 25 files changed, 600 insertions(+) create mode 100755 scripts/scripts/2bws.sh create mode 100755 scripts/scripts/bar.sh create mode 100755 scripts/scripts/bat create mode 100755 scripts/scripts/bluetooth.sh create mode 100755 scripts/scripts/blur.sh create mode 100755 scripts/scripts/cmusnp.sh create mode 100755 scripts/scripts/date.sh create mode 100755 scripts/scripts/doot create mode 100755 scripts/scripts/draw.sh create mode 100755 scripts/scripts/get_xres create mode 100755 scripts/scripts/hidebars.sh create mode 100755 scripts/scripts/img.sh create mode 100755 scripts/scripts/music.sh create mode 100755 scripts/scripts/netwrk.sh create mode 100755 scripts/scripts/playpause.sh create mode 100755 scripts/scripts/popups/cover.sh create mode 100755 scripts/scripts/record create mode 100755 scripts/scripts/restartbars.sh create mode 100755 scripts/scripts/time.sh create mode 100755 scripts/scripts/tmux-fzf.sh create mode 100755 scripts/scripts/up create mode 100755 scripts/scripts/url.sh create mode 100755 scripts/scripts/vol create mode 100755 scripts/scripts/wscycle.sh create mode 100755 scripts/scripts/zatheme.sh (limited to 'scripts') diff --git a/scripts/scripts/2bws.sh b/scripts/scripts/2bws.sh new file mode 100755 index 0000000..6f81baa --- /dev/null +++ b/scripts/scripts/2bws.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# display workspace status +# requires wmctrl + +# get the current workspace +ws=$( xprop -root _NET_CURRENT_DESKTOP | sed -e 's/_NET_CURRENT_DESKTOP(CARDINAL) = //' ) + +# icons +CURRENT=● +OCCUPIED=● +UNOCCUPIED=· + +# colors +current="$( ~/scripts/get_xres color5 )" +occupied="$( ~/scripts/get_xres color8 )" +unoccupied="$( ~/scripts/get_xres color8 )" + +# print workspaces to stdout +draw() { + for i in {0..5}; do + # get the number of windows in each workspace + windows=$( wmctrl -l | cut -d ' ' -f3 | grep $i | wc -l ) + + + if [[ $i -eq $ws ]] + then + # current workspace + echo -ne "%{F$current} $CURRENT " + else + if [[ $windows -eq 0 ]] + then + echo -ne "%{F$unoccupied} $UNOCCUPIED " + else + echo -ne "%{F$occupied} $OCCUPIED " + fi + fi + done +} + +draw diff --git a/scripts/scripts/bar.sh b/scripts/scripts/bar.sh new file mode 100755 index 0000000..1903462 --- /dev/null +++ b/scripts/scripts/bar.sh @@ -0,0 +1,75 @@ +#! /usr/bin/env bash + + +fg="$(get_xres color15)" +fg_light="$(get_xres color10)" +bg="$(get_xres color0)" +# %{F$fg} $(date +%d/%m) %{F$fg_light} $(date +%Y) + +(while true; do echo -e "\n$(date +%H)\n$(date +%M)\n"; sleep 10; done) | dzen2 \ + -e "onstart=uncollapse;" \ + -fg "$fg" \ + -bg "$fg_light" \ + -tw 0 \ + -l 3 \ + -x 20 \ + -y 600 \ + -w 70 \ + -h 30 \ + -sa c \ + -p & + +(echo -e "\n"; while true; do echo -e "$(bat -i)"; sleep 1; done )| dzen2 \ + -e "onstart=uncollapse;" \ + -fg "$fg" \ + -bg "$fg_light" \ + -tw 70 \ + -l 4 \ + -x 20 \ + -y 500 \ + -w 70 \ + -h 15 \ + -sa c \ + -p & + +ws=$( xprop -root _NET_CURRENT_DESKTOP | sed -e 's/_NET_CURRENT_DESKTOP(CARDINAL) = //' ) + +# colors +current="$( ~/scripts/get_xres color5 )" +occupied="$( ~/scripts/get_xres color8 )" +unoccupied="$( ~/scripts/get_xres color8 )" + +# print workspaces to stdout +draw() { + for i in {0..5}; do + # get the number of windows in each workspace + windows=$( wmctrl -l | cut -d ' ' -f3 | grep $i | wc -l ) + + + if [[ $i -eq $ws ]] + then + # current workspace + echo -ne "^($current)O" + else + if [[ $windows -eq 0 ]] + then + echo -ne "^($unoccupied)o" + else + echo -ne "^($occupied)x" + fi + fi + done +} + +# echo -e "\n\n$(draw)\n" | dzen2 \ +# -e "onstart=uncollapse;" \ +# -fg "$fg" \ +# -bg "$fg_light" \ +# -tw 70 \ +# -l 4 \ +# -x 20 \ +# -y 500 \ +# -w 70 \ +# -h 15 \ +# -sa c \ +# -p & diff --git a/scripts/scripts/bat b/scripts/scripts/bat new file mode 100755 index 0000000..6746d82 --- /dev/null +++ b/scripts/scripts/bat @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +red="\e[31m" +grn="\e[32m" +ylw="\e[33m" +cyn="\e[36m" +blu="\e[34m" +prp="\e[35m" +bprp="\e[35;1m" +rst="\e[0m" + +icon="$( ~/scripts/get_xres color4 )" +fg="$( ~/scripts/get_xres color8 )" + +bat_status="" +bat_status=$( cat /sys/class/power_supply/BAT0/capacity ) +charging_status=$( cat /sys/class/power_supply/BAT0/status ) + +health() { + for i in {0..4} + do + if [[ $i -le $(( $bat_status/20 )) ]]; then + echo -ne "#[fg=colour1]• " + else + echo -ne "#[fg=colour8]• " + fi + done + echo +} + +bat_status_small() { + if [[ "$charging_status" = *Charging* ]]; then + echo -ne "+$bat_status%" + else + echo -ne "$bat_status%" + fi +} + +[ -z "$1" ] && { + bat_status_small +} + +while getopts qi options +do + case $options in + i) + bat_status_small + ;; + q) + if [[ "$charging_status" = *Charging* ]]; then + echo -ne "+ $(health)" + else + health + fi + esac +done diff --git a/scripts/scripts/bluetooth.sh b/scripts/scripts/bluetooth.sh new file mode 100755 index 0000000..85b7f08 --- /dev/null +++ b/scripts/scripts/bluetooth.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +connections=$( hcitool con ) +devices=$( hcitool dev | wc -l ) + +if [ $devices = 1 ] +then + echo -n "" +elif [[ $devices > 1 && $connections = "Connections:" ]] +then + echo -n "" +else + echo -n "" +fi diff --git a/scripts/scripts/blur.sh b/scripts/scripts/blur.sh new file mode 100755 index 0000000..9349b03 --- /dev/null +++ b/scripts/scripts/blur.sh @@ -0,0 +1,25 @@ +#! /usr/bin/env bash + +state="unblurred" +while :; do + current_workspace="$(xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}')" + if [[ -n "$current_workspace" ]]; then + num_windows="$(echo "$(wmctrl -l)" | awk -F" " '{print $2}' | grep ^$current_workspace)" + if [ -n "$num_windows" ]; then + if [ "$state" != "blurred" ]; then + for i in {0..6}; do + feh --bg-fill ~/pics/blurs/busy"$i".jpg + done + fi + state="blurred" + else + if [ "$state" != "unblurred" ]; then + for i in $(seq 5 -1 0); do + feh --bg-fill ~/pics/blurs/busy"$i".jpg + done + feh --bg-fill ~/pics/blurs/busy.jpg + fi + state="unblurred" + fi + fi +done diff --git a/scripts/scripts/cmusnp.sh b/scripts/scripts/cmusnp.sh new file mode 100755 index 0000000..b43c7e8 --- /dev/null +++ b/scripts/scripts/cmusnp.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Display currently playing song from cmus +# Requires cmus + +# colors +active="$( ~/scripts/get_xres color7 )" +inactive="$( ~/scripts/get_xres color7 )" + +np_string="" + +trunc() { + max_length=$1 + text=$2 + length=${#text} + (( length > max_length )) && + text=${text::$(( max_length ))}... + echo "$text" +} + +if pgrep -x "cmus" > /dev/null +then + status=$( cmus-remote -Q | grep status\ | sed 's/status //' ) + artist=$( cmus-remote -Q | grep tag\ artist\ | sed 's/tag artist //' ) + title=$( cmus-remote -Q | grep tag\ title\ | sed 's/tag title //' ) + + np_string="$title - $artist" + np_string=$( trunc 35 "$np_string" ) + + spc=$(( $(( 32 - ${#np_string} ))/2 )) + spc="$( printf "%${spc}s" )" + + if [[ "$status" = *playing* ]] + then + echo -ne "%{F#FF0000}%{F#FFFFFF}PAUSE" + elif [[ "$status" = *paused* ]] + then + echo -ne "PLAY" + elif [[ "$status" = *stopped* ]] + then + echo -ne "START" + fi + +else + echo +fi diff --git a/scripts/scripts/date.sh b/scripts/scripts/date.sh new file mode 100755 index 0000000..f97bdc9 --- /dev/null +++ b/scripts/scripts/date.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +month="$(date +%B)" +printf "%s $(date +%e) $(date +%Y)" "${month^^}" diff --git a/scripts/scripts/doot b/scripts/scripts/doot new file mode 100755 index 0000000..defb363 --- /dev/null +++ b/scripts/scripts/doot @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +red="\e[31m" +grn="\e[32m" +ylw="\e[33m" +cyn="\e[36m" +blu="\e[34m" +prp="\e[35m" +bprp="\e[35;1m" +gry="\e[94m" +rst="\e[0m" + +COL=$(tput cols) +ROW=$(tput lines) +((PADY = ROW / 2 - 1 - ${#ENTS[@]} / 2)) +((PADX = COL / 2 - LEN / 2)) + +for ((i = 0; i < PADX; ++i)); do + PADC="$PADC " +done + +for ((i = 0; i < PADY; ++i)); do + PADR="$PADR\n" +done +clear +printf "%b" "$PADR" + +echo -ne "$ylw$PADC" +echo -e ' _/_' +echo -n "$PADC" +echo -n '/' +echo -ne "$rst" +echo -n '`▅_▅'\''' +echo -ne "$ylw" +echo '\' +echo -n "$PADC" +echo -n '\' +echo -ne "$prp" +echo -ne ' vwv ' +echo -ne "$ylw" +echo -e '/' +echo -n "$PADC" +echo -n ' `---'\''' + +echo -e "$rst" + +for ((i = 0; i < PADX - 5; ++i)); do + PADT="$PADT " +done + +echo "$PADT$USER @ $HOSTNAME" +echo "$PADT$(uptime -p)" + +read x diff --git a/scripts/scripts/draw.sh b/scripts/scripts/draw.sh new file mode 100755 index 0000000..8e34904 --- /dev/null +++ b/scripts/scripts/draw.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Spawn terminals interactively +# Requires slop, urxvt + +read -r X Y W H < <(slop -f "%x %y %w %h" -b 4 -c 0.8,0.8,0.8,0.8 -t 0 ) +(( W /= 14 )) +(( H /= 25 )) + +g=${W}x${H}+${X}+${Y} + +urxvtc -geometry $g diff --git a/scripts/scripts/get_xres b/scripts/scripts/get_xres new file mode 100755 index 0000000..9276ef4 --- /dev/null +++ b/scripts/scripts/get_xres @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +xrdb -query | grep -w $1 | awk '{print $2}' diff --git a/scripts/scripts/hidebars.sh b/scripts/scripts/hidebars.sh new file mode 100755 index 0000000..6f449d6 --- /dev/null +++ b/scripts/scripts/hidebars.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +pkill n30f +while getopts hs options +do + case $options in + h) # hide + pkill -f polybar\ artist + pkill -f polybar\ track + pkill -f polybar\ album + ;; + s) # show + if pgrep -f polybar\ artist > /dev/null; then + ~/scripts/popups/cover.sh + else + polybar artist & + polybar track & + polybar album & + ~/scripts/popups/cover.sh + fi + ;; + esac +done diff --git a/scripts/scripts/img.sh b/scripts/scripts/img.sh new file mode 100755 index 0000000..baea386 --- /dev/null +++ b/scripts/scripts/img.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# z3bra -- 2014-01-21 +# http://blog.z3bra.org/2014/01/images-in-terminal.html + +test -z "$1" && exit + +W3MIMGDISPLAY="/usr/lib/w3m/w3mimgdisplay" +FILENAME=$1 +FONTH=14 # Size of one terminal row +FONTW=8 # Size of one terminal column +COLUMNS=`tput cols` +LINES=`tput lines` + +read width height <<< `echo -e "5;$FILENAME" | $W3MIMGDISPLAY` + +max_width=$(($FONTW * $COLUMNS)) +max_height=$(($FONTH * $(($LINES - 2)))) # substract one line for prompt + +if test $width -gt $max_width; then +height=$(($height * $max_width / $width)) +width=$max_width +fi +if test $height -gt $max_height; then +width=$(($width * $max_height / $height)) +height=$max_height +fi + +w3m_command="0;1;0;0;$width;$height;;;;;$FILENAME\n4;\n3;" + +tput cup $(($height/$FONTH)) 0 +echo -e $w3m_command|$W3MIMGDISPLAY diff --git a/scripts/scripts/music.sh b/scripts/scripts/music.sh new file mode 100755 index 0000000..1de3bc0 --- /dev/null +++ b/scripts/scripts/music.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +while getopts abt options +do + case $options in + a) + cmus-remote -Q | grep tag\ artist\ | sed 's/tag artist //' + ;; + b) + cmus-remote -Q | grep tag\ album\ | sed 's/tag album //' + ;; + t) + cmus-remote -Q | grep tag\ title\ | sed 's/tag title //' + ;; + esac +done diff --git a/scripts/scripts/netwrk.sh b/scripts/scripts/netwrk.sh new file mode 100755 index 0000000..4fec3a5 --- /dev/null +++ b/scripts/scripts/netwrk.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +status=$( nmcli | sed -n 1p | awk '{print $2}' ) + +if [ $status = "connected" ] +then + echo -n '' +else + echo -n '' +fi diff --git a/scripts/scripts/playpause.sh b/scripts/scripts/playpause.sh new file mode 100755 index 0000000..72ba0fb --- /dev/null +++ b/scripts/scripts/playpause.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Interactive polybar icon for music controls +# Requires cmus + +if pgrep -x "cmus" > /dev/null +then + status=$( cmus-remote -Q | grep status\ | sed 's/status //' ) + if [[ "$status" == *playing* ]]; then + echo -ne " %{F$(get_xres color2)} " + elif [[ "$status" == *paused* ]]; then + echo -ne " %{F$(get_xres color2)} " + elif [[ "$status" == *stopped* ]]; then + echo -ne " %{F$(get_xres color2)} " + fi +else + echo -ne "  " +fi diff --git a/scripts/scripts/popups/cover.sh b/scripts/scripts/popups/cover.sh new file mode 100755 index 0000000..356e5ba --- /dev/null +++ b/scripts/scripts/popups/cover.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +folder=$( cmus-remote -Q | grep -w file | sed 's/file //' ) +cover=${folder%/*}/cover.png + +convert "$cover" -resize 200x200 ~/tmp/cover.png + +if pgrep n30f > /dev/null +then + pkill n30f + n30f -x 20 -y 700 ~/tmp/cover.png -c "hidebars.sh -h" -d +else + n30f -x 20 -y 700 ~/tmp/cover.png -c "hidebars.sh -h" -d +fi diff --git a/scripts/scripts/record b/scripts/scripts/record new file mode 100755 index 0000000..bc59fb7 --- /dev/null +++ b/scripts/scripts/record @@ -0,0 +1,23 @@ +#!/bin/bash +slop=$(slop -f "%x %y %w %h %g %i") || exit 1 +read -r X Y W H G ID < <(echo $slop) +ffmpeg \ + -f x11grab \ + -s "$W"x"$H" \ + -i :0.0+$X,$Y \ + -f alsa \ + -thread_queue_size 512 \ + -ac 2 \ + -ar 48000 \ + -i hw:0 \ + -framerate 60 \ + -vcodec libx264 \ + -threads 4 \ + -y \ + "$HOME"/tmp/x.mkv + +ffmpeg \ + -i "$HOME"/tmp/x.mkv \ + -pix_fmt yuv420p \ + -vf scale=-2:1080 \ + "/home/np/vids/rec/$1" diff --git a/scripts/scripts/restartbars.sh b/scripts/scripts/restartbars.sh new file mode 100755 index 0000000..44d339f --- /dev/null +++ b/scripts/scripts/restartbars.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +pkill polybar +polybar time & +polybar date & +polybar music & diff --git a/scripts/scripts/time.sh b/scripts/scripts/time.sh new file mode 100755 index 0000000..66b0fbe --- /dev/null +++ b/scripts/scripts/time.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +fg="$(get_xres color15)" +fg_light="$(get_xres color8)" +# %{F$fg} $(date +%d/%m) %{F$fg_light} $(date +%Y) +echo -ne "$(date +%p) $(date +%I:%M)" diff --git a/scripts/scripts/tmux-fzf.sh b/scripts/scripts/tmux-fzf.sh new file mode 100755 index 0000000..9caa7ea --- /dev/null +++ b/scripts/scripts/tmux-fzf.sh @@ -0,0 +1,15 @@ +#! /usr/bin/env bash + +function __fzf() { + fzf --cycle --height 7 --reverse +} + +function __list_to_fzf() { + tmux ls -F "#{session_name}" | __fzf +} + +if [ -n "$TMUX" ]; then + tmux switch-client -t "$(__list_to_fzf)" +else + tmux a -dt "$(tmux ls -F "#{session_name}" | __fzf)" +fi diff --git a/scripts/scripts/up b/scripts/scripts/up new file mode 100755 index 0000000..6b9ece4 --- /dev/null +++ b/scripts/scripts/up @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +id=$( cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 2 | head -n 1 ) + +if [ $# != 1 ]; then + echo "needs an arg" +else + if [ -f "$1" ]; then + ext="${1##*.}" + id="$id.$ext" + scp -P 22222 "$1" ferrn:~/www/nerd/uploads/"$id" + echo "https://u.peppe.rs/$id" + if hash xclip 2> /dev/null; then + echo "https://u.peppe.rs/$id" | xclip -selection clipboard + echo "https://u.peppe.rs/$id" | xclip -i + fi + else + echo "file does not exist" + fi +fi diff --git a/scripts/scripts/url.sh b/scripts/scripts/url.sh new file mode 100755 index 0000000..6b3264d --- /dev/null +++ b/scripts/scripts/url.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash + +echo "$1" | xclip -i +echo "$1" | xclip -sel c diff --git a/scripts/scripts/vol b/scripts/scripts/vol new file mode 100755 index 0000000..8ed96da --- /dev/null +++ b/scripts/scripts/vol @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +fg="$( ~/scripts/get_xres color7 )" +icon="$( ~/scripts/get_xres color2 )" + +while getopts idq options +do + case $options in + i) + amixer sset Master 2%+ + ;; + + d) + amixer sset Master 2%- + ;; + q) + cur_vol=$( amixer sget Master | awk -F"[][]" '/dB/ { print $2 }' ) + echo " %{F$fg}$cur_vol" + ;; + esac +done diff --git a/scripts/scripts/wscycle.sh b/scripts/scripts/wscycle.sh new file mode 100755 index 0000000..7ea608d --- /dev/null +++ b/scripts/scripts/wscycle.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# cycle through workspaces + +# get the current ws +ws=$( xprop -root _NET_CURRENT_DESKTOP | sed -e 's/_NET_CURRENT_DESKTOP(CARDINAL) = //' ) +total=5 + +while getopts fr options +do + case $options in + f) + if [[ $ws -eq $total ]] + then + wmctrl -s 0 + else + ws=$(( $ws + 1 )) + wmctrl -s $ws + fi + ;; + r) + if [[ $ws -eq 0 ]] + then + wmctrl -s $total + else + ws=$(( $ws - 1 )) + wmctrl -s $ws + fi + ;; + esac +done diff --git a/scripts/scripts/zatheme.sh b/scripts/scripts/zatheme.sh new file mode 100755 index 0000000..4cda119 --- /dev/null +++ b/scripts/scripts/zatheme.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + + +echo 'set incremental-search true + +set recolor "true" + +set default-bg "'$( get_xres color0 )'" +set default-fg "'$( get_xres color7 )'" + +set completion-bg "'$( get_xres color0 )'" +set completion-fg "'$( get_xres color7 )'" +set completion-highlight-bg "'$( get_xres color5 )'" +set completion-highlight-fg "'$( get_xres color7 )'" + +set statusbar-bg "'$( get_xres color0 )'" +set statusbar-fg "'$( get_xres color7 )'" + +set inputbar-bg "'$( get_xres color0 )'" +set inputbar-fg "'$( get_xres color7 )'" + +set recolor-darkcolor "'$( get_xres color7 )'" +set recolor-lightcolor "'$( get_xres color0 )'" + +set window-height "800" +set window-width "600" + +set adjust-open "width" +set smooth-scroll true +set statusbar-home-tilde "true" +set statusbar-h-padding "50" +set statusbar-v-padding "50" +set guioptions "s" + +set font "Input 10" + +' > ~/.config/zathura/zathurarc -- cgit v1.2.3