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

138 lines
4.0 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"
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
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
2016-04-12 20:51:00 +02:00
menuItem "Wybierz Conky" "$CZEN"
2016-03-26 10:18:26 +01:00
fi
}
loadNewsessionMenu(){
if type "$CZEN" &>/dev/null;then # mb-conkyzen script found
2016-04-12 20:51:00 +02:00
menuItem "Nowa sesja Conky" "$CZEN -z"
2016-03-26 10:18:26 +01:00
fi
}
loadReloadMenu(){
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
2016-04-12 20:51:00 +02:00
menuItem "Przeładuj Conky" "$CSESSION"
2016-03-26 10:18:26 +01:00
fi
}
loadSavedsessionSubmenu(){
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
2016-04-12 20:51:00 +02:00
menuSubmenu "Sessions" "Zachowane sesje"
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(){
2016-04-12 20:51:00 +02:00
menuItem "Domyślne conkyrc" "geany $CONKYDEFAULT"
2016-03-26 10:18:26 +01:00
if [[ $(pidof conky) ]];then
2016-04-12 21:41:25 +02:00
menuSubmenu "RunningConky" "Działające 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
2016-04-12 21:41:25 +02:00
menuItem "Brak"
2016-03-26 10:18:26 +01:00
fi
}
getConkys(){
2016-04-12 21:41:25 +02:00
menuSubmenu "EditConky" "Edytuj Conky"
2016-03-26 10:18:26 +01:00
if type mb-conkyedit &>/dev/null;then # mb-conkyedit script found
2016-04-12 21:41:25 +02:00
menuItem "Edytor Conky" "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"
loadChooserMenu
loadReloadMenu
getConkys
menuSeparator
2016-12-14 12:57:27 +01:00
#loadPinMenu
2016-03-26 10:18:26 +01:00
loadNewsessionMenu
loadSavedsessionSubmenu
menuSeparator
checkHelpfile
menuEnd