mabox-pipemenus/usr/bin/mabox-compositor

99 lines
2.9 KiB
Plaintext
Raw Normal View History

2016-03-25 19:02:03 +01:00
#!/bin/bash
# mabox-compositor
2020-01-10 13:29:29 +01:00
# Openbox Pipe Menu for use with picom compositor
2016-03-25 19:02:03 +01:00
# Written for CrunchBang Linux <http://crunchbang.org/>
# by Philip Newborough <corenominal@corenominal.org>
# Ported to #!++ <https://crunchbangplusplus.org>
# by Ben Young <computermouth@crunchbangplusplus.org>
# Ported to Manjaro <https://manjaro.github.io/>
# by Daniel Napora <napcok@gmail.com>
RESTART_ATTEMPTS=20
if ! . mabox-include.cfg 2> /dev/null; then
echo ' Failed to locate mabox-include.cfg in PATH' >&2
exit 1
fi
2017-01-04 19:18:24 +01:00
case $LANG in
pl*)
ENABLE="Włącz Kompozytora"
RESTART="Restartuj Kompozytora"
DISABLE="Wyłącz Kompozytora"
2018-12-13 12:39:01 +01:00
EDIT="Edytuj plik ustawień Kompozytora"
EDIT_GUI="Ustawienia Kompozytora (GUI)"
2017-01-04 19:18:24 +01:00
;;
2020-08-24 16:37:30 +02:00
es*)
ENABLE="Activar Compositor"
2020-08-26 15:50:04 +02:00
RESTART="Reiniciar Compositor"
DISABLE="Desactivar Compositor"
EDIT="Editar archivo de ajustes del Compositor"
EDIT_GUI="Ajustes gráfico (GUI)"
2020-08-24 16:37:30 +02:00
;;
2017-01-04 19:18:24 +01:00
*)
ENABLE="Enable Compositor"
RESTART="Restart Compositor"
DISABLE="Disable Compositor"
2018-12-13 12:39:01 +01:00
EDIT="Edit Compositor settings file"
EDIT_GUI="Settings (GUI)"
2017-01-04 19:18:24 +01:00
;;
esac
2016-03-25 19:02:03 +01:00
# ------------- Set xcompmgr command options -----------------------------------
2020-01-10 13:29:29 +01:00
EXECXCOMP='picom'
#if glxinfo | egrep -iq 'direct rendering: yes'; then
# EXECXCOMP+=' --vsync opengl'
#fi
2016-03-25 19:02:03 +01:00
# Edit xcompmgr settings
if [[ $1 = '--edit' ]]; then
2020-01-10 22:42:27 +01:00
[[ ! -f $HOME/.config/picom.conf ]] &&
cp '/etc/xdg/picom.conf' "$HOME/.config/picom.conf"
2016-03-25 19:02:03 +01:00
if [[ -x /usr/bin/geany ]]; then
2020-01-10 22:42:27 +01:00
geany "$HOME/.config/picom.conf" &
2016-03-25 19:02:03 +01:00
else
2020-01-10 22:42:27 +01:00
terminator --command='nano "$HOME/.config/picom.conf"'
2016-03-25 19:02:03 +01:00
fi
2020-01-10 13:29:29 +01:00
elif [[ $1 = '--toggle' || $1 = '--start' ]]; then # Toggle compositing with picom.
2016-03-25 19:02:03 +01:00
# TODO why --toggle and --start act exactly the same?
2020-01-10 13:29:29 +01:00
if ! pidof picom > /dev/null; then
2016-03-25 19:02:03 +01:00
$EXECXCOMP &
else
2020-01-10 13:29:29 +01:00
killall picom
2016-03-25 19:02:03 +01:00
fi
elif [[ $1 = '--restart' ]]; then
2020-01-10 13:29:29 +01:00
if pidof picom > /dev/null;then
killall -q picom
2016-12-02 22:03:57 +01:00
for (( i=0; i < RESTART_ATTEMPTS; i++ )); do
2020-01-10 13:29:29 +01:00
pidof picom > /dev/null || # no process found! Safe to start again
2016-12-02 22:03:57 +01:00
break
2016-03-25 19:02:03 +01:00
2016-12-02 22:03:57 +01:00
(( i == RESTART_ATTEMPTS - 1 )) && # still didn't die? Probably hangs. Force it to die!
2020-01-10 13:29:29 +01:00
killall -q -S KILL picom
2016-03-25 19:02:03 +01:00
2016-12-02 22:03:57 +01:00
sleep 0.25
done
mabox-compositor --start
fi
2016-03-25 19:02:03 +01:00
elif [[ $1 = '--watch' ]]; then
2020-01-10 22:42:27 +01:00
while inotifywait -e modify "$HOME/.config/picom.conf"; do
2016-03-25 19:02:03 +01:00
mabox-compositor --restart # TODO move this to function?
done
else
# Output Openbox menu
menuStart
2020-04-25 17:36:39 +02:00
menuSeparator "Picom"
2020-01-10 13:29:29 +01:00
if ! pidof picom > /dev/null; then
2017-01-04 19:18:24 +01:00
menuItem "$ENABLE" 'mabox-compositor --start'
2016-03-25 19:02:03 +01:00
else
2017-01-04 19:18:24 +01:00
menuItem "$RESTART" 'mabox-compositor --restart'
menuItem "$DISABLE" 'mabox-compositor --toggle'
2016-03-25 19:02:03 +01:00
fi
2018-12-13 12:39:01 +01:00
menuSeparator
2017-01-04 19:18:24 +01:00
menuItem "$EDIT" 'mabox-compositor --edit'
2020-01-13 11:59:04 +01:00
#menuItem "$EDIT_GUI" 'compton-conf'
2016-03-25 19:02:03 +01:00
menuEnd
fi
exit 0