mabox-pipemenus/usr/bin/mabox-conky-pipemenu

180 lines
5.1 KiB
Plaintext
Raw Permalink Normal View History

2016-03-26 10:18:26 +01:00
#!/bin/bash
2021-05-01 18:17:55 +02:00
# mabox-conky-pipemenu - an Openbox pipemenu for manipulating conky
# Copyright (C) 2015 damo <damo@bunsenlabs.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
MB_COMMON_LIBDIR='/usr/lib/mabox/mabox-common'
2016-03-26 10:18:26 +01:00
CONKYDEFAULT="$HOME/.conkyrc"
CONKYPATH="$HOME/.config/conky"
CSESSIONFILE="$CONKYPATH/conky-sessionfile"
SESSIONS="$CONKYPATH/saved-sessions"
2020-08-29 10:00:57 +02:00
CZEN="mb-conky-manager"
2016-03-26 10:18:26 +01:00
CSESSION="mb-conky-session"
2021-05-01 18:17:55 +02:00
HELPFILE="/usr/share/mabox/mabox-docs/helpfile-conkyzen.txt"
2016-03-26 10:18:26 +01:00
2021-05-01 18:17:55 +02:00
if ! . "$MB_COMMON_LIBDIR/mabox-include.cfg" 2> /dev/null; then
echo "Error: Failed to source mb-include.cfg in $MB_COMMON_LIBDIR" >&2
exit 1
fi
2016-03-26 10:18:26 +01:00
if [ ! -e "$CSESSIONFILE" ] 2> /dev/null ; then
echo "Error: Failed to locate conky-sessionfile in $CONKYPATH" >&2
echo "conky -c $HOME/.conkyrc & sleep 1" > "$CSESSIONFILE"
fi
if [ ! -e "$SESSIONS" ] 2> /dev/null ; then
echo "$0: Failed to locate saved-sessions in $CONKYPATH" >&2
fi
2021-05-01 18:17:55 +02:00
declareDependencies yad
2017-01-04 19:18:24 +01:00
case $LANG in
pl*)
2021-05-01 18:17:55 +02:00
CHOOSE_CONKY="Wybierz Conky"
2017-01-04 19:18:24 +01:00
NEW_SESSION="Nowa sesja Conky"
RELOAD="Przeładuj Conky"
SAVED_SESSIONS="Zachowane sesje"
DEFAULT_CONKYRC="Domyślne conkyrc"
RUNNING_CONKY="Działające Conky"
EDIT_CONKY="Edytuj Conky"
2020-04-25 17:36:39 +02:00
CONKY_EDITOR="Wybierz plik Conky do edycji..."
2017-01-04 19:18:24 +01:00
NONE="Brak"
2021-05-01 18:17:55 +02:00
DEFAULT="Domyślna";;
2020-08-26 15:50:04 +02:00
es*)
2021-05-01 18:17:55 +02:00
CHOOSE_CONKY="Elegir recuadro Conky"
2020-08-29 20:47:05 +02:00
NEW_SESSION="Guardar sesión actual Conky"
RELOAD="Recargar recuadros Conky"
SAVED_SESSIONS="Sesiones Conky guardadas"
DEFAULT_CONKYRC="Archivo conkyrc x defecto"
RUNNING_CONKY="Recuadros en ejecución"
EDIT_CONKY="Edición manual recuadro"
CONKY_EDITOR="Editor de recuadro"
NONE="Ninguno"
2020-09-01 19:24:09 +02:00
DEFAULT="Default"
2020-08-26 15:50:04 +02:00
;;
2017-01-04 19:18:24 +01:00
*)
2021-05-01 18:17:55 +02:00
CHOOSE_CONKY="Choose Conky"
2017-01-04 19:18:24 +01:00
NEW_SESSION="New Conky session"
RELOAD="Reload Conky"
SAVED_SESSIONS="Saved sessions"
DEFAULT_CONKYRC="Default conkyrc"
RUNNING_CONKY="Running Conky"
EDIT_CONKY="Edit Conky"
CONKY_EDITOR="Conky Editor"
NONE="None"
2020-09-01 19:24:09 +02:00
DEFAULT="Default"
2017-01-04 19:18:24 +01:00
;;
esac
2021-05-01 18:17:55 +02:00
getSessions(){ # read any saved sessions from save-sessions file
menuSeparator "$SAVED_SESSIONS"
#menuItem "$DEFAULT" "$CSESSION $CSESSIONFILE"
if [ -e "$SESSIONS" ]
then
while read -r session ;do
[[ -z $session ]] && continue # skip if line is blank
menuItem "$session" "$CSESSION $session"
done < "$SESSIONS"
2016-03-26 10:18:26 +01:00
else
2021-05-01 18:17:55 +02:00
echo "$0: Failed to locate saved-sessions in $CONKYPATH" >&2
2016-03-26 10:18:26 +01:00
fi
}
2021-05-01 18:17:55 +02:00
loadChooserMenu(){
if type "$CZEN" &>/dev/null;then # mb-conkyzen script found
menuItem "$CHOOSE_CONKY" "$CZEN"
fi
}
2016-03-26 10:18:26 +01:00
2021-05-01 18:17:55 +02:00
loadNewsessionMenu(){
if type "$CZEN" &>/dev/null;then # mb-conkyzen script found
menuItem "$NEW_SESSION" "$CZEN -z"
fi
}
2016-03-26 10:18:26 +01:00
2021-05-01 18:17:55 +02:00
loadReloadMenu(){
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
menuItem "$RELOAD" "$CSESSION"
fi
}
2016-03-26 10:18:26 +01:00
2021-05-01 18:17:55 +02:00
loadSavedsessionSubmenu(){
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
menuSubmenu "Sessions" "$SAVED_SESSIONS"
getSessions
menuSubmenuEnd
fi
}
2016-03-26 10:18:26 +01:00
2021-05-01 18:17:55 +02:00
loadPinMenu(){
if type mb-conkypin &>/dev/null;then
menuItem "Ustaw pozycję Conky" "mb-conkypin"
menuSeparator
fi
}
2016-03-26 10:18:26 +01:00
2021-05-01 18:17:55 +02:00
loadEditMenu(){
if [[ $(pidof conky) ]];then
menuSubmenu "RunningConky" "$RUNNING_CONKY"
menuSeparator "$RUNNING_CONKY"
while read -r session ;do # get running conkys from sessionfile
[[ -z $session ]] && continue
CPATH=$(echo "$session" | awk '{print $3}')
CONKY=$(echo "$CPATH" | awk -F"/" '{print $(NF-1)"/"$NF }')
2022-08-17 14:19:31 +02:00
menuItem "$CONKY" "xdg-open $CPATH"
2021-05-01 18:17:55 +02:00
done < "$CSESSIONFILE"
menuSubmenuEnd
else
menuItem "$NONE"
2016-03-26 10:18:26 +01:00
fi
2021-05-01 18:17:55 +02:00
}
2016-03-26 10:18:26 +01:00
2021-05-01 18:17:55 +02:00
getConkys(){
menuSubmenu "EditConky" "$EDIT_CONKY"
menuSeparator "$EDIT_CONKY"
if type mb-conkyedit &>/dev/null;then # mb-conkyedit script found
menuItem "$CONKY_EDITOR" "mb-conkyedit"
loadEditMenu
2016-03-26 10:18:26 +01:00
else
2021-05-01 18:17:55 +02:00
loadEditMenu
2016-03-26 10:18:26 +01:00
fi
2021-05-01 18:17:55 +02:00
menuSubmenuEnd
}
2021-05-01 18:17:55 +02:00
checkHelpfile(){
DLG="yad --text-info --center --borders=20 \
--title='BunsenLabs Conky Manager Help' \
--window-icon=distributor-logo-bunsenlabs \
--filename=$HELPFILE --fontname=Monospace \
--width=650 --height=700 \
--button=OK:0"
if [[ -e $HELPFILE ]];then
menuItem "Pomoc do Conky Manager" "$DLG"
fi
}
2021-05-01 18:17:55 +02:00
menuStart "Conkymenu" "Conky"
menuSeparator "Conky"
loadChooserMenu
loadReloadMenu
getConkys
menuSeparator
#loadPinMenu
loadNewsessionMenu
loadSavedsessionSubmenu
#menuSeparator
#checkHelpfile
menuEnd