usr

Modulate your userpace into POSIX-compliant shell scripts!
git clone git://clone.theohenson.com/usr.git
Log | Files | Refs | README

commit 6ee7fe3646296d9e87dd8146924400c5e3d9e6c5
parent bcca505849ce332635652e90caef5c3d13a39660
Author: Theo Henson <[email protected]>
Date:   Sat, 14 Nov 2020 22:41:35 -0500

Add 'home/.local/bin/opt/' from commit '509258e11d0f4d3b503dea00a369b25b620ecf9e'

git-subtree-dir: home/.local/bin/opt
git-subtree-mainline: bcca505849ce332635652e90caef5c3d13a39660
git-subtree-split: 509258e11d0f4d3b503dea00a369b25b620ecf9e

Diffstat:
Ahome/.local/bin/opt/LICENSE | 24++++++++++++++++++++++++
Ahome/.local/bin/opt/README.md | 5+++++
Ahome/.local/bin/opt/aur | 9+++++++++
Ahome/.local/bin/opt/autorss | 7+++++++
Ahome/.local/bin/opt/cpusage | 9+++++++++
Ahome/.local/bin/opt/git_status_prompt | 24++++++++++++++++++++++++
Ahome/.local/bin/opt/lock | 14++++++++++++++
Ahome/.local/bin/opt/lsearch | 8++++++++
Ahome/.local/bin/opt/mkscr | 7+++++++
Ahome/.local/bin/opt/openup | 3+++
Ahome/.local/bin/opt/randwall | 16++++++++++++++++
Ahome/.local/bin/opt/runt | 7+++++++
Ahome/.local/bin/opt/spt-mute.sh | 21+++++++++++++++++++++
Ahome/.local/bin/opt/spt-vol.sh | 21+++++++++++++++++++++
Ahome/.local/bin/opt/time_bar | 6++++++
Ahome/.local/bin/opt/volume_bar | 8++++++++
16 files changed, 189 insertions(+), 0 deletions(-)

diff --git a/home/.local/bin/opt/LICENSE b/home/.local/bin/opt/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <http://unlicense.org/> diff --git a/home/.local/bin/opt/README.md b/home/.local/bin/opt/README.md @@ -0,0 +1,5 @@ +# scripts + +A collection of scripts I use on my system. + +Scripts suffixed with `_bar` are used to generate output for my window manager's bar. diff --git a/home/.local/bin/opt/aur b/home/.local/bin/opt/aur @@ -0,0 +1,9 @@ +#!/bin/sh + +AGDIR=$HOME/src/git/aur/$1 + +mkdir -p $AGDIR + +git clone https://aur.archlinux.org/$1.git $AGDIR + +echo "cd $AGDIR; makepkg -s" diff --git a/home/.local/bin/opt/autorss b/home/.local/bin/opt/autorss @@ -0,0 +1,7 @@ +#!/bin/sh + +newsboat -x reload +MSG=`newsboat -x print-unread` +if [[ `echo $MSG | awk '{print $1}'` -gt 0 ]]; then + notify-send -a "newsboat" "updated rss" "$MSG" +fi diff --git a/home/.local/bin/opt/cpusage b/home/.local/bin/opt/cpusage @@ -0,0 +1,9 @@ +#!/bin/sh + +USAGE=$(top -bn1 | grep "Cpu(s)" | \ + sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | \ + awk '{print 100 - $1}') + +NUM=$(echo "$USAGE" | sed "s/\..*//") + +echo "$NUM%" diff --git a/home/.local/bin/opt/git_status_prompt b/home/.local/bin/opt/git_status_prompt @@ -0,0 +1,24 @@ +#!/bin/sh +# Prints git information for my shell prompt + +PROMPT="$" +WORKING="$(git rev-parse --is-inside-work-tree 2>/dev/null)" + +if [ "$WORKING" ]; then + STATUS="$(git status -s)" + COLOR="\033[92m" + COMMIT="" + if [ "$STATUS" ]; then + COLOR="\033[91m" + fi + + COMMIT="$(git status | grep ahead)" + if [ "$COMMIT" ]; then + PROMPT="λ" + fi + + BRANCH=$(git branch --no-color --show-current) + printf "${COLOR}$BRANCH \033[38;2;142;192;124m$PROMPT\033[0m " +else + printf "\033[38;2;142;192;124m$PROMPT\033[0m " +fi diff --git a/home/.local/bin/opt/lock b/home/.local/bin/opt/lock @@ -0,0 +1,14 @@ +#!/bin/sh +# Locks my screen with i3lock + +xargs i3lock -e \ + --ringvercolor=45858888 \ + --ringwrongcolor=cc241d88 \ + --ringcolor=98971a88 \ + --insidevercolor=83a59888 \ + --insidewrongcolor=fb493488 \ + --insidecolor=28282888 \ + --keyhlcolor=b8bb2644 \ + --bshlcolor=fb493444 \ + --locktext="" --veriftext="" --noinputtext="" --wrongtext="" \ + -i < ~/.cache/oldwall diff --git a/home/.local/bin/opt/lsearch b/home/.local/bin/opt/lsearch @@ -0,0 +1,8 @@ +#!/bin/sh +# Script to easily do a web search with lynx + +URL='lynx -vikeys -accept_all_cookies https://lite.duckduckgo.com/lite/?q=' + +SEARCH=$(echo [email protected] | sed 's/ /+/g') + +eval "$URL$SEARCH" diff --git a/home/.local/bin/opt/mkscr b/home/.local/bin/opt/mkscr @@ -0,0 +1,7 @@ +#!/bin/sh +# Script to easily make a new script + +SCR_PATH="$HOME/git/scripts/$1" +echo "#!/bin/sh" > $SCR_PATH +chmod +x $SCR_PATH +echo "o" | $EDITOR -s /dev/stdin $SCR_PATH diff --git a/home/.local/bin/opt/openup b/home/.local/bin/opt/openup @@ -0,0 +1,3 @@ +#!/bin/sh + +$EDITOR $(which $1) diff --git a/home/.local/bin/opt/randwall b/home/.local/bin/opt/randwall @@ -0,0 +1,16 @@ +#!/bin/bash +# Sets my wallpaper to a random image in my wallpaper directory + +OLD=$(<$XDG_CACHE_HOME/oldwall) + +get_file () { + NEW=$(find $XDG_PICTURES_DIR/wall -type f -name "*" | shuf -n 1) +} + +get_file +while [ "$OLD" = "$NEW" ]; do + get_file +done + +feh --no-fehbg --bg-fill $NEW +echo $NEW > $XDG_CACHE_HOME/oldwall diff --git a/home/.local/bin/opt/runt b/home/.local/bin/opt/runt @@ -0,0 +1,7 @@ +#!/bin/sh +# Script to run commands many times +j=1 +while [ $j -le $1 ]; do + $2 + j=$(( j + 1 )) +done diff --git a/home/.local/bin/opt/spt-mute.sh b/home/.local/bin/opt/spt-mute.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +app_name="librespot" +current_sink_num='' +sink_num_check='' +app_name_check='' + +pactl list sink-inputs |while read line; do \ + sink_num_check=$(echo "$line" |sed -rn 's/^Sink Input #(.*)/\1/p') + if [ "$sink_num_check" != "" ]; then + current_sink_num="$sink_num_check" + else + app_name_check=$(echo "$line" \ + |sed -rn 's/application.name = "([^"]*)"/\1/p') + if [ "$app_name_check" = "$app_name" ]; then + echo "$current_sink_num" "$app_name_check" + pactl set-sink-input-mute "$current_sink_num" toggle + fi + fi +done + diff --git a/home/.local/bin/opt/spt-vol.sh b/home/.local/bin/opt/spt-vol.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +app_name="librespot" +current_sink_num='' +sink_num_check='' +app_name_check='' + +pactl list sink-inputs |while read line; do \ + sink_num_check=$(echo "$line" |sed -rn 's/^Sink Input #(.*)/\1/p') + if [ "$sink_num_check" != "" ]; then + current_sink_num="$sink_num_check" + else + app_name_check=$(echo "$line" \ + |sed -rn 's/application.name = "([^"]*)"/\1/p') + if [ "$app_name_check" = "$app_name" ]; then + echo "$current_sink_num" "$app_name_check" + pactl set-sink-input-volume "$current_sink_num" "$1"5% + fi + fi +done + diff --git a/home/.local/bin/opt/time_bar b/home/.local/bin/opt/time_bar @@ -0,0 +1,6 @@ +#!/bin/sh +# Prints time/date information for dwmblocks + +TIME=$(date +"%I:%M %m.%d.%y") + +echo "$TIME" diff --git a/home/.local/bin/opt/volume_bar b/home/.local/bin/opt/volume_bar @@ -0,0 +1,8 @@ +#!/bin/sh +# Prints volume information for dwmblocks + +VOL=$(amixer -D pulse sget Master | grep 'Mono:' | awk -F'[][]' '{ print $2 }') +if ["$VOL" -eq ""]; then + VOL=$(amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }') +fi +echo "$VOL"