| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Set IconColumnsNumber which is used by all recipes to determinate the IconBox size, and |
| 4 |
# by the FVWM-Crystal desktop icons manager. |
| 5 |
# Written by Dominique Michel <[email protected]>, 2015 |
| 6 |
|
| 7 |
# Must be included in all the recipes before to check for the Icon manager: |
| 8 |
# PipeRead '$[FVWM_SYSTEMDIR]/scripts/set_DesktopIconsGeom $[vp.height]' |
| 9 |
|
| 10 |
deskmanfile="${FVWM_USERDIR}/tmp/DesktopIcons" |
| 11 |
echo "" > "${deskmanfile}" |
| 12 |
|
| 13 |
# unique temporary file |
| 14 |
tmpdrivefile="/tmp/Icon-Drives_$((`dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -d' ' -f1` % 32768))" |
| 15 |
echo "InfoStoreAdd tmpdrivefile ${tmpdrivefile}" |
| 16 |
|
| 17 |
# We must calculate the size of the button box {{{1 |
| 18 |
# Home: 1 icon, XDG user dirs: 8 icons, partitions: variable, directories: variable |
| 19 |
IconNumber=0 |
| 20 |
if [[ "`cat ${FVWM_USERDIR}/preferences/DefaultDesktopManager | grep components/apps/DesktopIcons`" != "" ]] |
| 21 |
then |
| 22 |
IconNumber=1 |
| 23 |
if [[ "${ShowXDG}" == "yes" ]]; then IconNumber=9; fi |
| 24 |
if [[ "${ShowPartitions}" == "yes" ]] |
| 25 |
then gawk '/^\/.*|^simple-mtpfs.*\// { print $2; }' </proc/mounts |sort > ${tmpdrivefile} |
| 26 |
IconNumber="$((${IconNumber}+`wc -l < ${tmpdrivefile}`))" |
| 27 |
IconNumber="$((${IconNumber}+`wc -l < ${HOME}/.fvwm-crystal/preferences/ShowDirectories`))" |
| 28 |
fi |
| 29 |
IconRowsNumber="$((((${1}-((${EWMH_BS_Panel_Top}+${EWMH_BS_Panel_Bottom}))))/50))" |
| 30 |
echo "SetEnv IconRowsNumber ${IconRowsNumber}" |
| 31 |
tmpvar=$((${IconNumber}/${IconRowsNumber})) |
| 32 |
if [[ "$((${IconRowsNumber}*${tmpvar}))" != "${IconNumber}" ]] |
| 33 |
then echo "SetEnv IconColumnsNumber $((${tmpvar}+1))" |
| 34 |
else echo "setEnv IconColumnsNumber ${tmpvar}" |
| 35 |
fi |
| 36 |
else |
| 37 |
echo "SetEnv IconRowsNumber 0" |
| 38 |
echo "SetEnv IconColumnsNumber 0" |
| 39 |
fi |