| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# Generation of the FVWM-Crystal Desktop Manager (icons on the desktop) |
| 4 |
# Written by Dominique Michel <[email protected]>, 2015 |
| 5 |
# Generate the desktop manager in $[FVWM_USERDIR]/tmp/DesktopIcons. |
| 6 |
|
| 7 |
# Syntax: |
| 8 |
# PipeRead '$[FVWM_SYSTEMDIR]/scripts/desktop_manager $[infostore.DeskIconsSign] $[infostore.cs_transparent] $[infostore.SILENT] $[infostore.FileBrowser1] $[infostore.FileBrowser2] \ |
| 9 |
# $[vp.height] $[infostore.tmpdrivefile]' |
| 10 |
# Include tmp/DesktopIcons |
| 11 |
|
| 12 |
deskmanfile="${FVWM_USERDIR}/tmp/DesktopIcons" |
| 13 |
echo "" > "${deskmanfile}" |
| 14 |
|
| 15 |
# We must calculate the size of the button box {{{1 |
| 16 |
# Home: 1 icon, XDG user dirs: 8 icons, partitions: variable, directories: variable |
| 17 |
IconNumber=1 |
| 18 |
if [[ "${ShowXDG}" == "yes" ]]; then IconNumber=9; fi |
| 19 |
if [[ "${ShowPartitions}" == "yes" ]] |
| 20 |
then gawk '/^\/.*|^simple-mtpfs.*\// { print $2; }' </proc/mounts |sort > ${7} |
| 21 |
IconNumber="$((${IconNumber}+`wc -l < ${7}`))" |
| 22 |
IconNumber="$((${IconNumber}+`wc -l < ${HOME}/.fvwm-crystal/preferences/ShowDirectories`))" |
| 23 |
fi |
| 24 |
IconRowsNumber="$((((${6}-((${EWMH_BS_Panel_Top}+${EWMH_BS_Panel_Bottom}))))/50))" |
| 25 |
tmpvar=$((${IconNumber}/${IconRowsNumber})) |
| 26 |
if [[ "$((${IconRowsNumber}*${tmpvar}))" != "${IconNumber}" ]] |
| 27 |
then IconColumnsNumber="$((${tmpvar}+1))" |
| 28 |
else IconColumnsNumber="${tmpvar}" |
| 29 |
fi |
| 30 |
|
| 31 |
# Preference menu |
| 32 |
echo "DestroyMenu /Preferences/IconLauncher" >> "${deskmanfile}" |
| 33 |
echo "AddToMenu /Preferences/IconLauncher" >> "${deskmanfile}" |
| 34 |
if [ -f pmount-gui ] |
| 35 |
then echo "+ PMount \"Exec exec pmount-gui\"" >> "${deskmanfile}" |
| 36 |
echo "+ PUMount \"Exec exec pmount-gui -u\"" >> "${deskmanfile}"; fi |
| 37 |
if [[ "${ShowPartitions}" == "yes" ]] |
| 38 |
then cat /etc/fstab|grep user|grep -v \#| awk '{print $2}'|while read line |
| 39 |
do partition=${line} |
| 40 |
exist=0 |
| 41 |
while read lines |
| 42 |
do if [ ${partition} = ${lines} ] |
| 43 |
then exist=1 |
| 44 |
fi |
| 45 |
done <${7} |
| 46 |
if [ ${exist} = 0 ] |
| 47 |
then echo "+ \"\$[gt.Mount] ${line}\" Exec exec mount ${line}" >> "${deskmanfile}" |
| 48 |
fi |
| 49 |
done |
| 50 |
fi |
| 51 |
echo "+ '\$[gt.XDG user directories]' PopUp /Preferences/XDG" >> "${deskmanfile}" |
| 52 |
echo "+ '\$[gt.Mounted partitions]' PopUp /Preferences/Partitions" >> "${deskmanfile}" |
| 53 |
echo "+ '\$[gt.Show directories]' LaunchFileWithHelp ShowDirectories" >> "${deskmanfile}" |
| 54 |
echo "+ '\$[gt.Actions]' PopUp /Preferences/FileBrowser" >> "${deskmanfile}" |
| 55 |
echo "+ '\$[gt.Emplacement]' Popup /Preferences/DeskIconsPlace" >> "${deskmanfile}" |
| 56 |
echo "+ '\$[gt.Show on top with panels]' Popup /Preferences/DeskIconsTop" >> "${deskmanfile}" |
| 57 |
|
| 58 |
echo "" >> "${deskmanfile}" |
| 59 |
|
| 60 |
# The button {{{1 |
| 61 |
echo "DestroyFunc ShowDesktopIcons" >> "${deskmanfile}" |
| 62 |
echo "AddToFunc ShowDesktopIcons" >> "${deskmanfile}" |
| 63 |
#echo "+ I GetIconsNumber" >> "${deskmanfile}" |
| 64 |
echo "+ I KillModule FvwmButtons DesktopIcons" >> "${deskmanfile}" |
| 65 |
echo "+ I DestroyModuleConfig DesktopIcons: *" >> "${deskmanfile}" |
| 66 |
if [ "$1" = "-" ] |
| 67 |
then echo "+ I *DesktopIcons: Geometry $((${IconColumnsNumber}*48))x$((${IconRowsNumber}*48))${1}+${EWMH_BS_Panel_Right}+${EWMH_BS_Panel_Top}" >> "${deskmanfile}" |
| 68 |
else echo "+ I *DesktopIcons: Geometry $((${IconColumnsNumber}*48))x$((${IconRowsNumber}*48))${1}+${EWMH_BS_Panel_Left}+${EWMH_BS_Panel_Top}" >> "${deskmanfile}" |
| 69 |
fi |
| 70 |
echo "+ I *DesktopIcons: Padding 1 1" >> "${deskmanfile}" |
| 71 |
echo "+ I *DesktopIcons: BoxSize Fixed" >> "${deskmanfile}" |
| 72 |
echo "+ I *DesktopIcons: Rows ${IconRowsNumber}" >> "${deskmanfile}" |
| 73 |
echo "+ I *DesktopIcons: Columns ${IconColumnsNumber}" >> "${deskmanfile}" |
| 74 |
echo "+ I *DesktopIcons: Font \"xft:${panel_font}:pixelsize=${panel_font_size}:${panel_font_style}\"" >> "${deskmanfile}" |
| 75 |
echo "+ I *DesktopIcons: Colorset ${2}" >> "${deskmanfile}" |
| 76 |
# Home |
| 77 |
echo "+ I *DesktopIcons: (1x1+0+0, Padding 1 1, Frame 0, Icon 48x48/categories/Home.png, ActiveIcon 48x48/categories/Home.png.active.png, Action (Mouse 1) \"${4} ${HOME} ${3}\", Action (Mouse 2) \"${5} /home/`id -un` ${3}\", Action (Mouse 3) \"Menu /Preferences/IconLauncher\")" >> "${deskmanfile}" |
| 78 |
# XDG user dirs |
| 79 |
if [[ "${ShowXDG}" == "yes" ]] |
| 80 |
then xdgicons="" |
| 81 |
for name in DESKTOP DOWNLOAD TEMPLATES PUBLICSHARE DOCUMENTS MUSIC PICTURES VIDEOS |
| 82 |
do eval dir=\$$(echo XDG_"${name}"_DIR) |
| 83 |
echo "DestroyMenu /XDG${name}" |
| 84 |
echo "AddToMenu /XDG${name}" |
| 85 |
echo "+ ${dir} Nop" |
| 86 |
echo "+ I *DesktopIcons: (1x1, Padding 1 1, Frame 0, Icon 48x48/categories/${name}.png, ActiveIcon 48x48/categories/${name}.png.active.png, PressIcon 48x48/categories/${name}.png.active.png, Action (Mouse 1) \"${4} ${dir} ${3}\", Action(Mouse 2) \"${5} ${dir} ${3}\", Action (Mouse 3) \"Menu /XDG${name}\")" >> "${deskmanfile}" |
| 87 |
xdgicons="${xdgicons} ${dir}" |
| 88 |
y=++y |
| 89 |
done |
| 90 |
echo "InfoStoreAdd XDGIcons \"${xdgicons}\"" |
| 91 |
fi |
| 92 |
# partitions |
| 93 |
if [[ "${ShowPartitions}" == "yes" ]] |
| 94 |
then partitions="" |
| 95 |
while read line |
| 96 |
do echo "DestroyMenu /Partitions${line}" |
| 97 |
echo "AddToMenu /Partitions${line}" |
| 98 |
echo "+ ${line} Nop" |
| 99 |
echo "DesktopUmount ${line}" |
| 100 |
if [[ "${line}" == "/" ]] |
| 101 |
then icon="48x48/categories/Root.png" |
| 102 |
else if [[ "$(echo ${line} | grep -e cdrom -e dvd)" != "" ]] |
| 103 |
then icon="48x48/categories/CD.png" |
| 104 |
else icon="48x48/categories/Work_4.png" |
| 105 |
fi |
| 106 |
fi |
| 107 |
echo "+ I *DesktopIcons: (1x1, Padding 1 1, Frame 0, Icon ${icon}, ActiveIcon ${icon}.active.png, PressIcon ${icon}.active.png, Action (Mouse 1) \"${4} ${line} ${3}\", Action (Mouse 2) \"${5} ${line} ${3}\", Action (Mouse 3) \"Menu /Partitions${line}\")" >> "${deskmanfile}" |
| 108 |
partitions="${partitions} ${line}" |
| 109 |
done <${7} |
| 110 |
echo "InfoStoreAdd PartitionModules \"${partitions}\"" |
| 111 |
# We don't want a PipeRead that will block FVWM every 5 seconds |
| 112 |
pidof -x DesktopCheckMounts 1>2 2>/dev/null || echo "Exec exec ${FVWM_SYSTEMDIR}/scripts/DesktopCheckMounts 4" |
| 113 |
else pidof -x DesktopCheckMounts 1>2 2>/dev/null && killall DesktopCheckMounts |
| 114 |
fi |
| 115 |
# directories |
| 116 |
# To work with spaces into the directories names, you must quote them with single quotes in ${FVWM_USERDIR}/preferences/ShowDirectories |
| 117 |
directories="" |
| 118 |
while read line |
| 119 |
do echo "DestroyMenu /Directories${line}" |
| 120 |
echo "AddToMenu /Directories${line}" |
| 121 |
echo "+ ${line} Nop" |
| 122 |
icon="48x48/categories/Yellow_Drawer.png" |
| 123 |
echo "+ I *DesktopIcons: (1x1, Padding 1 1, Frame 0, ActiveTitle \"${line}\", Icon ${icon}, ActiveIcon ${icon}.active.png, PressIcon ${icon}.active.png, Action (Mouse 1) \"${4} ${line} ${3}\", Action (Mouse 2) \"${5} ${line} ${3}\", Action (Mouse 3) \"Menu /Directories${line}\")" >> "${deskmanfile}" |
| 124 |
directories="${directories} ${line}" >> "${deskmanfile}" |
| 125 |
done <${FVWM_USERDIR}/preferences/ShowDirectories |
| 126 |
echo "+ I Style DesktopIcons !Borders" >> "${deskmanfile}" |
| 127 |
echo "+ I Module FvwmButtons DesktopIcons" >> "${deskmanfile}" |
| 128 |
|
| 129 |
echo "ShowDesktopIcons" >> "${deskmanfile}" |
| 130 |
|
| 131 |
|
| 132 |
# Laurent Gaudé - Eldorado |