mirror of
https://git.adityakumar.xyz/betterlockscreen-openrc.git
synced 2025-03-14 13:09:21 +00:00
Add shellcheck-action, fix shellcheck-errors (#206)
This commit is contained in:
parent
3be77f6854
commit
929205022c
2 changed files with 32 additions and 14 deletions
16
.github/workflows/shellcheck.yml
vendored
Normal file
16
.github/workflows/shellcheck.yml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
name: ShellCheck
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
name: ShellCheck
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Run ShellCheck
|
||||||
|
uses: ludeeus/action-shellcheck@master
|
||||||
|
with:
|
||||||
|
severity: style
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
# find your resolution so images can be resized to match your screen resolution
|
# find your resolution so images can be resized to match your screen resolution
|
||||||
res=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')
|
res=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')
|
||||||
default_timeout="$(cut -d ' ' -f4 <<< $(xset q | sed -n '25p'))"
|
default_timeout="$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')")"
|
||||||
default_dpms=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}')
|
default_dpms=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}')
|
||||||
|
|
||||||
init_filenames() {
|
init_filenames() {
|
||||||
|
@ -34,6 +34,7 @@ init_filenames() {
|
||||||
# override defaults with config
|
# override defaults with config
|
||||||
theme_rc="$HOME/.config/betterlockscreenrc"
|
theme_rc="$HOME/.config/betterlockscreenrc"
|
||||||
if [ -e "$theme_rc" ]; then
|
if [ -e "$theme_rc" ]; then
|
||||||
|
# shellcheck disable=SC1090
|
||||||
source "$theme_rc"
|
source "$theme_rc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ init_filenames() {
|
||||||
res_folder="$HOME/.cache/i3lock/$1"
|
res_folder="$HOME/.cache/i3lock/$1"
|
||||||
folder="$HOME/.cache/i3lock/current"
|
folder="$HOME/.cache/i3lock/current"
|
||||||
echo "Got" "$@" "$res_folder"
|
echo "Got" "$@" "$res_folder"
|
||||||
if [ ! -d "$folder" -o -n "$2" ]; then
|
if [ ! -d "$folder" ] || [ -n "$2" ]; then
|
||||||
rm -rf "$folder"
|
rm -rf "$folder"
|
||||||
mkdir -p "$res_folder"
|
mkdir -p "$res_folder"
|
||||||
ln -s "$res_folder" "$folder"
|
ln -s "$res_folder" "$folder"
|
||||||
|
@ -74,10 +75,10 @@ init_filenames "$res"
|
||||||
|
|
||||||
|
|
||||||
prelock() {
|
prelock() {
|
||||||
if [ ! -z "$lock_timeout" ]; then
|
if [ -n "$lock_timeout" ]; then
|
||||||
xset dpms "$lock_timeout"
|
xset dpms "$lock_timeout"
|
||||||
fi
|
fi
|
||||||
if [ ! -z "$(pidof dunst)" ]; then
|
if [ -n "$(pidof dunst)" ]; then
|
||||||
pkill -u "$USER" -USR1 dunst
|
pkill -u "$USER" -USR1 dunst
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -86,7 +87,7 @@ prelock() {
|
||||||
lock() {
|
lock() {
|
||||||
#$1 image path
|
#$1 image path
|
||||||
|
|
||||||
i3lock \
|
i3lock-color \
|
||||||
-c 00000000 \
|
-c 00000000 \
|
||||||
-t -i "$1" \
|
-t -i "$1" \
|
||||||
--timepos='x+110:h-70' \
|
--timepos='x+110:h-70' \
|
||||||
|
@ -99,19 +100,19 @@ lock() {
|
||||||
--radius=20 --ring-width=4 --veriftext='' --wrongtext='' \
|
--radius=20 --ring-width=4 --veriftext='' --wrongtext='' \
|
||||||
--verifcolor="$verifcolor" --timecolor="$timecolor" --datecolor="$datecolor" \
|
--verifcolor="$verifcolor" --timecolor="$timecolor" --datecolor="$datecolor" \
|
||||||
--time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \
|
--time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \
|
||||||
--noinputtext='' --force-clock --pass-media-keys $lockargs
|
--noinputtext='' --force-clock --pass-media-keys "$lockargs"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
postlock() {
|
postlock() {
|
||||||
if [ ! -z "$lock_timeout" ]; then
|
if [ -n "$lock_timeout" ]; then
|
||||||
xset dpms "$default_timeout"
|
xset dpms "$default_timeout"
|
||||||
if [ "$default_dpms" = "Disabled" ]; then
|
if [ "$default_dpms" = "Disabled" ]; then
|
||||||
xset -dpms
|
xset -dpms
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ ! -z "$(pidof dunst)" ] ; then
|
if [ -n "$(pidof dunst)" ] ; then
|
||||||
pkill -u "$USER" -USR2 dunst
|
pkill -u "$USER" -USR2 dunst
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -123,9 +124,10 @@ rec_get_random() {
|
||||||
user_input="$dir"
|
user_input="$dir"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
dir=("$dir"/*)
|
dirs=("$dir"*)
|
||||||
dir="${dir[RANDOM % ${#dir[@]}]}"
|
random_dir="${dirs[RANDOM % ${#dirs[@]}]}"
|
||||||
rec_get_random "$dir"
|
rec_get_random "$random_dir"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,8 +167,8 @@ lockselect() {
|
||||||
logical_px() {
|
logical_px() {
|
||||||
# get dpi value from xrdb
|
# get dpi value from xrdb
|
||||||
local DPI
|
local DPI
|
||||||
DPI=$(cat ~/.Xresources | grep -oP 'Xft.dpi:\s*\K\d+' | bc)
|
DPI=$(grep -oP 'Xft.dpi:\s*\K\d+' ~/.Xresources | bc)
|
||||||
if [ -z "$DPI" ]; then
|
if [ -n "$DPI" ]; then
|
||||||
DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$2/p" | head -n1)
|
DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$2/p" | head -n1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -196,7 +198,7 @@ update() {
|
||||||
rectangles=" "
|
rectangles=" "
|
||||||
SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*')
|
SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*')
|
||||||
for RES in $SR; do
|
for RES in $SR; do
|
||||||
SRA=(${RES//[x+]/ })
|
SRA=("${RES//[x+]/ }")
|
||||||
CX=$((SRA[2] + $(logical_px 25 1)))
|
CX=$((SRA[2] + $(logical_px 25 1)))
|
||||||
CY=$((SRA[1] - $(logical_px 30 2)))
|
CY=$((SRA[1] - $(logical_px 30 2)))
|
||||||
rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300 1))),$((CY-$(logical_px 80 2))) "
|
rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300 1))),$((CY-$(logical_px 80 2))) "
|
||||||
|
|
Loading…
Reference in a new issue