Posted: Sat 27 Aug 2011, 09:47
From users' point of view the advantage would be that they could quickly define several jwm profiles that they could switch easily. Or the emphasis is on detail of customization?
READ-ONLY Archive
https://oldforum.puppylinux.com/
Code: Select all
. ${HOME}/.jwm/JWMRC
#bunch of gui crud here
jwm_param_set 'PARAM1="'${VALUE}'"' ...
jwm_menu_create && jwm -restart
Code: Select all
#!/bin/sh
# jwm-tools-gui
# TODO: what about comments in config file?
# color selectors, checkboxes,...
# 2 file locations
new_values="/dev/shm/jwm_tools_gui"
conf=${HOME}/.jwm/JWMRC
. $conf
text1=$(gettext "Select <span color='darkgreen'>one</span> ore <span color='darkred'>several</span> items
then click or press OK button
to change the <span color='darkred'>values</span> of the <span color='darkgreen'>selected</span> items")
text2=$(gettext "Now change value")
# ask what has to be changed
change_it=$(cat $conf \
| yad --title="jwm-tools" --image="gtk-preferences" --text="$text1" --height=300 \
--list --multiple \
--column="" \
| tr '|' ' ' )
choice=$?
[[ $choice -eq 1 || $choice -eq 252 ]] && exit 0
# let user change selected values
echo -n "" > $new_values
for ONEchange in $change_it
do
param=`echo $ONEchange | cut -d '"' -f 1`
old_value=`echo $ONEchange | cut -d '"' -f 2`
new=$(echo $ONEchange \
| yad --image="gtk-edit" --text="$text2" \
--form \
--field="$param" "$old_value" \
| cut -d '|' -f1
)
echo "s#${param}\"${old_value}\"#${param}\"$new\"#" >>$new_values
done
#apply changes
mv $conf ${conf}tmp
sed -f $new_values ${conf}tmp > $conf
sync
jwm_menu_create && jwm -restart
#end
The format was clear for me.technosaurus wrote: but if you would rather use jwm_param_set, I probably wasn't clear enough on the format
Code: Select all
{ #desktop settings
MENU=${MENU}'
<Desktops count="'${DESKTOPS:-$((${DESKTOPWIDTH}*${DESKTOPHEIGHT}))}'" width="'${DESKTOPWIDTH}'" height="'${DESKTOPHEIGHT}'">
'
i=1 DESKNUM=1
while ([ $i -le ${DESKTOPHEIGHT} ]) do
j=1
while ([ $j -le ${DESKTOPWIDTH} ]) do
DESKTOPNAME=$i","$j
DESKTOPBGTYPE=`eval echo '$DESKTOPBG'${DESKNUM}'TYPE'`
DESKTOPBG=`eval echo '$DESKTOPBG'${DESKNUM}`
[ $DESKTOPBGTYPE ] && MENU=${MENU}'
<Desktop name="'${DESKTOPNAME}'">
<Background type="'${DESKTOPBGTYPE}'">'${DESKTOPBG}'</Background>
</Desktop>
'
DESKNUM=$(($DESKNUM+1))
j=$(($j+1))
done
i=$(($i+1))
done
MENU=${MENU}'
</Desktops>
'
}
Code: Select all
#!/bin/sh
# jwm_param_gui
# version added, same as jwm_tools
# no more sed
# fixed:blank in values
# filtered empty lines and commented lines
# form field types: number, font, combo and color
# TODO: images...
#
version=0.7
conf=${HOME}/.jwm/JWMRC
. $conf
text1=$(gettext "Select <span color='darkgreen'>one</span> ore <span color='darkred'>several</span> items
then click or press OK button
to change the <span color='darkred'>values</span> of the <span color='darkgreen'>selected</span> items")
text2=$(gettext "Now change value")
# ask what has to be changed
change_it=$(cat $conf \
| yad --title="jwm-tools $version" --image="gtk-preferences" --text="$text1" --height=300 \
--list --multiple \
--column="" \
| tr ' ' '_' ) # ex: DejaVu Sans12 -> DejaVu_Sans12
choice=$?
[[ $choice -eq 1 || $choice -eq 252 ]] && exit 0
echo $change_it
# let user change selected values
for ONEchange in $change_it ; do
case "${ONEchange:0:1}" in
"|") continue;; # was blank line
"#") continue;; # was comment
esac
param=${ONEchange//${ONEchange#*=}}
old_value=`echo "$ONEchange" | cut -d '"' -f 2`
field_type=""
case $param in
# SUBMENU=) field_type=':CHK';;
# DRIVES=) field_type=':CHK';;
*FONT*) field_type=':FN';;
DESKTOPS=) field_type=':NUM';;
*WIDTH=) field_type=':NUM';;
*HEIGHT=) field_type=':NUM';;
*SPEED=) field_type=':NUM';;
*DELTA=) field_type=':NUM';;
*DISTANCE=) field_type=':NUM';;
BG=) : ;;
*BG=) field_type=':CLR';;
*FG=) field_type=':CLR';;
*OUTLINE=) field_type=':CLR';;
*TEXT=) field_type=':CLR';;
esac
field_values=""
case $param in
SUBMENU=) field_type=':CB' && field_values='!TRUE!FALSE';;
DRIVES=) field_type=':CB' && field_values='!TRUE!FALSE';;
*MODEL=) field_type=':CB' && field_values='!sloppy!click';;
SNAPMODE=) field_type=':CB' && field_values='!none!sreen!border';;
MOVEMODE=) field_type=':CB' && field_values='!outline!opaque';;
RESIZEMODE=) field_type=':CB' && field_values='!outline!opaque';;
esac
new=$(yad --image="gtk-edit" --text="$text2" \
--form \
--field="${param}${field_type}" "$old_value${field_values}" \
| cut -d '|' -f1 \
| tr '_' ' ' # ex: DejaVu_Sans12 -> DejaVu Sans12
)
# apply change
jwm_param_set $param'"'"$new"'"'
done
#jwm_menu_create && jwm -restart
#end
Code: Select all
#!/bin/ash
linkmount(){ # link/copy as appropriate everything in dir $1 and suffix list them in $2
[ ! -d ${1} ] && echo usage $0 /mnt/directory not $1 && exit
for F in ${1}/* ; do #all files in directory passed in 1st arg
NF=/${F#/*/*/} #packages are mounted at /mnt/package ... remove those for its "/" equivalent
if [ -L ${F} ];then #we need to do symlinks 1st in case a dir is a symlink to .
busybox cp ${F} ${NF} && echo ${NF} >>${2} #we copy symlinks in case they are a relative path
# the echo after && only executes if cp has no errors, but cp without -f errors and doesn't
#overwrite an existing file ... that way we only get a list of new files that can be removed
elif [ -d ${F} ];then #better to make directories than symlink them... no real size anyways
#and a symlink would prevent anything within from being writeable
[ ! -e ${NF} ] && mkdir ${NF} && echo ${NF} >>${2}
linkmount ${F} $2 & #this is recursion + threading in action
elif [ -f ${F} ];then # -f tells us its _not_ a block or char device ... they need write capability
busybox ln -s ${F} ${NF} && echo ${NF} >>${2} # todo cp files in $HOME may need 2b rw
else # we assume it does need to be copied (block or char device)
busybox cp ${F} ${NF} && echo ${NF} >>${2}
fi
done
}
mntdir=/mnt/${1##*/} # we will use /mnt + the filename as the mount location
if [ -d ${mntdir} ];then #if it exists we unmount and remove otherwise mount & run.
while read LINE; do #we are getting the list of files to remove
[ -d ${LINE} ] && rmdir ${LINE} || rm ${LINE} # rmdir directories & rm files
done <${HOME}/.packages/${1##*/}.files
rm ${HOME}/.packages/${1##*/}.files #now that the file are gone this is garbage
umount ${mntdir} #might as well unmount it and free a loop
rmdir ${mntdir} #harmless to leave, but we use it as our toggle switch
else
mkdir -p ${mntdir} # we need to create the place we will mount it.
busybox mount ${1} ${mntdir} # mount the filesystem using busybox for automatic loops
linkmount ${mntdir} ${HOME}/.packages/${1##*/}.files 2>/dev/null #silence output because
#we need the cp,ln errors for preventing "clobbering" and for creating the list of new files.
sleep 1 # wait a little bit in case recursion threads are still going.
[ -e ${mntdir}/usr/share/applications ] && rox ${mntdir}/usr/share/applications/*
#start the GUI app(s) ... todo remove dep on rox using the Exec= line ... just lazy now
fi
Code: Select all
#!/bin/sh
# jwm_param_gui
# version added, same as jwm_tools
# filtered empty lines and commented lines
# form field types: number, font, combo and color
# file for images (jpg and png)
# fonts: selection in yad from installed fonts, format example: DejaVu Sans 12
# TODO: further testing, ranges for numeric values
#
version=0.7.1
Code: Select all
#!/bin/ash
linkmount(){
[ ! -d ${1} ] && echo usage $0 /mnt/directory not $1 && exit
for F in ${1}/* ; do
NF=/${F#/*/*/} #the root of the mount
case ${NF} in #multiuser support
/root*)NF=${HOME}/${NF#/*/}
esac
if [ -L ${F} ];then #handle symlinks first in case of looping links (ex ., ../)
cp ${F} ${NF} && echo ${NF} >>${2}
elif [ -d ${F} ];then #if its a directory, we want to thread and recurse it
[ ! -e ${NF} ] && mkdir ${NF} && NEWDIR=true
linkmount ${F} $2 &
[ $NEWDIR ] && echo ${NF} >>${2}
elif [ -f ${F} ];then #we can just use symlinks for all but dir & nodes
case ${NF} in
${HOME}*)cp ${F} ${NF} && echo ${NF} >>${2};;
*)ln -s ${F} ${NF} && echo ${NF} >>${2};;
esac
else #for /dev/* mostly ... we need write access to block/char devices
cp ${F} ${NF} && echo ${NF} >>${2}
fi
done
}
mntdir=/mnt/${1##*/}
if [ -d ${mntdir} ];then
while read LINE; do
[ -d ${LINE} ] && rmdir ${LINE} || rm ${LINE} &
done <${HOME}/.packages/${1##*/}.files
rm ${HOME}/.packages/${1##*/}.files &
umount ${mntdir} && rmdir ${mntdir} &
else
mkdir -p ${mntdir} 2>/dev/null
busybox mount ${1} ${mntdir} 2>/dev/null
linkmount ${mntdir} ${HOME}/.packages/${1##*/}.files 2>/dev/null
sleep .2
if [ -d ${mntdir}/usr/share/applications ];then
for PROG in ${mntdir}/usr/share/applications/*.desktop; do
while read LINE; do
case $LINE in
Name=*)NAME=${LINE#*=};;
Exec=*)EXEC=${LINE#*=};;
Comment=*)COMM=${LINE#*=};;
Icon=*)ICON=${LINE#*=};;
esac
done <${PROG}
#one prog
jwm_notify "${NAME}" "${COMM}" "${ICON}" "${EXEC}" close "click here to continue without running $NAME" mini-stop.xpm exit
done
fi
fi
Part 1 is doable just keep a throwaway variable that contains each subcategory as it is added then use a case ... to check before addingsc0ttman wrote:I had some thoughts, these may not be of any use to you, but I think I'll have a go myself, as I need this in Akita:
Update jwm_menu_create:
- try to remove duplicates if they end up in same sub category
- maybe remove all non JWM .desktop files??
For example, in a .desktop file, we can add 'WM=openbox' or 'WM=windowmaker', and jwm_menu_create can skip any files which contain WM= (when not WM=jwm)...
their are though, in at least the latest wary and lucid528!technosaurus wrote: If you use submenus, there shouldn't be duplicates in the same submenu though.