fix: lint custom executables against shellcheck

This commit is contained in:
winston 2022-07-30 22:17:25 +02:00
parent e0cfa9bd22
commit c032ffd1a2
Signed by: winston
GPG key ID: 3786770EDBC2B481
3 changed files with 22 additions and 25 deletions

View file

@ -1,6 +1,4 @@
#! /bin/bash
#
# /usr/bin/setcursor
#! /usr/bin/env bash
# config files
gtk2=$HOME/.gtkrc-2.0
@ -11,39 +9,39 @@ gtk3=$HOME/.config/gtk-3.0/settings.ini
default=share/icons/default/index.theme
glob_default=/usr/$default
user_default=$HOME/.local/$default
[[ -e $glob_default ]] && [[ ! -e $user_default ]] && install -D $glob_default $user_default
[[ -e $glob_default ]] && [[ ! -e $user_default ]] && install -D $glob_default "$user_default"
# cursor-theme entries
cursor_gtk2=$(grep "cursor-theme-name" $gtk2 | cut -d'"' -f2)
cursor_gtk3=$(grep "cursor-theme-name" $gtk3 | cut -d'=' -f2)
cursor_xr=$(grep "Xcursor.theme" $xr | cut -d' ' -f2)
cursor_gtk2=$(grep "cursor-theme-name" "$gtk2" | cut -d'"' -f2)
cursor_gtk3=$(grep "cursor-theme-name" "$gtk3" | cut -d'=' -f2)
cursor_xr=$(grep "Xcursor.theme" "$xr" | cut -d' ' -f2)
cursor=$1
# find config last modified
if [ -z $1 ]; then
if [ -z "$1" ]; then
cursor=$cursor_gtk2; newest=$gtk2
[[ $xr -nt $gtk2 ]] && [[ ! -z $cursor_xr ]] && cursor=$cursor_xr && newest=$xr
[[ $gtk3 -nt $newest ]] && [[ ! -z $cursor_gtk3 ]] && cursor=$cursor_gtk3
[[ $xr -nt $gtk2 ]] && [[ -n $cursor_xr ]] && cursor=$cursor_xr && newest=$xr
[[ $gtk3 -nt $newest ]] && [[ -n $cursor_gtk3 ]] && cursor=$cursor_gtk3
fi
# Strip any quotes from cursor string
cursor=$(echo $cursor | sed -e 's/"//g')
cursor=${cursor/\"/}
# set theme in all config files
echo "setting cursortheme \"$cursor\""
[[ "$cursor" != "$cursor_xr" ]] && \
sed -i "s/Xcursor.theme:.*/Xcursor.theme: $cursor/g" $xr &>/dev/null && \
xrdb -merge -I$HOME ~/.Xresources
sed -i "s/Xcursor.theme:.*/Xcursor.theme: $cursor/g" "$xr" &>/dev/null && \
xrdb -merge -I"$HOME" ~/.Xresources
[[ "$cursor" != "$cursor_gtk2" ]] && \
sed -i "s/cursor-theme-name=\".*\"/cursor-theme-name=\"$cursor\"/" $gtk2
sed -i "s/cursor-theme-name=\".*\"/cursor-theme-name=\"$cursor\"/" "$gtk2"
[[ "$cursor" != "$cursor_gtk3" ]] && \
sed -i "s/cursor-theme-name=.*/cursor-theme-name=$cursor/" $gtk3 &>/dev/null
[[ -e $user_default ]] && sed -i "s/Inherits=.*/Inherits=$cursor/" $user_default &>/dev/null
sed -i "s/cursor-theme-name=.*/cursor-theme-name=$cursor/" "$gtk3" &>/dev/null
[[ -e $user_default ]] && sed -i "s/Inherits=.*/Inherits=$cursor/" "$user_default" &>/dev/null
# and in the realms of the GNOMEs
[[ -f /usr/bin/gconftool-2 ]] && gconftool-2 --type string -s /desktop/gnome/peripherals/mouse/cursor $cursor
[[ -f /usr/bin/gsettings ]] && gsettings set org.gnome.desktop.interface cursor-theme $cursor
[[ -f /usr/bin/gconftool-2 ]] && gconftool-2 --type string -s /desktop/gnome/peripherals/mouse/cursor "$cursor"
[[ -f /usr/bin/gsettings ]] && gsettings set org.gnome.desktop.interface cursor-theme "$cursor"
exit

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
UNREAD_ONLY=true
MAIL_DIR=~/.local/share/mail
@ -6,7 +6,7 @@ MAIL_DIR=~/.local/share/mail
mailcount=0
if [[ -d ${MAIL_DIR} ]]; then
for dir in ${MAIL_DIR}/*/; do
for dir in "${MAIL_DIR}"/*/; do
# get file count for the unread mailbox, add to count
mailcount=$(( $( ls ${dir}INBOX/new | wc -l ) + $mailcount ))
@ -19,4 +19,3 @@ if [[ -d ${MAIL_DIR} ]]; then
fi
echo ${mailcount}

View file

@ -1,14 +1,14 @@
#!/usr/bin/env bash
while read LINE; do
while read -r LINE; do
if echo "$LINE" | grep -q 'Connected'; then
# get the relay (3rd word) | drop the wireguard/openvpn suffix | make it uppercase
# just replace this with whatever style you like
OUTPUT=$(echo $LINE | cut -d " " -f 3 | cut -d "-" -f 1 | tr '/a-z/' '/A-Z/')
OUTPUT=$(echo "$LINE" | cut -d " " -f 3 | cut -d "-" -f 1 | tr '/a-z/' '/A-Z/')
ICON=" "
else
ICON=" "
fi
echo $ICON $OUTPUT
echo "$ICON" "$OUTPUT"
done < <(mullvad status listen)