mabox-tools/bin/mbscreenlocker

76 lines
1.9 KiB
Plaintext
Raw Permalink Normal View History

2021-05-30 01:51:41 +02:00
#!/bin/bash
CONFIG_DIR="$HOME/.config/mbscreenlocker"
CONFIG_FILE="$CONFIG_DIR/mbscreenlocker.conf"
# Make config directory if not exist
mkdir -p $CONFIG_DIR
# If config file not exist create one with defaults
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Effect to use: dim, blur, dimblur or pixel
effect=dim
# ScreenLocker program: betterlockscreen or i3lock
2021-06-01 12:16:09 +02:00
screenlocker=i3lock
2021-05-30 01:51:41 +02:00
EOF
fi
# read config variables from file
source <(grep = $CONFIG_FILE)
case $LANG in
pl*)
TITLE="Tworzenie obrazków dla blokady ekranu"
TEXT="\nCierpliwości...\nto może chwilkę potrwać.."
TITLE2="Gotowe"
2021-08-31 22:55:30 +02:00
TEXT2="\n<b>super+l</b> aby zablokować ekran"
2021-05-30 01:51:41 +02:00
;;
*)
TITLE="Caching images for faster screen locking"
TEXT="\nPlease wait...\nthis might take few seconds..."
TITLE2="Done"
2021-08-31 22:55:30 +02:00
TEXT2="All required changes have been applied.\n Use <b>super + l</b> to lock screen."
2021-05-30 01:51:41 +02:00
;;
esac
2021-08-31 22:55:30 +02:00
lock() {
if [[ $screenlocker == "betterlockscreen" ]]; then
betterlockscreen -l $effect
else
i3lock -B 2 -k --time-color="337d00ff" --date-color="337d00ff"
fi
}
cache() {
2021-05-30 01:51:41 +02:00
source <(grep file ~/.config/nitrogen/bg-saved.cfg)
notify-send.sh -u critical -i emblem-photos -R /tmp/mbscreencache "$TITLE" "$TEXT"
betterlockscreen -u "$file"
notify-send.sh -u normal -i emblem-photos -R /tmp/mbscreencache "$TITLE2" "$TEXT2"
}
2021-08-31 22:55:30 +02:00
setimg() {
img=$(yad --file --file-filter="Image Files (*.jpg *.jpeg *.png *.tif)| *.jpg *.JPG *.jpeg *.JPEG *.png *.PNG")
if [ -f "$img" ]; then
notify-send.sh -u critical -i emblem-photos -R /tmp/mbscreencache "$TITLE" "$TEXT"
betterlockscreen -u "$img"
notify-send.sh -u normal -i emblem-photos -R /tmp/mbscreencache "$TITLE2" "$TEXT2"
fi
}
2021-05-30 01:51:41 +02:00
usage() {
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
exit
}
case "$1" in
-c|cache) cache;;
-h|--help) usage;;
2021-08-31 22:55:30 +02:00
-s|setimg) setimg;;
2021-05-30 01:51:41 +02:00
*) lock;;
esac
exit 0