1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
|
# Desktop icons for Fvwm-Crystal. Support any file manager.
#
# Version: 2.1.0
# Licence: GPL 2
#
# Written by Dominique Michel <dominique_libre@users.sourceforge.net>, 2010-2013
# for Fvwm-Crystal.
#
# From Fvwm FAQ, 7.13 with huge modifications and added functions.
# This file will add nice 2 pictures icons (a standard feature on the Amiga OS) on the desktop:
# one mandatory for $HOME, the other are optional and are divided into 2 ranges:
# the XDG user directories and the mounted partitions.
# A left click will launch Thunar into the corresponding mount point.
# A middle click will do the same with mc (Thunar doesn't heve a built-in shell).
# A right click on the $HOME icon open the preferences.
#
# Requirement: gawk, sort, Thunar, mc, mount, and /proc/mounts.
# Recommanded: pmount and pmount-gui
# Preferences {{{1
LoadPreferences ShowXDG
LoadPreferences ShowPartitions
LoadPreferences FileBrowser1
LoadPreferences FileBrowser2
# For the recipes
SetEnv DefaultDesktopManager Crystal
AddToFunc ExitFunction I UnsetEnv DefaultDesktopManager
# We must calculate the size of the button box {{{1
# Home: 1 icon, XDG user dirs: 8 icons, partitions: variable
# The icons number {{{2
DestroyFunc GetPartitions
AddToFunc GetPartitions
+ I PipeRead "gawk \'/^\\/.*\\// { print $$$2; }\' </proc/mounts |sort > /tmp/Icon-Drives; \
echo SetEnv IconNumber $(($[IconNumber]+`wc -l < /tmp/Icon-Drives`))"
DestroyFunc GetIconsNumber
AddToFunc GetIconsNumber
+ I SetEnv IconNumber 1
+ I Test (EnvMatch ShowXDG yes) SetEnv IconNumber 9
+ I Test (EnvMatch ShowPartitions yes) GetPartitions
# The number of row and columns {{{2
+ I PipeRead 'echo "SetEnv IconRowsNumber $(((($[vp.height]-92))/60))"'
+ I PipeRead 'tmpvar=$(($[IconNumber]/$[IconRowsNumber])); if [ $(($[IconRowsNumber]*${tmpvar})) != $[IconNumber] ]; then echo "SetEnv IconColumnsNumber $((${tmpvar}+1))"; else echo "SetEnv IconColumnsNumber ${tmpvar}"; fi'
# IconBox {{{1
#+ I PipeRead 'echo "Style * IconBox $(($[vp.width]-((((50*$[IconColumnsNumber]))+$[infostore.DeskIconsXSup))))x$(($[vp.height]-92))+$((36+((50*$[IconColumnsNumber]))))+46"'
# umount/pumount wrapper
DestroyFunc DesktopUmount
AddToFunc DesktopUmount
+ I PipeRead 'if [ "$(echo $* | grep -e media)" != "" ]; \
then exem="pumount"; \
else exem="umount"; \
fi ; \
echo "+ \\\"$[gt.Umount] $*\\\" Exec exec ${exem} $*"'
# The button {{{1
DestroyFunc ShowDesktopIcons
AddToFunc ShowDesktopIcons
+ I Exec exec killall DesktopCheckMounts $[infostore.SILENT]
+ I GetIconsNumber
+ I KillModule FvwmButtons DesktopIcons
+ I DestroyModuleConfig DesktopIcons: *
+ I *DesktopIcons: Geometry $[infostore.DeskIconsSign]+18+46
+ I *DesktopIcons: Padding 1 1
+ I *DesktopIcons: BoxSize Fixed
+ I *DesktopIcons: Rows $[IconRowsNumber]
+ I *DesktopIcons: Columns $[IconColumnsNumber]
+ I *DesktopIcons: Font "xft:$[panel_font]:pixelsize=$[panel_font_size]:$[panel_font_style]"
+ I *DesktopIcons: Colorset $[infostore.cs_transparent]
# Home
+ I *DesktopIcons: (1x1+0+0, Padding 1 6, Frame 0, Icon 48x48/categories/Home.png, ActiveIcon 48x48/categories/Home.png.active.png, Action (Mouse 1) "$[infostore.FileBrowser1] ${HOME} $[infostore.SILENT]", Action (Mouse 2) "$[infostore.FileBrowser2] /home/`id -un` $[infostore.SILENT]", Action (Mouse 3) "Menu /Preferences/IconLauncher")
# XDG user dirs
+ I Test (EnvMatch ShowXDG yes) PipeRead 'xdgicons=""; for name in DESKTOP DOWNLOAD TEMPLATES PUBLICSHARE DOCUMENTS MUSIC PICTURES VIDEOS; \
do eval dir=\\\$\$(echo XDG_"${name}"_DIR); \
echo "DestroyMenu /XDG${name}"; \
echo "AddToMenu /XDG${name}"; \
echo "+ ${dir} Nop"; \
echo "*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) $[infostore.FileBrowser1] ${dir} $[infostore.SILENT], Action(Mouse 2) $[infostore.FileBrowser2] ${dir} $[infostore.SILENT], Action (Mouse 3) Menu /XDG${name})"; \
xdgicons="${xdgicons} ${dir}"; \
y=++y; \
done ; \
echo "InfoStoreAdd XDGIcons \\\"${xdgicons}\\\""'
# partitions
+ I Test (EnvMatch ShowPartitions yes) PipeRead 'partitions=""; while read line; do \
echo "DestroyMenu /Partitions${line}"; \
echo "AddToMenu /Partitions${line}"; \
echo "+ ${line} Nop"; \
echo "DesktopUmount ${line}"; \
if [ "${line}" == "/" ]; \
then icon="48x48/categories/Root.png"; \
else if [ "$(echo ${line} | grep -e cdrom -e dvd)" != "" ]; \
then icon="48x48/categories/CD.png"; \
else icon="48x48/categories/Work_4.png"; \
fi ; \
fi ; \
echo "*DesktopIcons: (1x1, Padding 1 1, Frame 0, Icon ${icon}, ActiveIcon ${icon}.active.png, PressIcon ${icon}.active.png, Action (Mouse 1) $[infostore.FileBrowser1] ${line} $[infostore.SILENT], Action (Mouse 2) $[infostore.FileBrowser2] ${line} $[infostore.SILENT], Action (Mouse 3) Menu /Partitions${line})"; \
partitions="${partitions} ${line}"; \
done </tmp/Icon-Drives; \
echo "InfoStoreAdd PartitionModules \\\"${partitions}\\\""'
# We don't want a PipeRead that will block FVWM every 5 seconds
+ I Test (EnvMatch ShowPartitions yes) Exec exec $[FVWM_SYSTEMDIR]/scripts/DesktopCheckMounts 5
+ I Style DesktopIcons !Borders
+ I Module FvwmButtons DesktopIcons
ShowDesktopIcons
# Functions {{{1
# Preferences menu {{{2
DestroyMenu /Preferences/IconLauncher
AddToMenu /Preferences/IconLauncher
+ DynamicPopupAction Function IconLauncher-generator /Preferences/IconLauncher
DestroyFunc FindUMPartitions
AddToFunc FindUMPartitions
+ I PipeRead "cat /etc/fstab|grep user|grep -v \\\#| awk \'{print $$2}\'|while read line; do partition=${line}; exist=0; while read lines; do if [ ${partition} == ${lines} ]; then exist=1; fi; done </tmp/Icon-Drives; if [ ${exist} == 0 ]; then echo AddToMenu $0 \\\"$[gt.Mount] ${line}\\\" Exec exec mount ${line}; fi; done"
DestroyFunc IconLauncher-generator
AddToFunc IconLauncher-generator
+ I DestroyMenu recreate $0
+ I AddToMenu $0
+ I Test (x pmount-gui) AddToMenu $0 'PMount' Exec exec pmount-gui
+ I Test (x pmount-gui) AddToMenu $0 'PUmount' Exec exec pmount-gui -u
+ I PipeRead "${FVWM_SYSTEMDIR}/scripts/findumpartitions $0"
+ I AddToMenu $0 '$[gt.XDG user directories]' PopUp /Preferences/XDG
+ I AddToMenu $0 '$[gt.Mounted partitions]' PopUp /Preferences/Partitions
+ I AddToMenu $0 '$[gt.Actions]' PopUp /Preferences/FileBrowser
DestroyMenu /Preferences/XDG
AddToMenu /Preferences/XDG
+ '%22x22/fvwm-crystal/On.png%$[gt.On]' ShowXDG
+ '%22x22/fvwm-crystal/Off.png%$[gt.Off]' DontShowXDG
DestroyFunc ShowXDG
AddToFunc ShowXDG
+ I SavePreferences ShowXDG "SetEnv ShowXDG yes"
+ I SetEnv ShowXDG yes
+ I ShowDesktopIcons
+ I RedrawIconBox
DestroyFunc DontShowXDG
AddToFunc DontShowXDG
+ I SavePreferences ShowXDG "SetEnv ShowXDG no"
+ I SetEnv ShowXDG no
+ I ShowDesktopIcons
+ I RedrawIconBox
DestroyMenu /Preferences/Partitions
AddToMenu /Preferences/Partitions
+ '%22x22/fvwm-crystal/On.png%$[gt.On]' ShowPartitions
+ '%22x22/fvwm-crystal/Off.png%$[gt.Off]' DontShowPartitions
DestroyFunc ShowPartitions
AddToFunc ShowPartitions
+ I SavePreferences ShowPartitions "SetEnv ShowPartitions yes"
+ I SetEnv ShowPartitions yes
+ I ShowDesktopIcons
+ I RedrawIconBox
DestroyFunc DontShowPartitions
AddToFunc DontShowPartitions
+ I SavePreferences ShowPartitions "SetEnv ShowPartitions no"
+ I SetEnv ShowPartitions no
+ I ShowDesktopIcons
+ I RedrawIconBox
DestroyMenu /Preferences/FileBrowser
AddToMenu /Preferences/FileBrowser
+ MissingSubmenuFunction FileBrowser-generator
+ '%22x22/categories/directory.png%$[gt.Action ]1' Popup BrowserAction1
+ '%22x22/categories/directory.png%$[gt.Action ]2' Popup BrowserAction2
+ '%22x22/categories/directory.png%$[gt.Custom action ]1' Module FvwmForm FileBrowser-Action1-Dialog
+ '%22x22/categories/directory.png%$[gt.Custom action ]2' Module FvwmForm FileBrowser-Action2-Dialog
DestroyFunc FileBrowser-generator
AddToFunc FileBrowser-generator
+ I DestroyMenu recreate $0
+ I AddToMenu $0
+ I PipeRead 'index=`echo "$0" | sed -e "s:BrowserAction::"`; $[FVWM_SYSTEMDIR]/scripts/DesktopActions "$0" ${index}'
All (FileBrowser-Action1-Dialog) Close
DestroyModuleConfig FileBrowser-Action1-Dialog: *
*FileBrowser-Action1-Dialog: Title "$[gt.File browser action]"
*FileBrowser-Action1-Dialog: Text "$[gt.Type a command to bind to the first mouse button.]"
*FileBrowser-Action1-Dialog: Line center
*FileBrowser-Action1-Dialog: Line center
*FileBrowser-Action1-Dialog: Text "$[gt.A console command must be prefixed by A and space,]"
*FileBrowser-Action1-Dialog: Line center
*FileBrowser-Action1-Dialog: Line center
*FileBrowser-Action1-Dialog: Text "$[gt.use X and space otherwise.]"
*FileBrowser-Action1-Dialog: Line center
*FileBrowser-Action1-Dialog: Line center
*FileBrowser-Action1-Dialog: Input ActionName 40 "A mc"
*FileBrowser-Action1-Dialog: Line center
*FileBrowser-Action1-Dialog: Line center
*FileBrowser-Action1-Dialog: Button quit " $[gt.Save] "
*FileBrowser-Action1-Dialog: Command SetFileBrowser 1 "$(ActionName)"
*FileBrowser-Action1-Dialog: Button quit " $[gt.Not now] " ^[
*FileBrowser-Action1-Dialog: Command Nop
*FileBrowser-Action1-Dialog: Line center
All (FileBrowser-Action1-Dialog) Close
DestroyModuleConfig FileBrowser-Action2-Dialog: *
*FileBrowser-Action2-Dialog: Title "$[gt.File browser action]"
*FileBrowser-Action2-Dialog: Text "$[gt.Type a command to bind to the second mouse button.]"
*FileBrowser-Action2-Dialog: Line center
*FileBrowser-Action2-Dialog: Line center
*FileBrowser-Action2-Dialog: Text "$[gt.A console command must be prefixed by A and space,]"
*FileBrowser-Action2-Dialog: Line center
*FileBrowser-Action2-Dialog: Line center
*FileBrowser-Action2-Dialog: Text "$[gt.use X and space otherwise.]"
*FileBrowser-Action2-Dialog: Line center
*FileBrowser-Action2-Dialog: Line center
*FileBrowser-Action2-Dialog: Input ActionName 40 "A mc"
*FileBrowser-Action2-Dialog: Line center
*FileBrowser-Action2-Dialog: Line center
*FileBrowser-Action2-Dialog: Button quit " $[gt.Save] "
*FileBrowser-Action2-Dialog: Command SetFileBrowser 2 "$(ActionName)"
*FileBrowser-Action2-Dialog: Button quit " $[gt.Not now] " ^[
*FileBrowser-Action2-Dialog: Command Nop
*FileBrowser-Action2-Dialog: Line center
DestroyFunc SetFileBrowser
AddToFunc SetFileBrowser
+ I SavePreferences FileBrowser$[0] "InfoStoreAdd FileBrowser$[0] \'$[1]\'"
+ I InfoStoreAdd FileBrowser$[0] '$[1]'
+ I ShowDesktopIcons
+ I RedrawIconBox
AddToFunc ExitFunction I Test (Quit) Exec exec killall DesktopCheckMounts $[infostore.SILENT]
AddToFunc ExitFunction I Test (ToRestart) Exec exec killall DesktopCheckMounts $[infostore.SILENT]
# vim:ft=fvwm
|