mirror of
https://git.adityakumar.xyz/betterlockscreen-openrc.git
synced 2024-11-09 10:39:45 +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
|
||||
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)}')
|
||||
|
||||
init_filenames() {
|
||||
|
@ -34,6 +34,7 @@ init_filenames() {
|
|||
# override defaults with config
|
||||
theme_rc="$HOME/.config/betterlockscreenrc"
|
||||
if [ -e "$theme_rc" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$theme_rc"
|
||||
fi
|
||||
|
||||
|
@ -41,7 +42,7 @@ init_filenames() {
|
|||
res_folder="$HOME/.cache/i3lock/$1"
|
||||
folder="$HOME/.cache/i3lock/current"
|
||||
echo "Got" "$@" "$res_folder"
|
||||
if [ ! -d "$folder" -o -n "$2" ]; then
|
||||
if [ ! -d "$folder" ] || [ -n "$2" ]; then
|
||||
rm -rf "$folder"
|
||||
mkdir -p "$res_folder"
|
||||
ln -s "$res_folder" "$folder"
|
||||
|
@ -74,10 +75,10 @@ init_filenames "$res"
|
|||
|
||||
|
||||
prelock() {
|
||||
if [ ! -z "$lock_timeout" ]; then
|
||||
if [ -n "$lock_timeout" ]; then
|
||||
xset dpms "$lock_timeout"
|
||||
fi
|
||||
if [ ! -z "$(pidof dunst)" ]; then
|
||||
if [ -n "$(pidof dunst)" ]; then
|
||||
pkill -u "$USER" -USR1 dunst
|
||||
fi
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ prelock() {
|
|||
lock() {
|
||||
#$1 image path
|
||||
|
||||
i3lock \
|
||||
i3lock-color \
|
||||
-c 00000000 \
|
||||
-t -i "$1" \
|
||||
--timepos='x+110:h-70' \
|
||||
|
@ -99,19 +100,19 @@ lock() {
|
|||
--radius=20 --ring-width=4 --veriftext='' --wrongtext='' \
|
||||
--verifcolor="$verifcolor" --timecolor="$timecolor" --datecolor="$datecolor" \
|
||||
--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() {
|
||||
if [ ! -z "$lock_timeout" ]; then
|
||||
if [ -n "$lock_timeout" ]; then
|
||||
xset dpms "$default_timeout"
|
||||
if [ "$default_dpms" = "Disabled" ]; then
|
||||
xset -dpms
|
||||
fi
|
||||
fi
|
||||
if [ ! -z "$(pidof dunst)" ] ; then
|
||||
if [ -n "$(pidof dunst)" ] ; then
|
||||
pkill -u "$USER" -USR2 dunst
|
||||
fi
|
||||
}
|
||||
|
@ -123,9 +124,10 @@ rec_get_random() {
|
|||
user_input="$dir"
|
||||
return
|
||||
fi
|
||||
dir=("$dir"/*)
|
||||
dir="${dir[RANDOM % ${#dir[@]}]}"
|
||||
rec_get_random "$dir"
|
||||
dirs=("$dir"*)
|
||||
random_dir="${dirs[RANDOM % ${#dirs[@]}]}"
|
||||
rec_get_random "$random_dir"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
|
@ -165,8 +167,8 @@ lockselect() {
|
|||
logical_px() {
|
||||
# get dpi value from xrdb
|
||||
local DPI
|
||||
DPI=$(cat ~/.Xresources | grep -oP 'Xft.dpi:\s*\K\d+' | bc)
|
||||
if [ -z "$DPI" ]; then
|
||||
DPI=$(grep -oP 'Xft.dpi:\s*\K\d+' ~/.Xresources | bc)
|
||||
if [ -n "$DPI" ]; then
|
||||
DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$2/p" | head -n1)
|
||||
fi
|
||||
|
||||
|
@ -196,7 +198,7 @@ update() {
|
|||
rectangles=" "
|
||||
SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*')
|
||||
for RES in $SR; do
|
||||
SRA=(${RES//[x+]/ })
|
||||
SRA=("${RES//[x+]/ }")
|
||||
CX=$((SRA[2] + $(logical_px 25 1)))
|
||||
CY=$((SRA[1] - $(logical_px 30 2)))
|
||||
rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300 1))),$((CY-$(logical_px 80 2))) "
|
||||
|
|
Loading…
Reference in a new issue