| 1 |
# Desktop icons for Fvwm-Crystal. Support any file manager. |
| 2 |
# |
| 3 |
# Version: 2.1.0 |
| 4 |
# License: GPL 3+ |
| 5 |
# |
| 6 |
# Written by Dominique Michel <[email protected]>, 2010-2015 |
| 7 |
# for Fvwm-Crystal. |
| 8 |
# |
| 9 |
# From Fvwm FAQ, 7.13 with huge modifications and added functions. |
| 10 |
# This file will add nice 2 pictures icons (a standard feature on the Amiga OS) on the desktop: |
| 11 |
# one mandatory for $HOME, the other are optional and are divided into 2 ranges: |
| 12 |
# the XDG user directories and the mounted partitions. |
| 13 |
# A left click will launch Thunar into the corresponding mount point. |
| 14 |
# A middle click will do the same with mc (Thunar doesn't heve a built-in shell). |
| 15 |
# A right click on the $HOME icon open the preferences. |
| 16 |
# |
| 17 |
# Requirement: gawk, sort, at least one file manager like Thunar or mc, mount, and /proc/mounts. |
| 18 |
# Recommanded: pmount and pmount-gui, fusermount for some mobile phones. |
| 19 |
# |
| 20 |
# To use it in your recipe, add "LoadPreferences DefaultDesktopManager" after |
| 21 |
# the EWMH-Desktop and EWMH-Panel-* configuration. |
| 22 |
|
| 23 |
|
| 24 |
# Preferences {{{1 |
| 25 |
LoadPreferences ShowXDG |
| 26 |
LoadPreferences ShowPartitions |
| 27 |
LoadPreferences FileBrowser1 |
| 28 |
LoadPreferences FileBrowser2 |
| 29 |
LoadPreferences DeskIconsSign.$[infostore.Recipe] |
| 30 |
LoadPreferences DeskIconsOnTop |
| 31 |
|
| 32 |
# unique temporary file |
| 33 |
AddToFunc ExitFunction I Test (Quit) Exec exec rm $[infostore.tmpdrivefile] $[infostore.SILENT] |
| 34 |
AddToFunc ExitFunction I Test (ToRestart) Exec exec rm $[infostore.tmpdrivefile] $[infostore.SILENT] |
| 35 |
|
| 36 |
# For the recipes |
| 37 |
SetEnv DefaultDesktopManager Crystal |
| 38 |
AddToFunc ExitFunction I UnsetEnv DefaultDesktopManager |
| 39 |
|
| 40 |
# umount/pumount wrapper |
| 41 |
DestroyFunc DesktopUmount |
| 42 |
AddToFunc DesktopUmount |
| 43 |
+ I PipeRead 'if [ "$(echo $* | grep -e media)" != "" ]; \ |
| 44 |
then exem="pumount"; \ |
| 45 |
else if [ "$(mount | grep \"$* \" | grep simple-mtpfs)" != "" ]; \ |
| 46 |
then exem="fusermount -u"; \ |
| 47 |
else exem="umount"; \ |
| 48 |
fi ; fi; \ |
| 49 |
echo "+ \\\"$[gt.Umount] $*\\\" Exec exec ${exem} $*"' |
| 50 |
|
| 51 |
# Functions {{{1 |
| 52 |
DestroyMenu /Preferences/XDG |
| 53 |
AddToMenu /Preferences/XDG |
| 54 |
+ '%22x22/fvwm-crystal/On.png%$[gt.On]' ShowXDG |
| 55 |
+ '%22x22/fvwm-crystal/Off.png%$[gt.Off]' DontShowXDG |
| 56 |
|
| 57 |
DestroyFunc ShowXDG |
| 58 |
AddToFunc ShowXDG |
| 59 |
+ I SavePreferences ShowXDG "SetEnv ShowXDG yes" |
| 60 |
+ I SetEnv ShowXDG yes |
| 61 |
+ I LoadDesktopIcons |
| 62 |
|
| 63 |
DestroyFunc DontShowXDG |
| 64 |
AddToFunc DontShowXDG |
| 65 |
+ I SavePreferences ShowXDG "SetEnv ShowXDG no" |
| 66 |
+ I SetEnv ShowXDG no |
| 67 |
+ I LoadDesktopIcons |
| 68 |
|
| 69 |
DestroyMenu /Preferences/Partitions |
| 70 |
AddToMenu /Preferences/Partitions |
| 71 |
+ '%22x22/fvwm-crystal/On.png%$[gt.On]' ShowPartitions |
| 72 |
+ '%22x22/fvwm-crystal/Off.png%$[gt.Off]' DontShowPartitions |
| 73 |
|
| 74 |
DestroyFunc ShowPartitions |
| 75 |
AddToFunc ShowPartitions |
| 76 |
+ I SavePreferences ShowPartitions "SetEnv ShowPartitions yes" |
| 77 |
+ I SetEnv ShowPartitions yes |
| 78 |
+ I LoadDesktopIcons |
| 79 |
|
| 80 |
DestroyFunc DontShowPartitions |
| 81 |
AddToFunc DontShowPartitions |
| 82 |
+ I SavePreferences ShowPartitions "SetEnv ShowPartitions no" |
| 83 |
+ I SetEnv ShowPartitions no |
| 84 |
+ I LoadDesktopIcons |
| 85 |
|
| 86 |
DestroyMenu /Preferences/FileBrowser |
| 87 |
AddToMenu /Preferences/FileBrowser |
| 88 |
+ MissingSubmenuFunction FileBrowser-generator |
| 89 |
+ '%22x22/categories/directory.png%$[gt.Action ]1: "$[infostore.FileBrowser1]"' Popup BrowserAction1 |
| 90 |
+ '%22x22/categories/directory.png%$[gt.Action ]2: "$[infostore.FileBrowser2]"' Popup BrowserAction2 |
| 91 |
+ '%22x22/categories/directory.png%$[gt.Custom action ]1' Module FvwmForm FileBrowser-Action1-Dialog |
| 92 |
+ '%22x22/categories/directory.png%$[gt.Custom action ]2' Module FvwmForm FileBrowser-Action2-Dialog |
| 93 |
|
| 94 |
DestroyFunc FileBrowser-generator |
| 95 |
AddToFunc FileBrowser-generator |
| 96 |
+ I DestroyMenu recreate $0 |
| 97 |
+ I AddToMenu $0 |
| 98 |
+ I PipeRead 'index=`echo "$0" | sed -e "s:BrowserAction::"`; $[FVWM_SYSTEMDIR]/scripts/DesktopActions "$0" ${index}' |
| 99 |
|
| 100 |
All (FileBrowser-Action1-Dialog) Close |
| 101 |
DestroyModuleConfig FileBrowser-Action1-Dialog: * |
| 102 |
*FileBrowser-Action1-Dialog: Title "$[gt.File browser action]" |
| 103 |
*FileBrowser-Action1-Dialog: Text "$[gt.Type a command to bind to the first mouse button.]" |
| 104 |
*FileBrowser-Action1-Dialog: Line center |
| 105 |
*FileBrowser-Action1-Dialog: Line center |
| 106 |
*FileBrowser-Action1-Dialog: Text "$[gt.A console command must be prefixed by A and space,]" |
| 107 |
*FileBrowser-Action1-Dialog: Line center |
| 108 |
*FileBrowser-Action1-Dialog: Line center |
| 109 |
*FileBrowser-Action1-Dialog: Text "$[gt.use X and space otherwise.]" |
| 110 |
*FileBrowser-Action1-Dialog: Line center |
| 111 |
*FileBrowser-Action1-Dialog: Line center |
| 112 |
*FileBrowser-Action1-Dialog: Input ActionName 40 "$[infostore.FileBrowser1]" |
| 113 |
*FileBrowser-Action1-Dialog: Line center |
| 114 |
*FileBrowser-Action1-Dialog: Line center |
| 115 |
*FileBrowser-Action1-Dialog: Button quit " $[gt.Save] " ^M |
| 116 |
*FileBrowser-Action1-Dialog: Command SetFileBrowser 1 "$(ActionName)" |
| 117 |
*FileBrowser-Action1-Dialog: Button quit " $[gt.Not now] " ^[ |
| 118 |
*FileBrowser-Action1-Dialog: Command Nop |
| 119 |
*FileBrowser-Action1-Dialog: Line center |
| 120 |
|
| 121 |
All (FileBrowser-Action2-Dialog) Close |
| 122 |
DestroyModuleConfig FileBrowser-Action2-Dialog: * |
| 123 |
*FileBrowser-Action2-Dialog: Title "$[gt.File browser action]" |
| 124 |
*FileBrowser-Action2-Dialog: Text "$[gt.Type a command to bind to the second mouse button.]" |
| 125 |
*FileBrowser-Action2-Dialog: Line center |
| 126 |
*FileBrowser-Action2-Dialog: Line center |
| 127 |
*FileBrowser-Action2-Dialog: Text "$[gt.A console command must be prefixed by A and space,]" |
| 128 |
*FileBrowser-Action2-Dialog: Line center |
| 129 |
*FileBrowser-Action2-Dialog: Line center |
| 130 |
*FileBrowser-Action2-Dialog: Text "$[gt.use X and space otherwise.]" |
| 131 |
*FileBrowser-Action2-Dialog: Line center |
| 132 |
*FileBrowser-Action2-Dialog: Line center |
| 133 |
*FileBrowser-Action2-Dialog: Input ActionName 40 "$[infostore.FileBrowser2]" |
| 134 |
*FileBrowser-Action2-Dialog: Line center |
| 135 |
*FileBrowser-Action2-Dialog: Line center |
| 136 |
*FileBrowser-Action2-Dialog: Button quit " $[gt.Save] " ^M |
| 137 |
*FileBrowser-Action2-Dialog: Command SetFileBrowser 2 "$(ActionName)" |
| 138 |
*FileBrowser-Action2-Dialog: Button quit " $[gt.Not now] " ^[ |
| 139 |
*FileBrowser-Action2-Dialog: Command Nop |
| 140 |
*FileBrowser-Action2-Dialog: Line center |
| 141 |
|
| 142 |
DestroyFunc SetFileBrowser |
| 143 |
AddToFunc SetFileBrowser |
| 144 |
+ I SavePreferences FileBrowser$[0] "InfoStoreAdd FileBrowser$[0] \'$[1]\'" |
| 145 |
+ I InfoStoreAdd FileBrowser$[0] '$[1]' |
| 146 |
+ I Exec exec killall DesktopCheckMounts $[infostore.SILENT] |
| 147 |
+ I KillModule FvwmButtons DesktopIcons |
| 148 |
+ I DestroyModuleConfig DesktopIcons: * |
| 149 |
+ I Exec exec FvwmCommand "Include components/apps/DesktopIcons" |
| 150 |
|
| 151 |
AddToFunc ExitFunction I Test (Quit) Exec exec killall DesktopCheckMounts $[infostore.SILENT] |
| 152 |
AddToFunc ExitFunction I Test (ToRestart) Exec exec killall DesktopCheckMounts $[infostore.SILENT] |
| 153 |
|
| 154 |
DestroyMenu /Preferences/DeskIconsPlace |
| 155 |
AddToMenu /Preferences/DeskIconsPlace |
| 156 |
+ '%22x22/fvwm-crystal/Left.png%$[gt.Left]' SetDeskIconsPlace " " |
| 157 |
+ '%22x22/fvwm-crystal/Right.png%$[gt.Right]' SetDeskIconsPlace "-" |
| 158 |
|
| 159 |
|
| 160 |
DestroyFunc SetDeskIconsPlace |
| 161 |
AddToFunc SetDeskIconsPlace |
| 162 |
+ I Exec exec killall DesktopCheckMounts $[infostore.SILENT] |
| 163 |
+ I SavePreferences DeskIconsSign.$[infostore.Recipe] "InfoStoreAdd DeskIconsSign \'$[0]\'" |
| 164 |
+ I InfoStoreAdd DeskIconsSign '$[0]' |
| 165 |
+ I KillModule FvwmButtons DesktopIcons |
| 166 |
+ I DestroyModuleConfig DesktopIcons: * |
| 167 |
+ I Exec exec rm $[infostore.tmpdrivefile] $[infostore.SILENT] |
| 168 |
# Schedule time should be > DesktopCheckMounts time loop |
| 169 |
+ I Schedule 4500 Exec exec FvwmCommand "Include components/apps/DesktopIcons" |
| 170 |
|
| 171 |
DestroyMenu /Preferences/DeskIconsTop |
| 172 |
AddToMenu /Preferences/DeskIconsTop |
| 173 |
+ '%22x22/fvwm-crystal/On.png%$[gt.On]' DeskIconsOnTop |
| 174 |
+ '%22x22/fvwm-crystal/Off.png%$[gt.Off]' DeskIconsOnBottom |
| 175 |
|
| 176 |
DestroyFunc DeskIconsOnTop |
| 177 |
AddToFunc DeskIconsOnTop |
| 178 |
+ I SavePreferences DeskIconsOnTop "Style DesktopIcons State 30" |
| 179 |
+ I All (DesktopIcons) WindowStyle State 30 |
| 180 |
|
| 181 |
DestroyFunc DeskIconsOnBottom |
| 182 |
AddToFunc DeskIconsOnBottom |
| 183 |
+ I SavePreferences DeskIconsOnTop "Style DesktopIcons !State 30" |
| 184 |
+ I All (DesktopIcons) WindowStyle !State 30 |
| 185 |
|
| 186 |
DestroyFunc LoadDesktopIcons |
| 187 |
AddToFunc LoadDesktopIcons |
| 188 |
+ I PipeRead '$[FVWM_SYSTEMDIR]/scripts/desktop_manager \"$[infostore.DeskIconsSign]\" $[infostore.cs_transparent] "$[infostore.SILENT]" \"$[infostore.FileBrowser1]\" \"$[infostore.FileBrowser2]\" \ |
| 189 |
$[vp.height] $[infostore.tmpdrivefile]' |
| 190 |
+ I Include tmp/DesktopIcons |
| 191 |
+ I RedrawIconBox |
| 192 |
|
| 193 |
LoadDesktopIcons |
| 194 |
|
| 195 |
# vim:ft=fvwm |