You are not logged in.
Pages: 1
Joe's Window Manager is a very lightweight WM used by distros such as DSL and Puppy Linux which uses fewer system resources than Openbox and Fluxbox despite coming with its own panel by default. The biggest problem is that it can be quite frustrating to set up an applications menu.
I wrote a shell script wrapper (with a lot of awk) for MenuMaker to extend its compatibility to JWM. It does the same thing as MenuMaker except that it only works for JWM and it adds a few extra shortcuts for convenience. MenuMaker is a dependency. It passes options to MenuMaker so it works the same way except that you should not put "JWM" at the end. MenuMaker only creates static menus, as does my script, so I would recommend keeping jwmmaker and MenuMaker installed for as long as you intend on using JWM.
I recommend installing it by saving a file called jwmmaker.sh somewhere safe (it should stay there as long as you want to keep jwmmaker) with the script below as its contents, and making a symlink to /usr/bin like so:
# ln -s /path/to/jwmmaker.sh /usr/bin/jwmmaker
then you can run jwmmaker like so:
$ jwmmaker [options]
Here is how I would do it:
$ jwmmaker -vf
Here is one way to view the MenuMaker help file plus a few distinctions regarding jwmmaker:
$ jwmmaker -h
Here is the script:
#!/bin/sh
# jwmmaker 0.1.0
# Copyright 2014 Drew Nutter
# 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/>.
# Initialize variables
h=0
ii=0
f=0
c=0
t=0
v=0
lo=""
so=""
term=""
categ=""
arg=$(echo $@ | sed 's/f//') # This avoids a force overwrite of the openbox menu if the user has one already.
# Identify options that affect this script's behavior (other than passing).
for (( i=1; $i<=$#; i++ )); do
iter=${!i}
if [ "${iter:0:2}" == "--" ]; then
if [ "$iter" == "--help" ]; then
h=1
elif [ "$iter" == "--version" ]; then
v=1
elif [ "$iter" == "--force" ]; then
f=1
elif [ "$iter" == "--stdout" ]; then
c=1
fi
elif [ "${iter:0:1}" == "-" ]; then
string=${!i}
for (( j=1; j<${#string}; j++ )); do
opt=${string:$j:1}
if [ "$opt" == "h" ]; then
h=1
elif [ "$opt" == "f" ]; then
f=1
elif [ "$opt" == "c" ]; then
c=1
elif [ "$opt" == "i" ]; then
ii=1
elif [ "$opt" == "t" ]; then
t=1
fi
done
fi
done
# Determine whether .jwmrc exists to determine source.
# /etc/system.jwmrc will not be modified, but it will be used to create the new .jwmrc if ~/.jwmrc does not exist.
if [ $HOME/.jmwrc ]; then
jwmrc="$HOME/.jwmrc"
else
jwmrc="/etc/system.jwmrc"
fi
# Main function, call later on depending on options
function main
{
# Pull pre-menu jwmrc
out1=$(awk '
BEGIN { dontprint = 0 }
{
if (dontprint == 0)
{
print $0
}
if ($1 == "<RootMenu")
{
dontprint = 1
}
}' $jwmrc)
# Generate jwmrc menu from mmaker's openbox menu
out2=$(mmaker -ci $arg openbox | awk '
BEGIN {
FS = "[<>/=]"
indent = " "
print indent "<Program label=\"Run\">gmrun</Program>"
print indent "<Separator/>"
print indent "<Program label=\"Terminal\">xterm</Program>"
print indent "<Program label=\"Web Browser\">xdg-open http://</Program>"
print indent "<Program label=\"File Manager\">xdg-open $HOME</Program>"
print indent "<Separator/>"
}
{
if ($2 == "menu id")
{
print indent"<Menu label="$4">"
indent = " "indent
}
if ($3 == "menu")
{
indent = substr(indent,5)
print indent"</Menu>"
}
if ($2 == "item label")
{
printf indent"<Program label="$3">"
}
if ($2 == "execute")
{
print $3"</Program>"
}
}
END{
print indent "<Separator/>"
print indent "<Menu label=\"Exit\">"
print indent " <Program icon=\"lock.png\" label=\"Lock\">"
print indent " xscreensaver-command -lock"
print indent " </Program>"
print indent " <Separator/>"
print indent " <Program label=\"Reboot\">reboot</Program>"
print indent " <Program label=\"Shut Down\">shutdown now</Program>"
print indent " <Separator/>"
print indent " <Restart label=\"Restart JWM\" icon=\"restart.png\"/>"
print indent " <Exit label=\"Exit JWM\" confirm=\"true\" icon=\"quit.png\"/>"
print indent "</Menu>"
}')
# Pull post-menu jwmrc
out3=$(awk '
BEGIN { dontprint = 1 }
{
if ($1 == "</RootMenu>")
{
dontprint = 0
}
if (dontprint == 0)
{
print $0
}
}' $jwmrc)
}
# -h or --help = show help, cancel operation
if [ $h == 1 ]; then
echo -e "JWM has a file (~/.jwmrc) which configures more than just the JWM menu. This script does not alter any part of that file except the menu.\n"
echo "Below is the help file generated by MenuMaker which is installed on your system. Please ignore the \"frontend\" information. Use jwmmaker like so:"
echo -e "$ jwmmaker [options]\n"
mmaker -h
echo -e "\nAbove is the help file generated by MenuMaker which is installed on your system. Please ignore the \"frontend\" information. Use jwmmaker like so:"
echo -e "$ jwmmaker [options]\n"
elif [ $v == 1 ]; then
echo "jwmmaker 0.1.0"
mmaker --version
# Print new xml data based on mmaker analogous user input.
else
if [ $ii == 0 ] && [ $c == 1 ]; then # -c = show output
main
echo "$out1"
echo "$out2"
echo "$out3"
elif [ $c == 1 ]; then # -ci = show only menu output
main
echo "$out2"
elif [ $ii == 1 ]; then # -i = show error message, do not overwrite
echo "-i MUST be used in conjunction with -c; this is done to prevent accidental overwriting of the custom menu"
elif [ $f == 1 ] || [ $jwmrc == "/etc/system.jwmrc" ]; then # If -f or no jwmrc file, $ jwmmaker = write to .jwmrc
cp $HOME/.jwmrc $HOME/.jwmrc.bak 2> /dev/null # Create backup for .jwmrc if it exists
main
echo "$out1" > $HOME/.jwmrc
echo "$out2" >> $HOME/.jwmrc
echo "$out3" >> $HOME/.jwmrc
else # If .jwmrc exists, $ jwmmaker = do nothing, require -f
echo "You already have a .jwmrc file. Its menu section will not be overwritten unless you delete it or use the -f flag."
fi
if [ $c = 1 ]; then # If -c is chosen, put this is at bottom so user can immediately see if there were any errors.
nov=$(echo $@ | sed 's/v//') # No need to double up on verbosity.
mmaker -c $nov openbox > /dev/null
fi
fi
Every time it overwrites the .jwmrc file, it automatically creates (or overwrites) a backup of the previous version in your home directory called .jwmrc.bak. I also added some shortcuts to the main menu by default to improve the convenience of the menu. A few of these shortcuts rely on your system having one of the following packages installed, so these are optional dependencies:
gmrun
xdg-utils
xscreensaver
As I was testing it I ran into some problems regarding how options are passed based on how the arguments are put together by the user. I fixed every issue that I found, but there is a possibility I missed something, so please report any bugs to this thread so I can fix them. I am not a professional software developer, so you might find ways to be more stable or efficient. I'd be more than happy to accept community input to improve this.
COPYING: GPLv3
MenuMaker is licensed under the two clause BSD license.
Last edited by Drew (2014-10-20 19:15:05)
Offline
Pages: 1