164 lines
4.6 KiB
Bash
Executable File
164 lines
4.6 KiB
Bash
Executable File
#!/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"
|
|
CZEN="mb-conkyzen"
|
|
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
|
|
|
|
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"
|
|
CONKY_EDITOR="Conky edytor"
|
|
NONE="Brak"
|
|
;;
|
|
*)
|
|
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"
|
|
;;
|
|
esac
|
|
|
|
|
|
getSessions(){ # read any saved sessions from save-sessions file
|
|
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"
|
|
else
|
|
echo "$0: Failed to locate saved-sessions in $CONKYPATH" >&2
|
|
fi
|
|
}
|
|
|
|
loadChooserMenu(){
|
|
if type "$CZEN" &>/dev/null;then # mb-conkyzen script found
|
|
menuItem "$CHOOSE_CONKY" "$CZEN"
|
|
fi
|
|
}
|
|
|
|
loadNewsessionMenu(){
|
|
if type "$CZEN" &>/dev/null;then # mb-conkyzen script found
|
|
menuItem "$NEW_SESSION" "$CZEN -z"
|
|
fi
|
|
}
|
|
|
|
loadReloadMenu(){
|
|
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
|
|
menuItem "$RELOAD" "$CSESSION"
|
|
fi
|
|
}
|
|
|
|
loadSavedsessionSubmenu(){
|
|
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
|
|
menuSubmenu "Sessions" "$SAVED_SESSIONS"
|
|
getSessions
|
|
menuSubmenuEnd
|
|
fi
|
|
}
|
|
|
|
loadPinMenu(){
|
|
if type mb-conkypin &>/dev/null;then
|
|
menuItem "Ustaw pozycję Conky" "mb-conkypin"
|
|
menuSeparator
|
|
fi
|
|
}
|
|
|
|
loadEditMenu(){
|
|
menuItem "$DEFAULT_CONKYRC" "geany $CONKYDEFAULT"
|
|
if [[ $(pidof conky) ]];then
|
|
menuSubmenu "RunningConky" "$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 }')
|
|
menuItem "$CONKY" "geany $CPATH"
|
|
done < "$CSESSIONFILE"
|
|
menuSubmenuEnd
|
|
else
|
|
menuItem "$NONE"
|
|
fi
|
|
}
|
|
|
|
getConkys(){
|
|
menuSubmenu "EditConky" "$EDIT_CONKY"
|
|
if type mb-conkyedit &>/dev/null;then # mb-conkyedit script found
|
|
menuItem "$CONKY_EDITOR" "mb-conkyedit"
|
|
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
|
|
menuItem "Pomoc do Conky Manager" "$DLG"
|
|
fi
|
|
}
|
|
|
|
menuStart "Conkymenu" "Conky"
|
|
loadChooserMenu
|
|
loadReloadMenu
|
|
getConkys
|
|
menuSeparator
|
|
#loadPinMenu
|
|
loadNewsessionMenu
|
|
loadSavedsessionSubmenu
|
|
menuSeparator
|
|
checkHelpfile
|
|
menuEnd
|