From 6a432b305bb66b3493f55a5b8fb79b83d07dc7e6 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sun, 7 Jun 2020 10:04:38 -0500 Subject: [PATCH] Shellcheck a few core scripts --- scripts/core/sxmo_camera.sh | 4 ++-- scripts/core/sxmo_rotate.sh | 26 +++++++++++++------------- scripts/core/sxmo_vol.sh | 30 +++++++++++++++--------------- scripts/core/sxmo_xinit.sh | 21 +++++++-------------- 4 files changed, 37 insertions(+), 44 deletions(-) diff --git a/scripts/core/sxmo_camera.sh b/scripts/core/sxmo_camera.sh index a4b152f..9e02ff9 100755 --- a/scripts/core/sxmo_camera.sh +++ b/scripts/core/sxmo_camera.sh @@ -1,7 +1,7 @@ #!/usr/bin/env sh err() { - echo -e "$1" | dmenu -fn Terminus-20 -c -l 10 - exit 1 + printf %b "$1" | dmenu -fn Terminus-20 -c -l 10 + exit 1 } media-ctl -d /dev/media1 --set-v4l2 '"ov5640 3-004c":0[fmt:UYVY8_2X8/1280x720]' || err "Couldn't open camera, is camera enabled?" diff --git a/scripts/core/sxmo_rotate.sh b/scripts/core/sxmo_rotate.sh index 8426a50..e6be220 100755 --- a/scripts/core/sxmo_rotate.sh +++ b/scripts/core/sxmo_rotate.sh @@ -1,31 +1,31 @@ #!/usr/bin/env sh applyptrmatrix() { - PTRID="$( - xinput | grep -iE 'touchscreen.+pointer' | grep -oE 'id=[0-9]+' | cut -d= -f2 - )" - xinput set-prop "$PTRID" --type=float --type=float "Coordinate Transformation Matrix" "$@" + PTRID="$( + xinput | grep -iE 'touchscreen.+pointer' | grep -oE 'id=[0-9]+' | cut -d= -f2 + )" + xinput set-prop "$PTRID" --type=float --type=float "Coordinate Transformation Matrix" "$@" } isrotated() { - xrandr | grep primary | cut -d' ' -f 5 | grep right && return 0 - return 1 + xrandr | grep primary | cut -d' ' -f 5 | grep right && return 0 + return 1 } rotnormal() { - xrandr -o normal - applyptrmatrix 0 0 0 0 0 0 0 0 0 - exit 0 + xrandr -o normal + applyptrmatrix 0 0 0 0 0 0 0 0 0 + exit 0 } rotright() { - xrandr -o right - applyptrmatrix 0 1 0 -1 0 1 0 0 1 - exit 0 + xrandr -o right + applyptrmatrix 0 1 0 -1 0 1 0 0 1 + exit 0 } rotate() { - isrotated && rotnormal || rotright + if isrotated; then rotnormal; else rotright; fi } rotate diff --git a/scripts/core/sxmo_vol.sh b/scripts/core/sxmo_vol.sh index 546bf00..7e3c4ef 100755 --- a/scripts/core/sxmo_vol.sh +++ b/scripts/core/sxmo_vol.sh @@ -1,26 +1,26 @@ #!/usr/bin/env sh notify() { - VOL="$( - amixer get "$(sxmo_audiocurrentdevice.sh)" | - grep -oE '([0-9]+)%' | - tr -d ' %' | - awk '{ s += $1; c++ } END { print s/c }' | - xargs printf %.0f - )" - dunstify -i 0 -u normal -r 998 "♫ $VOL" - echo 1 > /tmp/sxmo_bar + VOL="$( + amixer get "$(sxmo_audiocurrentdevice.sh)" | + grep -oE '([0-9]+)%' | + tr -d ' %' | + awk '{ s += $1; c++ } END { print s/c }' | + xargs printf %.0f + )" + dunstify -i 0 -u normal -r 998 "♫ $VOL" + echo 1 > /tmp/sxmo_bar } up() { - amixer set "$(sxmo_audiocurrentdevice.sh)" 1+ - notify + amixer set "$(sxmo_audiocurrentdevice.sh)" 1+ + notify } down() { - amixer set "$(sxmo_audiocurrentdevice.sh)" 1- - notify + amixer set "$(sxmo_audiocurrentdevice.sh)" 1- + notify } setvol() { - amixer set "$(sxmo_audiocurrentdevice.sh)" $1 + amixer set "$(sxmo_audiocurrentdevice.sh)" "$1" } -$@ +$1 diff --git a/scripts/core/sxmo_xinit.sh b/scripts/core/sxmo_xinit.sh index 43b5681..6e72a83 100755 --- a/scripts/core/sxmo_xinit.sh +++ b/scripts/core/sxmo_xinit.sh @@ -1,8 +1,8 @@ #!/usr/bin/env sh # Env vars -source /etc/profile -which $TERM || export TERM=st -which $BROWSER || export BROWSER=surf +. /etc/profile +which "$TERM" || export TERM=st +which "$BROWSER" || export BROWSER=surf [ -z "$MOZ_USE_XINPUT2" ] && export MOZ_USE_XINPUT2=1 [ -z "$XDG_CONFIG_HOME" ] && export XDG_CONFIG_HOME=~/.config @@ -24,16 +24,9 @@ autocutsel & autocutsel -selection PRIMARY & sxmo_statusbar.sh & -# Start dunst, lisgd (after dunst so it's in dbus path) and dwm -LEGACYSXMOFOLDERWARNING=" -Warning: ~/.sxmo is deprecated since sxmo-utils 1.1.5. -Modem call logs/texts location have moved. -Please move the contents of the ~/.sxmo/ folder to $XDG_CONFIG_HOME/sxmo/modem/ -" - +# Startup dbus, dunst in dbus path, lisgd in dbus path, and finally dwm exec dbus-run-session sh -c " - dunst -conf /usr/share/sxmo/dunst.conf & - lisgd & - [ -d "/home/$USER/.sxmo" ] && notify-send -t 0 -u critical '$LEGACYSXMOFOLDERWARNING' & - dwm 2> ~/.dwm.log + dunst -conf /usr/share/sxmo/dunst.conf & + lisgd & + dwm 2> ~/.dwm.log "