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

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
UNREAD_ONLY=true UNREAD_ONLY=true
MAIL_DIR=~/.local/share/mail MAIL_DIR=~/.local/share/mail
@ -6,12 +6,12 @@ MAIL_DIR=~/.local/share/mail
mailcount=0 mailcount=0
if [[ -d ${MAIL_DIR} ]]; then 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 # get file count for the unread mailbox, add to count
mailcount=$(( $( ls ${dir}INBOX/new | wc -l ) + $mailcount )) mailcount=$(( $( ls ${dir}INBOX/new | wc -l ) + $mailcount ))
# also add the rest of the inbox if var is set # also add the rest of the inbox if var is set
if !($UNREAD_ONLY); then if ! ($UNREAD_ONLY); then
mailcount=$(( $( ls ${dir}INBOX/cur | wc -l ) + $mailcount )) mailcount=$(( $( ls ${dir}INBOX/cur | wc -l ) + $mailcount ))
fi fi
@ -19,4 +19,3 @@ if [[ -d ${MAIL_DIR} ]]; then
fi fi
echo ${mailcount} echo ${mailcount}

View file

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