This commit is contained in:
Daniel Napora 2024-12-17 00:31:38 +01:00
parent 580699c086
commit f9e3a0973c
2 changed files with 154 additions and 72 deletions

View File

@ -2,6 +2,8 @@
# jgpicom-pipe - pipemenu to start, stop, restart Picom and manage Picom configs (WIP)
# Copyright (C) 2020-2024 napcok <napcok@gmail.com>
#TODO recognize rule-based configs (since picom v12) and don't show link to picom-conf
. "$HOME/.config/mabox/mabox.conf"
backend=${picom_renderer:-glx}
@ -26,6 +28,8 @@ case $LANG in
RENDERER="Rendering Backend"
GLX="<b>glx</b> <i>(zalecany)</i>"
XRENDER="<b>xrender</b> <i>(dla starszego sprzętu)</i>"
_COLORIZER_ROOT="<b>Colorizer</b> - menu główne"
_LEFTSIDEPANEL="Lewy panel boczny"
;;
es*)
ENABLE="Activar Compositor"
@ -41,6 +45,8 @@ case $LANG in
RENDERER="Rendering Backend"
GLX="<b>glx</b> <i>(recommended)</i>"
XRENDER="<b>xrender</b> <i>(for older hardware)</i>"
_COLORIZER_ROOT="<b>Colorizer</b> rootmenu"
_LEFTSIDEPANEL="Left Sidepanel"
;;
*)
ENABLE="Start Compositor"
@ -52,38 +58,43 @@ case $LANG in
EDIT="Edit Compositor settings file"
CONFIG_GUI="Configure with GUI (picom-conf)"
INSTALL_GUI="Install picom-conf (GUI)"
OPENDIR="Open <i>~/.config/picom/configs</i> directory"
OPENDIR="Open <i>~/.config/picom/configs</i> dir"
RENDERER="Rendering Backend"
GLX="<b>glx</b> <i>(recommended)</i>"
XRENDER="<b>xrender</b> <i>(for older hardware)</i>"
_COLORIZER_ROOT="<b>Colorizer</b> rootmenu"
_LEFTSIDEPANEL="Left Sidepanel"
;;
esac
menu() {
me="jgpicom-pipe -s"
out+=("^sep(Picom)")
if ! pidof picom > /dev/null; then
out+=("$ENABLE,mabox-compositor --start")
out+=("$ENABLE,mabox-compositor --start;${me}")
else
out+=("$RESTART,mabox-compositor --restart")
out+=("$DISABLE,mabox-compositor --stop")
out+=("$RESTART,mabox-compositor --restart;${me}")
out+=("$DISABLE,mabox-compositor --stop;${me}")
fi
out+=("^sep($RENDERER)")
[[ "$backend" == "glx" ]] && out+=("<big>綠</big> $GLX" "<big>祿</big> $XRENDER,mb-setvar picom_renderer=xrender;mabox-compositor --restart;${me}") || out+=("<big>祿</big> $GLX,mb-setvar picom_renderer=glx;mabox-compositor --restart;${me}" "<big>綠</big> $XRENDER")
out+=("^sep($CHOOSE)")
if [ "$(readlink $CONFFILE)" -ef "/dev/null" ];then
out+=("<u><b>$DEVNULL</b></u>")
out+=("<big>綠</big> <u><b>$DEVNULL</b></u>")
else
out+=("$DEVNULL,ln -sf /dev/null $CONFFILE;mabox-compositor --restart")
out+=("<big>祿</big> $DEVNULL,ln -sf /dev/null $CONFFILE;mabox-compositor --restart;${me}")
fi
for item in "$CONFDIR"/*.conf; do
if [ -f "$item" ];then
if [ "$(readlink $CONFFILE)" -ef "$item" ];then
out+=("<u><b>${item##*/}</b></u>")
out+=("<big>綠</big> <u><b>${item##*/}</b></u>")
else
out+=("${item##*/},ln -sf $item $CONFFILE;mabox-compositor --restart")
out+=("<big>祿</big> ${item##*/},ln -sf $item $CONFFILE;mabox-compositor --restart;${me}")
fi
fi
done
@ -91,25 +102,89 @@ done
out+=("^sep($EDIT_TITLE)")
if [ -f "$CONFFILE" ];then
if [ ! "$(readlink $CONFFILE)" -ef "/dev/null" ];then
out+=("$EDIT,xdg-open $CONFFILE")
out+=("$EDIT,xdg-open $CONFFILE")
if hash picom-conf 2>&1 >/dev/null
then
out+=("$CONFIG_GUI,picom-conf")
out+=("$CONFIG_GUI,picom-conf")
else
out+=("$INSTALL_GUI,pamac-installer picom-conf-git")
out+=("$INSTALL_GUI,pamac-installer picom-conf-git")
fi
fi
fi
out+=("$OPENDIR,exo-open --launch FileManager $CONFDIR")
out+=(" $OPENDIR,exo-open --launch FileManager $CONFDIR")
if [[ "$1" == "-s" ]]; then
. /usr/share/mb-jgtools/pipemenu-standalone.cfg
CNF_DIR="$HOME/.config/colorizer"
CNF_FILE="$CNF_DIR/colorizer.conf"
source "$CNF_FILE"
out+=("^sep()")
out+=(" ${arrow_string_left} $_COLORIZER_ROOT,colorizer -s")
out+=(" ${arrow_string_left} ${arrow_string_left} $_LEFTSIDEPANEL,mb-jgtools places")
if [[ "$colorizer_size" == "full" ]];then
eval $(xdotool getdisplaygeometry --shell)
MENU_HEIGHT_MIN="$HEIGHT"
MENU_HEIGHT_MAX=$MENU_HEIGHT_MIN
jgtools_radius=0
menu_margin_x="0"
else
MENU_VALIGN="center"
menu_margin_x=${submenu_spacing:-0}
fi
MENU_HALIGN="left"
jgmenu_icon_size=0
[ $(pidof picom) ] && MENU_RADIUS=$jgtools_radius
[ -z $jgmenu_use_borders ] && menu_border=0
JGWIDTH=$((jgtools_padding + 270 + jgtools_padding))
MENU_PADDING_TOP=$((jgtools_padding + 150))
#WALLPAPER
read WALLPATH<<< $(grep file "$HOME"/.config/nitrogen/bg-saved.cfg | tail -1 | cut -d'=' -f2)
THUMBDIR="$HOME/.cache/colorizer/thumbs"
mkdir -p ${THUMBDIR}
NAME=${WALLPATH////_}
if [[ "${NAME}" =~ ^_home_.* ]]; then
n=${#HOME}
((n++))
NAME=${NAME:${n}}
fi
THUMB="${THUMBDIR}/${NAME}.png"
if [[ ! -f "$THUMB" ]]
then
convert ${WALLPATH} -resize 270x150^ -gravity center -extent 270x150 ${THUMB}
fi
mkconfigfile
[[ "$GR" == "1" ]] && clr=${GR_FROM} || clr=${FG}
cat <<EOF > ${MENU_ITEMS}
@icon,,$((jgtools_padding)),$((jgtools_padding)),270,150,4,left,top,,,${THUMB}
@rect,,$((jgtools_padding)),$((jgtools_padding + 116)),270,28,0,left,top,#222222 20,#222222 70,
@icon,,$((jgtools_padding+4)),$((jgtools_padding+82)),64,64,4,left,top,,,/usr/share/icons/hicolor/scalable/apps/compton.svg
#@text,,$((jgtools_padding + 10)),$((jgtools_padding + 106)),100,28,0,left,top,#FFFFFF ,${WINCLR},<span size='41600' font_family='Ubuntu'><big></big></span>
@text,,$((jgtools_padding + 88)),$((jgtools_padding + 116)),180,28,0,left,top,#FFFFFF ,${WINCLR},<span size='10400' font_family='Ubuntu'>Mabox <b>Compositor</b> settings</span>
$(printf '%s\n' "${out[@]}")
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
exit 0
fi
out+=("^sep($RENDERER)")
[[ "$backend" == "glx" ]] && out+=("<big>綠</big> $GLX" "<big>祿</big> $XRENDER,mb-setvar picom_renderer=xrender;mabox-compositor --restart") || out+=("<big>祿</big> $GLX,mb-setvar picom_renderer=glx;mabox-compositor --restart" "<big>綠</big> $XRENDER")
printf '%s\n' "${out[@]}"
}
case "$1" in
start) start;;
menu) menu "$2";;
esac

View File

@ -1,6 +1,9 @@
#!/bin/bash
# jgwallpaperchanger - dynamic menu (or submenu) to configure/set wallpapers
#
#TODO wallpaper colors on image
#TODO quickly colorize OB,Conky,menus from wp-colors + apply predefined schemes
if [[ $1 == "-r" || "$1" == "-d" ]];then
me="${0##*/} -s"
else
@ -88,6 +91,7 @@ case $LANG in
_COLORIZER_HELP="Okno główne i Pomoc"
_COLORIZER_ROOT="<b>Colorizer</b> menu główne"
_COLORIZER_FONTS="Konfiguruj <b>Czcionki</b>"
_COLORIZER_PICOM="Kompozytor <b>Picom</b>"
_COLORIZER_OB="Moduł <b>Openbox</b>"
_COLORIZER_MENU="Moduł <b>Menu</b>"
_COLORIZER_CONKY="Moduł <b>Conky</b>"
@ -134,6 +138,7 @@ case $LANG in
_COLORIZER_HELP="Main Window and Help"
_COLORIZER_ROOT="<b>Colorizer</b> rootmenu"
_COLORIZER_FONTS="Configure <b>Fonts</b>"
_COLORIZER_PICOM="<b>Compositor</b> settings <b>(Picom)</b>"
_COLORIZER_OB="<b>Openbox</b> module"
_COLORIZER_MENU="<b>Menus/SidePanels</b> module"
_COLORIZER_CONKY="<b>Conky</b> module"
@ -240,6 +245,8 @@ case "$1" in
out+=("^sep()")
out+=("$_COLORIZER_FONTS,colorizer-fonts -s")
out+=("^sep()")
out+=("$_COLORIZER_PICOM,jgpicom-pipe -s")
out+=("^sep()")
out+=("$_COLORIZER_OB,colorizer-ob -s")
out+=("$_COLORIZER_MENU,colorizer-menus -s")
out+=("$_COLORIZER_CONKY,colorizer-conky -s")