mabox-pipemenus/usr/bin/jgpicom-pipe
2024-12-10 20:59:19 +01:00

116 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# jgpicom-pipe - pipemenu to start, stop, restart Picom and manage Picom configs (WIP)
# Copyright (C) 2020-2024 napcok <napcok@gmail.com>
. "$HOME/.config/mabox/mabox.conf"
backend=${picom_renderer:-glx}
CONFDIR="$HOME/.config/picom/configs"
CONFFILE="$HOME/.config/picom.conf"
mkdir -p "$CONFDIR"
case $LANG in
pl*)
ENABLE="Włącz Kompozytora"
RESTART="Restartuj Kompozytora"
DISABLE="Wyłącz Kompozytora"
CHOOSE="Wybierz plik konfiguracyjny"
DEVNULL="/dev/null <i>(brak)</i>"
EDIT_TITLE="Edytuj ustawienia Picom"
EDIT="Edytuj plik ustawień Kompozytora"
CONFIG_GUI="Konfiguruj (picom-conf)"
INSTALL_GUI="Zainstaluj picom-conf"
OPENDIR="Otwórz katalog <i>~/.config/picom/configs</i>"
RENDERER="Rendering Backend"
GLX="<b>glx</b> <i>(zalecany)</i>"
XRENDER="<b>xrender</b> <i>(dla starszego sprzętu)</i>"
;;
es*)
ENABLE="Activar Compositor"
RESTART="Reiniciar Compositor"
DISABLE="Desactivar Compositor"
CHOOSE="Elegir el archivo de configuración"
DEVNULL="/dev/null"
EDIT_TITLE="Editar..."
CONFIG_GUI="Configure with GUI (picom-conf)"
INSTALL_GUI="Install picom-conf (GUI)"
EDIT="Editar archivo de ajustes del Compositor"
OPENDIR="Abrir la carpeta <i>~/.config/picom/configs</i>"
RENDERER="Rendering Backend"
GLX="<b>glx</b> <i>(recommended)</i>"
XRENDER="<b>xrender</b> <i>(for older hardware)</i>"
;;
*)
ENABLE="Start Compositor"
RESTART="Restart Compositor"
DISABLE="Stop Compositor"
CHOOSE="Choose config file"
DEVNULL="/dev/null <i>(none)</i>"
EDIT_TITLE="Edit Compositor settings"
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"
RENDERER="Rendering Backend"
GLX="<b>glx</b> <i>(recommended)</i>"
XRENDER="<b>xrender</b> <i>(for older hardware)</i>"
;;
esac
menu() {
out+=("^sep(Picom)")
if ! pidof picom > /dev/null; then
out+=("$ENABLE,mabox-compositor --start")
else
out+=("$RESTART,mabox-compositor --restart")
out+=("$DISABLE,mabox-compositor --stop")
fi
out+=("^sep($CHOOSE)")
if [ "$(readlink $CONFFILE)" -ef "/dev/null" ];then
out+=("<u><b>$DEVNULL</b></u>")
else
out+=("$DEVNULL,ln -sf /dev/null $CONFFILE;mabox-compositor --restart")
fi
for item in "$CONFDIR"/*.conf; do
if [ -f "$item" ];then
if [ "$(readlink $CONFFILE)" -ef "$item" ];then
out+=("<u><b>${item##*/}</b></u>")
else
out+=("${item##*/},ln -sf $item $CONFFILE;mabox-compositor --restart")
fi
fi
done
out+=("^sep($EDIT_TITLE)")
if [ -f "$CONFFILE" ];then
if [ ! "$(readlink $CONFFILE)" -ef "/dev/null" ];then
out+=("$EDIT,xdg-open $CONFFILE")
if hash picom-conf 2>&1 >/dev/null
then
out+=("$CONFIG_GUI,picom-conf")
else
out+=("$INSTALL_GUI,pamac-installer picom-conf-git")
fi
fi
fi
out+=("$OPENDIR,exo-open --launch FileManager $CONFDIR")
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