add changes recommended/needed as indicated by shellcheck

This commit is contained in:
randomuser 2022-11-27 17:04:53 +00:00
parent 98d0a2fd68
commit 8594f34cb6
15 changed files with 63 additions and 72 deletions

View File

@ -1,36 +1,37 @@
#!/bin/sh
[ "$(ps -aux | grep -c NetworkManager)" -eq 2 ] && \
printf "NetworkManager is already running!" && \
[ "$(pgrep -c NetworkManager)" -eq 1 ] &&
printf "NetworkManager is already running!\n" &&
exit
case $1 in
"c"*)
wpa_supplicant -iwlp3s0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B
dhcpcd wlp3s0
tor & disown
# make tor and nohup shut up in a posix-compliant way
nohup tor >/dev/null 2>&1
;;
"d"*)
killall -15 wpa_supplicant dhcpcd tor
;;
"r"*)
sh $0 d
sh $0 c
sh "$0" d
sh "$0" c
;;
"t"*)
[ $(ps aux | grep wpa_supplicant | wc -l) -eq 2 ] && sh $0 d && exit
sh $0 c
[ "$(pgrep -c wpa_supplicant)" -eq 1 ] && sh "$0" d && exit
sh "$0" c
;;
"l"*)
iw dev wlp3s0 scan | \
grep 'SSID\|signal' | \
grep -v '* SSID List' | \
grep -v 'SSID List' | \
awk -F': ' '{print $2}' | \
sed 'N;s/\n/ /' | \
grep -v '\x00'
;;
*)
printf "\
echo "
simple wrapper for connecting to a network
${0} toggle to toggle wifi connection
${0} restart to restart wifi

View File

@ -1,12 +1,12 @@
#!/bin/sh
exists() {
xrandr | grep ' connected' | grep "${1}" | wc -l
xrandr | grep ' connected' | grep -c "${1}"
}
bspc monitor -d 1 2 3 4 5 6 7 8 9
if [ $(exists "HDMI-2") -eq 1 ] && [ $(exists "LVDS-1") -eq 1 ]; then
if [ "$(exists "HDMI-2")" -eq 1 ] && [ "$(exists "LVDS-1")" -eq 1 ]; then
printf "two"
xrandr --output HDMI-2 --right-of LVDS-1 --auto
xrandr --output VGA-1 --off --auto

View File

@ -1,3 +1,3 @@
#!/bin/sh
HOME="/home/usr/.local/share/firefox" firefox $@
HOME="/home/usr/.local/share/firefox" firefox "$@"

View File

@ -1,11 +1,10 @@
#!/bin/sh
for i in $(ls); do
cd $i
for i in *; do
cd "$i" || continue
exists=$(
git status |\
grep 'Your branch is ahead of ' |\
wc -l
git status |
grep -c 'Your branch is ahead of '
)
[ "$exists" -eq 0 ] || printf "> %s\n" "$i"

2
sh/net
View File

@ -1,4 +1,4 @@
#!/bin/sh
# designed to be called from sxhkd (x session)
[ "$(pgrep NetworkManager)" ] && st -e nmtui
pgrep NetworkManager && st -e nmtui

29
sh/nws
View File

@ -3,7 +3,7 @@
[ -z "${XDG_CONFIG_DIR}" ] && XDG_CONFIG_DIR="${HOME}/.config"
[ -z "${NWS_CONFIG}" ] && NWS_CONFIG="${XDG_CONFIG_DIR}/nws"
[ -n "${NWS_ZONE}" ] || \
[ -e ${NWS_CONFIG} ] && NWS_ZONE=$(cat ${NWS_CONFIG}) || \
[ -e "${NWS_CONFIG}" ] && NWS_ZONE=$(cat "${NWS_CONFIG}") ||
NWS_ZONE="KGYX"
[ -z "${NWS_GIF}" ] && NWS_GIF="mpv --loop"
[ -z "${NWS_TORIFY}" ] && NWS_TORIFY=""
@ -28,9 +28,9 @@ Torify wrapper: export NWS_TORIFY=<command>
"
}
err () {
printf "err: %s\n" ${1}
printf "err: %s\n" "${1}"
[ -z "${2}" ] && exit 1
exit ${2}
exit "${2}"
}
kstrip () {
printf %s "$1" | sed 's/^K\(.*\)/\1/'
@ -46,7 +46,7 @@ mosaic () {
${NWS_GIF} "https://radar.weather.gov/ridge/lite/${1}_loop.gif"
}
setzone () {
printf "%s" "${1}" > ${NWS_CONFIG}
printf "%s" "${1}" > "${NWS_CONFIG}"
}
river () {
textmessage "RVA"
@ -66,36 +66,39 @@ textmessage () {
case $1 in
"n"*)
national
exit 0
;;
"l"*)
localradar
exit 0
;;
"r"*)
river
exit 0
;;
"w"*)
weather
exit 0
;;
"m"*)
[ $# -eq 2 ] && mosaid $2 || \
if [ "$#" -eq 2 ]; then
mosaid "$2"
else
err "two args required"
fi
;;
"s"*)
[ $# -eq 2 ] && setzone $2 || \
if [ "$#" -eq 2 ]; then
setzone "$2"
else
err "two args required"
exit 0
fi
;;
"t"*)
[ $# -eq 2 ] && textmessage $2 || \
if [ "$#" -eq 2 ]; then
textmessage "$2"
else
err "two args required"
fi
;;
*)
info
exit 0
;;
esac
exit 0

View File

@ -4,4 +4,4 @@ sel="$(pash l | tmenu)"
[ "$?" -eq 1 ] && exit 0
# requires bspc rule -a st-gpg-menu state=floating
st -c st-gpg-menu -e pash-dmenu-backend $sel
st -c st-gpg-menu -e pash-dmenu-backend "$sel"

View File

@ -5,15 +5,13 @@
printf "[info] this utility is used for adding youtube urls as rss feeds\n"
feed="$(curl ${1} -s | \
feed="$(curl "$1" -s | \
grep 'youtube/www\.youtube\.com/channel/.\{24\}' -o | \
awk -F'/' '{print "https://www.youtube.com/feeds/videos.xml?channel_id=" $NF}' | \
sed 1q)"
[ -z "$feed" ] && printf "[err] error processing the feed. are you sure it's *www*.youtube.com and not youtube.com?\n" && exit 1
tmp="$(mktemp)"
sfeedrc="$HOME/.config/sfeed/sfeedrc"
ed "$sfeedrc" <<EOF

View File

@ -4,7 +4,7 @@ power_prefix="/sys/class/power_supply/"
[ -d "${power_prefix}sbs-20-000b" ] && bat="sbs-20-000b"
[ -d "${power_prefix}BAT0" ] && bat="BAT0"
[ "$(ps aux | grep pulseaudio | wc -l)" -eq 2 ] && ss="pulse" || ss="alsa"
[ "$(pgrep -c pulseaudio)" -eq 1 ] && ss="pulse" || ss="alsa"
mod_bspwm () {
used_desk=$(bspc query -D -d .occupied --names | tr '\n' ' ')
@ -67,7 +67,7 @@ echo_bar () {
printf "\033[2J\033[H%s" "$left"
# print right side
printf "\033[1;%if%s" "$(($width - $rightwidth + 1))" "$right"
printf "\033[1;%if%s" "$((width - rightwidth + 1))" "$right"
}
register_sigs () {
@ -94,5 +94,5 @@ while true; do
sleep 0.25
[ "$i" -eq $((29 * 4)) ] && update_all && i=0
echo_bar
i="$(($i + 1))"
i="$((i + 1))"
done

View File

@ -3,10 +3,12 @@
barwidth=20
# remove all current statusbars
# pgrep doesn't handle arguments for running commands
# shellcheck disable=2009
processes="$(ps aux | grep 'st -c' | grep 'status' | awk -F' ' '{print $2}')"
for i in $processes; do
pkill -P "$i" 2>&1 > /dev/null
kill $i
pkill -P "$i" >/dev/null 2>&1
kill "$i"
done
# get all screens
@ -16,6 +18,6 @@ screens="$(xrandr | grep ' connected' | sed 's/ primary//g' | awk -F' ' '{print
IFS="
"
for i in $screens; do
screenstring=$(echo $i | awk -v a="$barwidth" -F'[ x+]' '{print $2 "x" a "+" $4 "+" $5}')
screenstring=$(echo "$i" | awk -v a="$barwidth" -F'[ x+]' '{print $2 "x" a "+" $4 "+" $5}')
st -c statusbar -p -g "$screenstring" -e status &
done

View File

@ -1,6 +1,6 @@
#!/bin/sh
printf "%s" $1
printf "%s" "$1"
fzy $2 < "$1" > "${1}a"
mv ${1}a ${1}
fzy "$2" < "$1" > "${1}a"
mv "${1}a" "${1}"

View File

@ -4,7 +4,7 @@ tmenu_path () {
IFS=" :"
for i in $PATH; do
for j in "$i"/*; do
[ -f $j ] && [ -x $j ] && printf "%s\n" $j
[ -f "$j" ] && [ -x "$j" ] && printf "%s\n" "$j"
done
done
}

View File

@ -19,7 +19,7 @@ desk=$(
)
[ "$desk" = "none" ] && exit 1
desk=$(($desk + 1))
desk=$((desk + 1))
bspc desktop -f "^${desk}"
killall -10 simplestatus

8
sh/vol
View File

@ -1,16 +1,16 @@
#!/bin/sh
pulse=$(ps aux | grep pulseaudio | wc -l)
pulse=$(pgrep -c pulseaudio)
[ "$1" = "inc" ] && sign="+"
[ "$1" = "dec" ] && sign="-"
[ "$#" -eq 0 ] && exit 1
if [ "$pulse" -eq 2 ]; then
for SINK in `pacmd list-sinks | grep 'index:' | cut -b12-`
if [ "$pulse" -eq 1 ]; then
for SINK in $(pacmd list-sinks | grep 'index:' | cut -b12-)
do
pactl set-sink-volume $SINK "${sign}5%"
pactl set-sink-volume "$SINK" "${sign}5%"
done
else
amixer -c 0 set Master "5%${sign}"

View File

@ -1,12 +1,11 @@
#!/bin/sh
WALLDIR="${HOME}/.local/share/wallpapers"
TEEFILE="${WALLDIR}/.hist"
BASECMD="feh --no-fehbg --bg-fill"
generate_wall () {
GENWALL=$( \
ls $WALLDIR | \
ls "$WALLDIR" | \
grep "." | \
shuf -n 1
)
@ -19,26 +18,15 @@ wall () {
done
}
displays () {
displays=$(xrandr | grep ' connected' | wc -l)
}
check () {
which $1 &>/dev/null
displays=$(xrandr | grep -c ' connected')
}
cmd=""
check "feh" || exit 1
if check "xrandr"; then
displays
for i in $(seq 1 $displays); do
wall ${tmp}
tmp=${GENWALL}
echo ${GENWALL} ${i} | tee $TEEFILE
displays
for i in $(seq 1 "$displays"); do
wall "${tmp}"
tmp="${GENWALL}"
cmd="${cmd} ${GENWALL}"
done
eval ${BASECMD} ${cmd}
else
generate_wall
eval ${BASECMD} ${GENWALL}
fi
unset GENWALL BASECMD tmp cmd displays i
done
eval "${BASECMD}" "${cmd}"
exit 0