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
@ -49,13 +52,13 @@ fi
lclick(){
case $t2_button_lclick_action in
random) mbwallpaper -o;;
choose) pcmanwp;;
preview) mbwallpaper -c;;
menu) jgwallpaperchanger ipc;;
slideshow) run_wallpaperslideshow;;
window) ycolorizer;;
colmenu) colorizer -s;;
random) mbwallpaper -o;;
choose) pcmanwp;;
preview) mbwallpaper -c;;
menu) jgwallpaperchanger ipc;;
slideshow) run_wallpaperslideshow;;
window) ycolorizer;;
colmenu) colorizer -s;;
esac
}
@ -84,10 +87,11 @@ case $LANG in
_DIRS="katalogach"
_LEFTPANEL="Lewy panel"
_OBTHEME="Motyw Openbox"
_MENUPANELS="Menu i Panele"
_COLORIZER_HELP="Okno główne i Pomoc"
_MENUPANELS="Menu i Panele"
_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>"
@ -104,7 +108,7 @@ case $LANG in
_COL_MENU="menu"
_RANDOM_DESC="Ustaw <b>losową</b> tapetę"
_CHOOSE_DESC="<b>Wybierz</b> tapetę (z menu kontekstowego)"
_PREVIEW_DESC="<b>Podgląd</b> <i>użyj</i> <span bgcolor='#333333' color='#d3d3d3'> <small>󱦱</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>󱦰</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>Enter</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>Esc</small> </span>"
_PREVIEW_DESC="<b>Podgląd</b> <i>użyj</i> <span bgcolor='#333333' color='#d3d3d3'> <small>󱦱</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>󱦰</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>Enter</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>Esc</small> </span>"
_COL_WINDOW_DESC="Colorizer - <b>okno</b>"
_COL_MENU_DESC="Colorizer - dynamiczne <b>menu</b>"
;;
@ -130,10 +134,11 @@ case $LANG in
_DIRS="dirs"
_LEFTPANEL="Left panel"
_OBTHEME="Openbox Theme"
_MENUPANELS="Menus/Panels"
_COLORIZER_HELP="Main Window and Help"
_MENUPANELS="Menus/Panels"
_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"
@ -150,7 +155,7 @@ case $LANG in
_COL_MENU="menu"
_RANDOM_DESC="Set <b>random</b> wallpaper"
_CHOOSE_DESC="<b>Choose</b> wallpaper (<i>from context menu</i>)"
_PREVIEW_DESC="<b>Preview</b> &amp; set <i>use</i> <span bgcolor='#333333' color='#d3d3d3'> <small>󱦱</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>󱦰</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>Enter</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>Esc</small> </span>"
_PREVIEW_DESC="<b>Preview</b> &amp; set <i>use</i> <span bgcolor='#333333' color='#d3d3d3'> <small>󱦱</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>󱦰</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>Enter</small> </span> <span bgcolor='#333333' color='#d3d3d3'> <small>Esc</small> </span>"
_COL_WINDOW_DESC="Colorizer - <b>window</b>"
_COL_MENU_DESC="Colorizer - dynamic <b>menu</b>"
;;
@ -168,38 +173,38 @@ if ! pgrep -f "mbwallpaper -s" > /dev/null; then
#out+=("$NITROGEN,nitrogen")
out+=("<big></big> $_RANDWALL,mbwallpaper -o;$me")
out+=("<big>󰉔</big> $_CHOOSE_WP,pcmanwp")
out+=("^sep()")
out+=("^sep()")
out+=("<big>易</big> $_PREVIEW_DESC,mbwallpaper -c")
out+=("<big>󰧸</big> $_SLIDESHOW_DESC,^checkout(sshow)")
out+=("<big>󰧸</big> $_SLIDESHOW_DESC,^checkout(sshow)")
out+=("<big>󱡄</big> $_GENERATOR,^pipe(jgwallpapergenerate)")
out+=("^sep()")
out+=("<big></big> $_WPDIR [ <b>${wallpaper_dir2}</b> ],^checkout(wpdirs)")
out2+=("^tag(wpdirs)")
out2+=("^sep($_WPDIRS)")
out2+=("^sep($_WPDIRS_DESC)")
out+=("^sep()")
out+=("<big></big> $_WPDIR [ <b>${wallpaper_dir2}</b> ],^checkout(wpdirs)")
out2+=("^tag(wpdirs)")
out2+=("^sep($_WPDIRS)")
out2+=("^sep($_WPDIRS_DESC)")
readarray -t wpdirs < <(grep -v '^\s*$\|^#\|^\s*\#' "$CNF_FILE")
readarray -t wpdirs < <(grep -v '^\s*$\|^#\|^\s*\#' "$CNF_FILE")
[[ -d "$(xdg-user-dir PICTURES)/imagick" ]] && wallp=$(shopt -s nullglob ; set -- $(xdg-user-dir PICTURES)/imagick/*.{jpg,JPG,jpeg,JPEG,png,PNG,avif} ; echo $#)
if [[ "$wallp" -gt "1" ]];then
[[ -d "$(xdg-user-dir PICTURES)/imagick" ]] && wallp=$(shopt -s nullglob ; set -- $(xdg-user-dir PICTURES)/imagick/*.{jpg,JPG,jpeg,JPEG,png,PNG,avif} ; echo $#)
if [[ "$wallp" -gt "1" ]];then
imagickdir="$(xdg-user-dir PICTURES)/imagick"
imagickdir=${imagickdir/$HOME/\~}
wpdirs=("$imagickdir" "${wpdirs[@]}")
fi
fi
wpdirs=("/usr/share/backgrounds/" "${wpdirs[@]}")
#notify-send.sh "DIRS" "${#wpdirs[@]}"
wpdirs=("/usr/share/backgrounds/" "${wpdirs[@]}")
#notify-send.sh "DIRS" "${#wpdirs[@]}"
wpimgs=0
for dir in "${wpdirs[@]}"
do
wpdir=${dir/\~/$HOME}
wallp=$(shopt -s nullglob ; set -- $wpdir/*.{jpg,JPG,jpeg,JPEG,png,PNG,avif} ; echo $#)
[[ "$wallpaper_dir2" == "${dir}" ]] && out2+=("<big>綠</big> <small>(${wallp})</small> <b>${dir}</b>") || out2+=("<big>祿</big> <small>(${wallp})</small> ${dir},mbwallpaper changedir ${dir};$me")
wpimgs=$((wpimgs+wallp))
done
out2+=("^sep($_TOTAL: <b>$wpimgs</b> $_WPS <b>${#wpdirs[@]}</b> $_DIRS)")
wpimgs=0
for dir in "${wpdirs[@]}"
do
wpdir=${dir/\~/$HOME}
wallp=$(shopt -s nullglob ; set -- $wpdir/*.{jpg,JPG,jpeg,JPEG,png,PNG,avif} ; echo $#)
[[ "$wallpaper_dir2" == "${dir}" ]] && out2+=("<big>綠</big> <small>(${wallp})</small> <b>${dir}</b>") || out2+=("<big>祿</big> <small>(${wallp})</small> ${dir},mbwallpaper changedir ${dir};$me")
wpimgs=$((wpimgs+wallp))
done
out2+=("^sep($_TOTAL: <b>$wpimgs</b> $_WPS <b>${#wpdirs[@]}</b> $_DIRS)")
out2+=("<big></big> $_EDIT_WPDIRS,xdg-open $CNF_FILE")
@ -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")
@ -250,15 +257,15 @@ case "$1" in
case $t2_button_lclick_action in
random) out+=("󰳽 $_B_LC_ACTION: <b>[ $_RAND ]</b>,^checkout(laction)");;
choose) out+=("󰳽 $_B_LC_ACTION: <b>[ $_CHOOSE ]</b>,^checkout(laction)");;
preview) out+=("󰳽 $_B_LC_ACTION: <b>[ $_PREVIEW ]</b>,^checkout(laction)");;
menu) out+=("󰳽 $_B_LC_ACTION: <b>[ $_WALL_MENU ]</b>,^checkout(laction)");;
slideshow) out+=("󰳽 $_B_LC_ACTION: <b>[ $_SLIDESHOW ]</b>,^checkout(laction)");;
window) out+=("󰳽 $_B_LC_ACTION: <b>[ $_COL_WINDOW ]</b>,^checkout(laction)");;
colmenu) out+=("󰳽 $_B_LC_ACTION: <b>[ $_COL_MENU ]</b>,^checkout(laction)");;
*) out+=("󰳽 $_B_LC_ACTION: <b>[ $_CHOOSE ]</b>,^checkout(laction)");;
esac
random) out+=("󰳽 $_B_LC_ACTION: <b>[ $_RAND ]</b>,^checkout(laction)");;
choose) out+=("󰳽 $_B_LC_ACTION: <b>[ $_CHOOSE ]</b>,^checkout(laction)");;
preview) out+=("󰳽 $_B_LC_ACTION: <b>[ $_PREVIEW ]</b>,^checkout(laction)");;
menu) out+=("󰳽 $_B_LC_ACTION: <b>[ $_WALL_MENU ]</b>,^checkout(laction)");;
slideshow) out+=("󰳽 $_B_LC_ACTION: <b>[ $_SLIDESHOW ]</b>,^checkout(laction)");;
window) out+=("󰳽 $_B_LC_ACTION: <b>[ $_COL_WINDOW ]</b>,^checkout(laction)");;
colmenu) out+=("󰳽 $_B_LC_ACTION: <b>[ $_COL_MENU ]</b>,^checkout(laction)");;
*) out+=("󰳽 $_B_LC_ACTION: <b>[ $_CHOOSE ]</b>,^checkout(laction)");;
esac
out2+=("^tag(laction)")
out2+=("^sep($_P_B_LC_ACTION)")
@ -346,6 +353,6 @@ printf '%s\n' "${out2[@]}"
case "$1" in
lclick) lclick;;
*) time main "$@";;
lclick) lclick;;
*) time main "$@";;
esac