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

181 lines
5.2 KiB
Plaintext
Raw Normal View History

2016-03-26 10:18:26 +01:00
#!/bin/bash
# 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'
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"
HELPFILE="/usr/share/mabox/mabox-docs/helpfile-conkyzen.txt"
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
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
declareDependencies yad
2017-01-04 19:18:24 +01:00
case $LANG in
pl*)
CHOOSE_CONKY="Wybierz Conky"
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"
2020-09-01 19:24:09 +02:00
DEFAULT="Domyślna";;
2020-08-26 15:50:04 +02:00
es*)
2020-08-29 20:47:05 +02:00
CHOOSE_CONKY="Elegir recuadro Conky"
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
*)
CHOOSE_CONKY="Choose Conky"
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
2016-03-26 10:18:26 +01:00
getSessions(){ # read any saved sessions from save-sessions file
2020-09-01 19:24:09 +02:00
menuSeparator "$SAVED_SESSIONS"
menuItem "$DEFAULT" "$CSESSION $CSESSIONFILE"
2016-03-26 10:18:26 +01:00
if [ -e "$SESSIONS" ]
then
while read -r session ;do
[[ -z $session ]] && continue # skip if line is blank
menuItem "$session" "$CSESSION $session"
done < "$SESSIONS"
else
echo "$0: Failed to locate saved-sessions in $CONKYPATH" >&2
fi
}
loadChooserMenu(){
if type "$CZEN" &>/dev/null;then # mb-conkyzen script found
2017-01-04 19:18:24 +01:00
menuItem "$CHOOSE_CONKY" "$CZEN"
2016-03-26 10:18:26 +01:00
fi
}
loadNewsessionMenu(){
if type "$CZEN" &>/dev/null;then # mb-conkyzen script found
2017-01-04 19:18:24 +01:00
menuItem "$NEW_SESSION" "$CZEN -z"
2016-03-26 10:18:26 +01:00
fi
}
loadReloadMenu(){
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
2017-01-04 19:18:24 +01:00
menuItem "$RELOAD" "$CSESSION"
2016-03-26 10:18:26 +01:00
fi
}
loadSavedsessionSubmenu(){
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
2017-01-04 19:18:24 +01:00
menuSubmenu "Sessions" "$SAVED_SESSIONS"
2016-03-26 10:18:26 +01:00
getSessions
menuSubmenuEnd
fi
}
loadPinMenu(){
if type mb-conkypin &>/dev/null;then
2016-04-12 21:41:25 +02:00
menuItem "Ustaw pozycję Conky" "mb-conkypin"
2016-03-26 10:18:26 +01:00
menuSeparator
fi
}
loadEditMenu(){
2020-10-02 09:56:51 +02:00
#menuItem "$DEFAULT_CONKYRC" "geany $CONKYDEFAULT"
2016-03-26 10:18:26 +01:00
if [[ $(pidof conky) ]];then
2017-01-04 19:18:24 +01:00
menuSubmenu "RunningConky" "$RUNNING_CONKY"
2020-09-01 19:24:09 +02:00
menuSeparator "$RUNNING_CONKY"
2016-03-26 10:18:26 +01:00
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 }')
menuItem "$CONKY" "geany $CPATH"
done < "$CSESSIONFILE"
menuSubmenuEnd
else
2017-01-04 19:18:24 +01:00
menuItem "$NONE"
2016-03-26 10:18:26 +01:00
fi
}
getConkys(){
2017-01-04 19:18:24 +01:00
menuSubmenu "EditConky" "$EDIT_CONKY"
2020-09-01 19:24:09 +02:00
menuSeparator "$EDIT_CONKY"
2016-03-26 10:18:26 +01:00
if type mb-conkyedit &>/dev/null;then # mb-conkyedit script found
2017-01-04 19:18:24 +01:00
menuItem "$CONKY_EDITOR" "mb-conkyedit"
2016-03-26 10:18:26 +01:00
loadEditMenu
else
loadEditMenu
fi
menuSubmenuEnd
}
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
2016-04-12 21:41:25 +02:00
menuItem "Pomoc do Conky Manager" "$DLG"
2016-03-26 10:18:26 +01:00
fi
}
menuStart "Conkymenu" "Conky"
2020-04-25 17:36:39 +02:00
menuSeparator "Conky"
2016-03-26 10:18:26 +01:00
loadChooserMenu
loadReloadMenu
getConkys
menuSeparator
2016-12-14 12:57:27 +01:00
#loadPinMenu
2016-03-26 10:18:26 +01:00
loadNewsessionMenu
loadSavedsessionSubmenu
2020-04-25 17:36:39 +02:00
#menuSeparator
#checkHelpfile
2016-03-26 10:18:26 +01:00
menuEnd