mabox-pipemenus/usr/bin/jglockscreen

153 lines
4.9 KiB
Plaintext
Raw Normal View History

2021-08-31 22:56:45 +02:00
#!/bin/bash
# jglockscreen - configure betterlockscreen
#
CONFIG_DIR="$HOME/.config/mbscreenlocker/"
SCRNLOCKCFG="$HOME/.config/mbscreenlocker/mbscreenlocker.conf"
# Make config directory if not exist
mkdir -p $CONFIG_DIR
# If config file not exist create one with defaults
if [ ! -f $SCRNLOCKCFG ]; then
cat <<EOF > ${SCRNLOCKCFG}
# Effect to use: dim, blur, dimblur or pixel
effect=pixel
# ScreenLocker program: betterlockscreen or i3lock
screenlocker=i3lock
EOF
fi
# read config variables from file
source <(grep = $SCRNLOCKCFG)
case $LANG in
pl*)
LOCK="Zablokuj ekran"
GENIMGS="Generuj obrazy tła"
LOCKER="Blokada ekranu <small>(super+l)</small>"
TYPETO="wpisz hasło aby odblokować"
SELECT_IMG="Wybierz obrazek"
CACHE="Użyj aktualnej tapety"
EFFECT="Efekt (ustaw i wypróbuj)"
DIM="przyciemnienie"
BLUR="rozmycie"
DIMBLUR="przyciemnienie i rozmycie"
PIXEL="pikseloza"
DESK="Rozmyty pulpit"
EDITCONF="Edytuj plik konfiguracyjny"
LEFTPANEL="Lewy panel"
;;
*)
LOCK="Lock screen now"
GENIMGS="Update Images"
LOCKER="ScreenLocker <small>(super+l)</small>"
TYPETO="type password to unlock"
SELECT_IMG="Select image file"
CACHE="Cache current wallpaper for ScreenLock"
EFFECT="Effect (set and run)"
DIM="dim"
BLUR="blur"
DIMBLUR="dim and blur"
PIXEL="pixel"
DESK="Blurred desktop"
EDITCONF="Edit config file"
LEFTPANEL="Left panel"
;;
esac
. $HOME/.config/mabox/mabox.conf
me="jglockscreen -s"
#help='\nBased on Mabox forum member Shwaybo <a href="https://forum.maboxlinux.org/t/chwp-desktop-wallpaper-changer/496">idea</a>.\n\nchange wallpapers from a directory, never using the same picture twice until all the pictures have been shown, and rotating x number of seconds (configurable) before the next wallpaper change.\n'
out+=("^sep($LOCKER)")
out+=("^sep(<i><small>$TYPETO</small></i>")
#out+=("^sep(Betterlockscreen)")
2021-08-31 23:09:19 +02:00
out+=("$LOCK,mbscreenlocker")
2021-08-31 22:56:45 +02:00
out+=("^sep($GENIMGS)")
out+=("$SELECT_IMG,mbscreenlocker -s")
out+=("$CACHE,mbscreenlocker -c")
out+=("^sep(<i><small>$EFFECT</small></i>)")
if [ $effect == "dim" -a $screenlocker != "i3lock" ];then
out+=("<b>[ $DIM ]</b>,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=dim $SCRNLOCKCFG;mbscreenlocker")
else
out+=("$DIM,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=dim $SCRNLOCKCFG;mbscreenlocker")
fi
if [ $effect == "blur" -a $screenlocker != "i3lock" ];then
out+=("<b>[ $BLUR ]</b>,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=blur $SCRNLOCKCFG;mbscreenlocker")
else
out+=("$BLUR,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=blur $SCRNLOCKCFG;mbscreenlocker")
fi
if [ $effect == "dimblur" -a $screenlocker != "i3lock" ];then
out+=("<b>[ $DIMBLUR ]</b>,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=dimblur $SCRNLOCKCFG;mbscreenlocker")
else
out+=("$DIMBLUR,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=dimblur $SCRNLOCKCFG;mbscreenlocker")
fi
if [ $effect == "pixel" -a $screenlocker != "i3lock" ];then
out+=("<b>[ $PIXEL ]</b>,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=pixel $SCRNLOCKCFG;mbscreenlocker")
else
out+=("$PIXEL,mb-setvar screenlocker=betterlockscreen $SCRNLOCKCFG;mb-setvar effect=pixel $SCRNLOCKCFG;mbscreenlocker")
fi
out+=("^sep()")
if [ $screenlocker = "i3lock" ];then
out+=("<b>[ $DESK ]</b>,mb-setvar screenlocker=i3lock $SCRNLOCKCFG;mbscreenlocker")
else
out+=("$DESK,mb-setvar screenlocker=i3lock $SCRNLOCKCFG;mbscreenlocker")
fi
out+=("^sep()")
2022-08-17 14:19:31 +02:00
out+=("$EDITCONF ,xdg-open $SCRNLOCKCFG")
2021-08-31 22:56:45 +02:00
out2+=("^tag(interval)")
for i in 3 5 10 30 60 120 300 600 1800 3600; do out2+=("$(printf "<tt> %4s</tt>,%s" "$i" "mb-setvar interval=${i} $CONFIG_FILE;$me")");done
### RUN
if [[ "$1" == "-s" ]]; then
2021-09-24 01:40:09 +02:00
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
2021-08-31 22:56:45 +02:00
. $HOME/.config/mabox/mabox.conf
out+=("^sep()")
out+=(" ⮜ $LEFTPANEL,mb-jgtools places")
if [[ $panels_heightpos == "top" ]]; then
MENU_VALIGN="top"
MENU_MARGIN_Y=${panels_topmargin:-0}
elif [[ $panels_heightpos == "bottom" ]]; then
MENU_VALIGN="bottom"
MENU_MARGIN_Y=${panels_topmargin:-0}
else
MENU_VALIGN="center"
fi
MENU_PADDING_TOP=${jgtools_padding:-0}
MENU_HALIGN="left"
jgmenu_icon_size=0
JGWIDTH=40
menu_margin_x=${submenu_spacing:-0}
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
$(printf '%s\n' "${out[@]}")
$(printf '%s\n' "${out2[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
printf '%s\n' "${out[@]}"
if [[ $1 == "-r" ]]; then
case $LANG in
pl*) REMOVE="Usuń to menu z panelu";;
es*) REMOVE="Eliminar este menú del panel";;
*) REMOVE="Remove this menu from panel";;
esac
printf '%s\n' "^sep()"
printf '%s\n' "<i>$REMOVE</i>,mb-setvar places_jglockscreen=false;mb-jgtools places"
fi
printf '%s\n' "${out2[@]}"
echo $effect
echo $screenlocker