diff --git a/.local/bin/scripts/blaze b/.local/bin/scripts/blaze index 16f4884..1cdb338 100755 --- a/.local/bin/scripts/blaze +++ b/.local/bin/scripts/blaze @@ -4,24 +4,24 @@ # Author - Cherrry9 deps() { - [ "$1" ] && { - md="$(for i in $deps; do printf " - \033[31m%s\033[0m\n" "$i"; done)" - printf "\033[31mYou are missing dependencies\033[0m\n" - printf "%b\n" "$md" - printf "\n" - } - printf "\033[34mRequired dependencies\033[0m\n" - printf " - \033[34mffmpeg\033[0m Actually recording\n" - printf " - \033[34mdmenu\033[0m Selecting the options\n" - printf "\n" - printf "\033[35mAt least one of these is required\033[0m\n" - printf " - \033[35mxorg-xrandr\033[0m Selecting a display to record\n" - printf " - \033[35mslop\033[0m Selecting an area to record\n" - printf "\n" - printf "\033[32mOptional dependencies\033[0m\n" - printf " - \033[32mnotify-send\033[0m Letting the user know when the recording starts/ends\n" - printf " - \033[32mxdg-desktop-dir\033[0m Use directory from xdg instead \$HOME/Videos\n" - exit + [ "$1" ] && { + md="$(for i in $deps; do printf " - \033[31m%s\033[0m\n" "$i"; done)" + printf "\033[31mYou are missing dependencies\033[0m\n" + printf "%b\n" "$md" + printf "\n" + } + printf "\033[34mRequired dependencies\033[0m\n" + printf " - \033[34mffmpeg\033[0m Actually recording\n" + printf " - \033[34mdmenu\033[0m Selecting the options\n" + printf "\n" + printf "\033[35mAt least one of these is required\033[0m\n" + printf " - \033[35mxorg-xrandr\033[0m Selecting a display to record\n" + printf " - \033[35mslop\033[0m Selecting an area to record\n" + printf "\n" + printf "\033[32mOptional dependencies\033[0m\n" + printf " - \033[32mnotify-send\033[0m Letting the user know when the recording starts/ends\n" + printf " - \033[32mxdg-desktop-dir\033[0m Use directory from xdg instead \$HOME/Videos\n" + exit } # check all necessary dependencies @@ -35,9 +35,9 @@ _ xrandr || _ slop || deps="$deps xorg-xrandr/slop" # output file, use $BLAZE_DIR and $BLAZE_FILE if they are set if [ ! "$BLAZE_DIR" ]; then - _ xdg-user-dir && - BLAZE_DIR=$(xdg-user-dir VIDEOS 2>/dev/null) || - BLAZE_DIR="$HOME/Videos" + _ xdg-user-dir && + BLAZE_DIR=$(xdg-user-dir VIDEOS 2>/dev/null) || + BLAZE_DIR="$HOME/Videos" fi [ ! -d "$BLAZE_DIR" ] && mkdir -p "$BLAZE_DIR" >/dev/null 2>&1 @@ -52,172 +52,172 @@ m() { ${DMENU:-dmenu} "$@"; } # find default audio device audio() { - pacmd="$(pacmd list-sources | grep -i -B 1 output)" - dev="$(echo "$pacmd" | grep -i '\* index' || - echo "$pacmd" | grep -i 'index' | head -n 1)" - audio="-f pulse -i $(echo "$dev" | grep -o '[0-9]')" + pacmd="$(pacmd list-sources | grep -i -B 1 output)" + dev="$(echo "$pacmd" | grep -i '\* index' || + echo "$pacmd" | grep -i 'index' | head -n 1)" + audio="-f pulse -i $(echo "$dev" | grep -o '[0-9]')" } save() { - if [ -f "/tmp/blaze-pid" ]; then - recpid="$(cat /tmp/blaze-pid)" - # kill with SIGTERM, allowing finishing touches. - kill -15 "$recpid" - rm -f /tmp/blaze-pid - # even after SIGTERM, ffmpeg may still run, so SIGKILL it. - ( sleep 3; kill -9 "$recpid" ) >/dev/null 2>&1 & - echo "Recording Stopped" - notify-send -t 2000 "Recording Stopped" - exit - else - echo "Recording isn't active" - notify-send -t 2000 "Recording isn't active" - exit 1 - fi + if [ -f "/tmp/blaze-pid" ]; then + recpid="$(cat /tmp/blaze-pid)" + # kill with SIGTERM, allowing finishing touches. + kill -15 "$recpid" + rm -f /tmp/blaze-pid + # even after SIGTERM, ffmpeg may still run, so SIGKILL it. + ( sleep 3; kill -9 "$recpid" ) >/dev/null 2>&1 & + echo "Recording Stopped" + notify-send -t 2000 "Recording Stopped" + exit + else + echo "Recording isn't active" + notify-send -t 2000 "Recording isn't active" + exit 1 + fi } help() { - printf "\033[34mOptions\033[0m\n" - printf " \033[34m-o\033[0m \033[35m[]\033[0m Specify the output file\n" - printf " \033[34m-s\033[0m End the recording\n" - printf " \033[34m-h\033[0m Display what you're reading right now\n" - printf " \033[34m-d\033[0m printf dependencies\n" - printf " \033[34m-c\033[0m Don't ask if the user is ready to record\n" - printf " \033[34m-p\033[0m \033[35m[]\033[0m Save to and load from preset \n" - printf " \033[34m-r\033[0m \033[35m[]\033[0m Force framerate\n" - printf " \033[34m-b\033[0m \033[35m[]\033[0m Force bitrate (in MB)\n" - printf " \033[34m-m\033[0m \033[35m[]\033[0m Force method (slop, display)\n" - printf " \033[34m-d\033[0m \033[35m[]\033[0m Force display (Doesn't require -m)\n" - printf " \033[34m-n\033[0m Force disable NVENC\n" - printf " \033[34m-S\033[0m Options to use for slop (Needs to be quoted)\n" - printf " \033[34m-a\033[0m Record desktop audio\n" - printf "\n" - printf "To select an area, install 'slop',\n" - printf "to select a display, install 'xorg-xrandr'\n" - printf "\n" - printf "\033[35m[]\033[0m = Option requires an argument\n" - printf "\n" - printf "\033[34mVariables\033[0m\n" - printf " \033[34mBLAZE_DIR\033[0m Location to save the video\n" - printf " \033[37mDefault: xdg-user-dir VIDEOS or \$HOME/Videos\033[0m\n" - printf "\n" - printf " \033[34mBLAZE_FILE\033[0m Name of the saved video\n" - printf " \033[37mDefault: blaze-%s.mp4\033[0m\n" "\$(date +%Y-%m-%d_%H-%M-%S)" - printf "\n" - printf " \033[34mBLAZE_SLOP\033[0m Options to use for slop\n" - printf " \033[37mDefault: None\033[0m\n" - exit + printf "\033[34mOptions\033[0m\n" + printf " \033[34m-o\033[0m \033[35m[]\033[0m Specify the output file\n" + printf " \033[34m-s\033[0m End the recording\n" + printf " \033[34m-h\033[0m Display what you're reading right now\n" + printf " \033[34m-d\033[0m printf dependencies\n" + printf " \033[34m-c\033[0m Don't ask if the user is ready to record\n" + printf " \033[34m-p\033[0m \033[35m[]\033[0m Save to and load from preset \n" + printf " \033[34m-r\033[0m \033[35m[]\033[0m Force framerate\n" + printf " \033[34m-b\033[0m \033[35m[]\033[0m Force bitrate (in MB)\n" + printf " \033[34m-m\033[0m \033[35m[]\033[0m Force method (slop, display)\n" + printf " \033[34m-d\033[0m \033[35m[]\033[0m Force display (Doesn't require -m)\n" + printf " \033[34m-n\033[0m Force disable NVENC\n" + printf " \033[34m-S\033[0m Options to use for slop (Needs to be quoted)\n" + printf " \033[34m-a\033[0m Record desktop audio\n" + printf "\n" + printf "To select an area, install 'slop',\n" + printf "to select a display, install 'xorg-xrandr'\n" + printf "\n" + printf "\033[35m[]\033[0m = Option requires an argument\n" + printf "\n" + printf "\033[34mVariables\033[0m\n" + printf " \033[34mBLAZE_DIR\033[0m Location to save the video\n" + printf " \033[37mDefault: xdg-user-dir VIDEOS or \$HOME/Videos\033[0m\n" + printf "\n" + printf " \033[34mBLAZE_FILE\033[0m Name of the saved video\n" + printf " \033[37mDefault: blaze-%s.mp4\033[0m\n" "\$(date +%Y-%m-%d_%H-%M-%S)" + printf "\n" + printf " \033[34mBLAZE_SLOP\033[0m Options to use for slop\n" + printf " \033[37mDefault: None\033[0m\n" + exit } while getopts ':hdscb:m:r:nD:S:p:ao:' opt; do - case "$opt" in - h) - help;; - d) - deps;; - s) - save;; - c) - ready='yes';; - b) - bitrate="-b:v ${OPTARG}M";; - m) - method="$OPTARG";; - r) - rate="$OPTARG";; - n) - nvenc=' ';; - D) - display="$OPTARG" - method='display';; - S) - sloptions="$OPTARG" - method='selection';; - p) - preset="$OPTARG";; - a) - audio;; - o) - output="$OPTARG";; - \?) - echo "Invalid Option: -$OPTARG" 1>&2 - exit 1;; - :) - echo "Invalid Option: -$OPTARG requires an argument" 1>&2 - exit 1;; - esac + case "$opt" in + h) + help;; + d) + deps;; + s) + save;; + c) + ready='yes';; + b) + bitrate="-b:v ${OPTARG}M";; + m) + method="$OPTARG";; + r) + rate="$OPTARG";; + n) + nvenc=' ';; + D) + display="$OPTARG" + method='display';; + S) + sloptions="$OPTARG" + method='selection';; + p) + preset="$OPTARG";; + a) + audio;; + o) + output="$OPTARG";; + \?) + echo "Invalid Option: -$OPTARG" 1>&2 + exit 1;; + :) + echo "Invalid Option: -$OPTARG requires an argument" 1>&2 + exit 1;; + esac done shift $((OPTIND -1)) # exit if blaze is running [ -f /tmp/blaze-pid ] && { - echo "Blaze is already running, exiting." - notify-send "Blaze is already running, exiting." - exit + echo "Blaze is already running, exiting." + notify-send "Blaze is already running, exiting." + exit } [ "$preset" ] && { - # create preset location - mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}" + # create preset location + mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}" - # load preset - preset_location="${XDG_CONFIG_HOME:-$HOME/.config}"/blaze/"$preset" - [ -f "$preset_location" ] && - . "$preset_location" + # load preset + preset_location="${XDG_CONFIG_HOME:-$HOME/.config}"/blaze/"$preset" + [ -f "$preset_location" ] && + . "$preset_location" } # ask the user what method they want to use [ ! "$method" ] && { - # Check if the user has slop and disputils - _ slop && s=s - _ xrandr && d=d + # Check if the user has slop and disputils + _ slop && s=s + _ xrandr && d=d - # if the user only has slop or disputils (But not both) use that - [ "$s" ] && method=selection - [ "$d" ] && method=display + # if the user only has slop or disputils (But not both) use that + [ "$s" ] && method=selection + [ "$d" ] && method=display - # if the user has both slop and disputils ask the user which one to use - [ "$s" ] && [ "$d" ] && - method="$(printf "display\nselection" | m -p "Method of recording")" + # if the user has both slop and disputils ask the user which one to use + [ "$s" ] && [ "$d" ] && + method="$(printf "display\nselection" | m -p "Method of recording")" } if [ "$method" = display ]; then - # get information about the display - monitors="$(xrandr --listmonitors | awk 'NR>1 { printf $NF"\n" }')" + # get information about the display + monitors="$(xrandr --listmonitors | awk 'NR>1 { printf $NF"\n" }')" - # if there's only one display, use that and skip asking - if [ "$(printf "%b\n" "$monitors" | wc -l)" = 1 ]; then - display="$monitors" - else # if there are other displays ask the user which one to use - [ ! "$display" ] && display="$(printf "%b" "$monitors" | m -p "Display to record")" - fi + # if there's only one display, use that and skip asking + if [ "$(printf "%b\n" "$monitors" | wc -l)" = 1 ]; then + display="$monitors" + else # if there are other displays ask the user which one to use + [ ! "$display" ] && display="$(printf "%b" "$monitors" | m -p "Display to record")" + fi - set -- $(xrandr -q | grep "$display" | grep -oP '\d*x\d*\+\d*\+\d*' | tr '+x' ' ') + set -- $(xrandr -q | grep "$display" | grep -oP '\d*x\d*\+\d*\+\d*' | tr '+x' ' ') - width="$1" - height="$2" - offX="$3" - offY="$4" + width="$1" + height="$2" + offX="$3" + offY="$4" elif [ "$method" = selection ] || [ "$method" = slop ]; then - # select an area and make each number a separate word - set -- $(slop $sloptions -f '%w %h %x %y') + # select an area and make each number a separate word + set -- $(slop $sloptions -f '%w %h %x %y') - # get information about the display - width="$1" - height="$2" - offX="$3" - offY="$4" + # get information about the display + width="$1" + height="$2" + offX="$3" + offY="$4" - [ "$(( width % 2 ))" = 1 ] && width="$(( width + 1 ))" - [ "$(( height % 2 ))" = 1 ] && height="$(( height + 1 ))" + [ "$(( width % 2 ))" = 1 ] && width="$(( width + 1 ))" + [ "$(( height % 2 ))" = 1 ] && height="$(( height + 1 ))" else - printf "Invalid method; exiting\n" - exit 1 + printf "Invalid method; exiting\n" + exit 1 fi @@ -233,7 +233,7 @@ fi # save preset [ "$preset_location" ] && { - cat >"$preset_location"<"$preset_location"< /tmp/blaze-pid + echo $! > /tmp/blaze-pid } diff --git a/.local/bin/scripts/choosewall b/.local/bin/scripts/choosewall index d8afc06..7c5a168 100755 --- a/.local/bin/scripts/choosewall +++ b/.local/bin/scripts/choosewall @@ -1,9 +1,9 @@ #!/bin/sh if [ "$(cat /etc/hostname)" = "pc" ]; then - res="1920x1080" + res="1920x1080" elif [ "$(cat /etc/hostname)" = "laptop" ]; then - res="1366x768" + res="1366x768" fi find ~/.config/wallpapers/"$res"/* | shuf | sxiv - -tb diff --git a/.local/bin/scripts/colors b/.local/bin/scripts/colors index 266d500..295eaf8 100755 --- a/.local/bin/scripts/colors +++ b/.local/bin/scripts/colors @@ -5,7 +5,7 @@ x="$(tput op)" y=$(printf %76s) for i in {0..256}; do - o=00$i - echo -e ${o:${#o}-3:3} "$(tput setaf "$i";tput setab "$i")" "${y// /=}$x" + o=00$i + echo -e ${o:${#o}-3:3} "$(tput setaf "$i";tput setab "$i")" "${y// /=}$x" done diff --git a/.local/bin/scripts/dbar b/.local/bin/scripts/dbar index 670c044..5ad3ffa 100755 --- a/.local/bin/scripts/dbar +++ b/.local/bin/scripts/dbar @@ -6,12 +6,12 @@ sym="|" cd "$HOME/.local/bin/scripts/dwmbar/" || exit 1 status() { - echo "$(./torrent) $sym $(./disk) $sym $(./internet) $sym $(./lamp) $sym $(./music) $sym" \ - "$(./alsa) $sym $(./packages) $sym $(./date) $sym $(./clock)" + echo "$(./torrent) $sym $(./disk) $sym $(./internet) $sym $(./lamp) $sym $(./music) $sym" \ + "$(./alsa) $sym $(./packages) $sym $(./date) $sym $(./clock)" } while :; do - xsetroot -name " $(status | tr '\n' ' ')" + xsetroot -name " $(status | tr '\n' ' ')" - sleep "$delay" + sleep "$delay" done diff --git a/.local/bin/scripts/dwmbar/alsa b/.local/bin/scripts/dwmbar/alsa index 340d397..c4680ea 100755 --- a/.local/bin/scripts/dwmbar/alsa +++ b/.local/bin/scripts/dwmbar/alsa @@ -1,9 +1,9 @@ #!/bin/sh [ "$(amixer sget Master | awk 'NR==5 { print $6 }')" = "[off]" ] && { - echo " mut" && exit 1 + echo " mut" && exit 1 } - + level=$(amixer sget Master | awk -F"[][]" '/dB/ { print $2 }') revel="${level%?}" @@ -13,11 +13,11 @@ v2="" v3="" if [ "$revel" -lt 20 ]; then - echo "$v1" + echo "$v1" elif [ "$revel" -lt 50 ]; then - echo "$v2" + echo "$v2" elif [ "$revel" -lt 75 ]; then - echo "$v3" + echo "$v3" fi echo "$level" diff --git a/.local/bin/scripts/dwmbar/disk b/.local/bin/scripts/dwmbar/disk index 791bd4d..328126b 100755 --- a/.local/bin/scripts/dwmbar/disk +++ b/.local/bin/scripts/dwmbar/disk @@ -1,7 +1,7 @@ #!/bin/sh used() { - df -h "$1" | awk 'NR==2 { print $3 "/" $2 " GB" }' | sed 's/G\//\//g;s/G / /g' + df -h "$1" | awk 'NR==2 { print $3 "/" $2 " GB" }' | sed 's/G\//\//g;s/G / /g' } root="$(used /)" diff --git a/.local/bin/scripts/dwmbar/internet b/.local/bin/scripts/dwmbar/internet index 05f358c..f4578dd 100755 --- a/.local/bin/scripts/dwmbar/internet +++ b/.local/bin/scripts/dwmbar/internet @@ -1,11 +1,11 @@ #!/bin/sh if [ "$(cat /etc/hostname)" = "pc" ]; then - ip="$(eth-ip)" - echo "" + ip="$(eth-ip)" + echo "" elif [ "$(cat /etc/hostname)" = "laptop" ]; then - ip="$(wifi-ip)" - echo "" + ip="$(wifi-ip)" + echo "" fi ping -q -c 1 1.1.1.1 >/dev/null || { echo "dis" && exit 1; } diff --git a/.local/bin/scripts/dwmbar/music b/.local/bin/scripts/dwmbar/music index fc99166..276a776 100755 --- a/.local/bin/scripts/dwmbar/music +++ b/.local/bin/scripts/dwmbar/music @@ -2,10 +2,10 @@ echo "" if mpc status | grep -q "playing"; then - mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[playing\\].*//g" + mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[playing\\].*//g" elif mpc status | grep -q "paused"; then - echo "" + echo "" else - echo "" + echo "" fi diff --git a/.local/bin/scripts/dwmbar/torrent b/.local/bin/scripts/dwmbar/torrent index bf87852..90a597b 100755 --- a/.local/bin/scripts/dwmbar/torrent +++ b/.local/bin/scripts/dwmbar/torrent @@ -9,10 +9,10 @@ per="$(data | awk '{ print $2 }')" [ "${per%?}" != 100 ] && echo "$per" || echo "" data | \ - sed " - s/.*Stopped.*//g; - s/.*Seeding.*//g; - s/.*Idle.*//g; - s/.*Uploading.*//g; - s/.*%.*//g - " + sed " + s/.*Stopped.*//g; + s/.*Seeding.*//g; + s/.*Idle.*//g; + s/.*Uploading.*//g; + s/.*%.*//g + " diff --git a/.local/bin/scripts/refbar b/.local/bin/scripts/refbar new file mode 100755 index 0000000..7794263 --- /dev/null +++ b/.local/bin/scripts/refbar @@ -0,0 +1,3 @@ +#!/bin/sh + +pkill -SIGTRAP dbar && dbar &