conky,tint2,kb pipemenus

master
Daniel Napora 2016-03-26 10:18:26 +01:00
parent 919ed5554e
commit a3caa33172
3 changed files with 295 additions and 0 deletions

View File

@ -0,0 +1,137 @@
#!/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
menuItem "Conky Chooser" "$CZEN"
fi
}
loadNewsessionMenu(){
if type "$CZEN" &>/dev/null;then # mb-conkyzen script found
menuItem "New Conky Session" "$CZEN -z"
fi
}
loadReloadMenu(){
if type "$CSESSION" &>/dev/null;then # mb-conky-session script found
menuItem "Reload Conkys" "$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 "Pin moveable Conkys" "mb-conkypin"
menuSeparator
fi
}
loadEditMenu(){
menuItem "Default conkyrc" "geany $CONKYDEFAULT"
if [[ $(pidof conky) ]];then
menuSubmenu "RunningConky" "Running Conkys"
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 "No Running Conkys"
fi
}
getConkys(){
menuSubmenu "EditConky" "Edit Conkys"
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 "Conky Manager Help" "$DLG"
fi
}
menuStart "Conkymenu" "Conky"
loadChooserMenu
loadReloadMenu
getConkys
menuSeparator
loadPinMenu
loadNewsessionMenu
loadSavedsessionSubmenu
menuSeparator
checkHelpfile
menuEnd

View File

@ -0,0 +1,79 @@
#!/bin/bash
# mabox-kb-pipemenu - an Openbox pipemenu for displaying keybinds
# 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/>.
# NB The keybinds in the menu are clickable, except for the Openbox
# commands, which just exit the menu
# mb-kb is used to parse rc.xml and send the output to a textfile
MB_COMMON_LIBDIR="/usr/lib/mabox/mabox-common"
USR_CFG_DIR="$HOME/.config/openbox"
KBSCRIPT="mb-kb"
RCPATH="$USR_CFG_DIR/rc.xml"
KBTEXT="$USR_CFG_DIR/kbinds.txt"
if ! . "$MB_COMMON_LIBDIR/mabox-include.cfg" 2> /dev/null; then
echo $"Error: Failed to locate mabox-include.cfg in $MB_COMMON_LIBDIR" >&2
exit 1
fi
# test if mb-kb exists in path
if type "$KBSCRIPT" &> /dev/null;then
# run script to write kbinds.txt, suppress terminal output
"$KBSCRIPT" > /dev/null
else
menuStart
menuSeparator "$KBSCRIPT is not available. Try installing bunsen-utilities."
menuEnd
exit 1
fi
if [[ $1 = '--rcedit' ]];then # "Backup & Edit rc.xml" is chosen in menu
# backup rc.xml first
NOW=$(date +"%Y%m%d-%H%M")
RCBKP="$RCPATH.$NOW"
cp "$RCPATH" "$RCBKP"
geany "$RCPATH" # open rc.xml in default editor
fi
# pipemenu
menuStart
menuItem "Backup and Edit rc.xml" "mabox-kb-pipemenu --rcedit"
menuSeparator
menuItem "Display Keybinds in new window" "mb-kb --gui"
menuSubmenu "Display keybinds" "Display Keybinds in menu"
menuSeparator "Openbox window commands"
while read -r a b c;do # write out Openbox commands (not clickable)
if [[ "$a" = "o" ]];then
curItem=$(printf "%-20s %s" "$b" "$c")
menuItem "$curItem" "echo >/dev/null 2>&1"
fi
done < "$KBTEXT"
menuSeparator
menuSeparator "'Run' commands"
while read -r a b c;do # write out 'Run' commands (clickable)
if [[ "$a" = "x" ]];then
curItem=$(printf "%-20s %s" "$b" "$c")
menuItem "$curItem" "$c"
fi
done < "$KBTEXT"
menuSubmenuEnd
menuEnd
exit 0

View File

@ -0,0 +1,79 @@
#!/bin/bash
# mabox-tint2-pipemenu - an Openbox pipemenu for tint2 manipulation
# Copyright (C) 2015-2016 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'
TINT2PATH="$HOME/.config/tint2"
TINT2RC="$TINT2PATH/tint2rc"
TZEN="mb-tint2zen"
if ! . "$MB_COMMON_LIBDIR/mabox-include.cfg" 2> /dev/null; then
echo $"Error: Failed to source mabox-include.cfg in $MB_COMMON_LIBDIR" >&2
exit 1
fi
loadTEditmenu(){
menuSeparator
menuItem "Default tint2rc" "geany $TINT2RC"
if [ "$(pidof tint2)" ];then
menuSubmenu "RunningTint2" "Running Tint2s"
pgrep -a tint2 | while read -r pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
TINT=${cmd##* }
TINT2=${TINT#$HOME/.config/}
if [[ $TINT = tint2 ]];then
TINT="$TINT2RC"
TINT2="Default tint2rc"
fi
menuItem "$TINT2" "geany $TINT"
fi
done
menuSubmenuEnd
fi
}
getTint2s(){
menuSubmenu "EditTint2" "Edit Tint2s"
if type mb-tint2edit &>/dev/null;then # mb-tint2edit script found
menuItem "Tint2 Editor" "mb-tint2edit"
loadTEditmenu
else
loadTEditmenu
fi
menuSubmenuEnd
}
loadChoosermenu(){
if type $TZEN &>/dev/null;then # mb-tint2zen script found
menuItem "Tint2 Chooser" "$TZEN"
fi
}
loadRestartmenu(){
if [ "$(pidof tint2)" ];then
if type mb-tint2restart &>/dev/null;then # mb-tint2restart script found
menuItem "Restart Tint2" "mb-tint2restart"
fi
fi
}
menuStart "Tintmenu" "Tint2"
loadChoosermenu
loadRestartmenu
getTint2s
menuEnd