1# 2# Default user menu tutorial for xbmbrowser (version 5.0) 3# 4# Dated: 9 July 1995 5# 6# Original Programmer: Ashly Roll ash@cit.gu.edu.au 7# Current Programmer: Anthony Thyssen anthony@cit.gu.edu.au 8# 9# ---------------------------------------------------------------------------- 10# 11# The purpose of this file to to define a set of default user menus to 12# perform a number of actions. This file is an example only. Users making 13# heavy use of the xbmbrowser program is expected to make a copy of this 14# file into a file named ".xbmbrowserrc" in thier own home directory. 15# 16# Each line of this file consists of either :- 17# 18# # comment line 19# A comment line which is completely ignored. 20# 21# menu "main" 22# menu "main" "Main Menu" 23# Add any new menu elements (see below) to this menu. 24# The menu so defined will then popup as and when the appropriate 25# mouse button is pressed. Currently only the following user defined 26# menus can be used by the user. If the menu is not defined the program 27# will `beep' the user as an indication of that fact :- 28# 29# "main" The menu which pops up under the menu button when 30# pressed. Generally this is used a menu of directories 31# the user likes to visit. Warning no file is selected 32# by the user when using this menu so some substitutions 33# may be empty strings. (See Substitions below) 34# "global" A menu of global actions which will popup when either 35# the first two mouse buttons are are pressed on a 36# displayed icon or file symbol or any mouse button on 37# the background of the icon area. (See NOTE below) 38# If the pointer was not over a displayed icon or 39# symbol, no filename, basename, or suffix will be 40# defined. (See function `selected()' below) 41# "bitmap" Display this menu on any displayed X bitmap with the 42# right most (menu) mouse button. 43# "pixmap" As "bitmap", but for any X pixmap (or bad load pixmap) 44# "directory" Same again, but for directory symbols. 45# "other" Again, for any other file symbol (text, binary..) 46# 47# NOTE: If button 1 (leftmost or select mouse button) is pressed 48# on a directory symbol, the browser will automaticaly decend into that 49# directory, instead of poping up the "global" menu. 50# 51# line 52# Just insert a line into the menu at this point. 53# 54# item "Delete" confirm("Really delete %f?") \ 55# exec("rm '%f'") rescan() 56# Insert a item into the current menu which will execute the sequence 57# builtin functions (see below). As it is posible for a very long 58# sequences to be required for some menu items, the menu lines can be 59# continued onto the next line by `backslashing' or `escaping' the 60# return character at the end of the line. 61# 62# Each function may or may-not require some quoted string arguments, 63# with the quote being either single or double, allowing the other 64# quote to be used freely with the argument. 65# 66# Each argument can contain any number of macro substitutions which 67# consist of a % character followed by a single letter. A percent 68# character can be substituted with %%. 69# 70# 71# The following builtin functions are currently available :- 72# 73# quit() Exit xbmbrowser. Need I say more? 74# scan() Completely scan the current directory (Again) 75# NOTE: This is the only way to try to load BadXpm's 76# rescan() Do a fast rescan of the directory 77# chdir("dir") Change directory to the given directory (will scan()) 78# exec("command") Execute the given bourne shell command(s) 79# confirm("prompt") Ask the user to confirm action before continuing on 80# the next function given for this menu item. 81# input("prompt","initial") 82# Ask the user for some input, with the prompt given 83# and a default initial string. 84# selected() If the user pointer was NOT over an icon or symbol 85# then abort the current sequence with a popup error. 86# This function is not usful in anything but the 87# "global" menu, as in the other menus an icon is 88# either always or never selected. 89# 90# The folowing are substition macros you can use within the string 91# arguments. 92# 93# %d - The current directory of the browser (location of the file) 94# %f - The filename of the icon (or file) the user menu in on 95# %b - The basename (suffix removed) of the current filename 96# %s - The suffix of the current filename EG: ".xbm" 97# %i - The result of the last input() query to the user. 98# %h - The Users Home directory (do NOT use ~ in an argument for this) 99# %D - The Initial Startup directory (Where Xbmbrowser Started) 100# %% - Substitutes a percent character. 101# 102# NOTES: 103# The Full path of a selected file is %d%f 104# Also %f and %b%s results in the same substition. 105# 106# WARNING: the substitution macros %f, %b and %s will be an empty string if 107# the users pointer was not over a display icon or file symbol. See the 108# function selected() above. 109# 110# ---------------------------------------------------------------------- 111 112menu "main" 113# 114# The main menu appears under the menu button at the top of xbmbrowser. 115# It provides a place for general controls of the program such as 116# quiting the program, opening a new browser, and selecting directories 117# which the user likes to jump to on a regular basis. 118# 119# NOTE: I do not supply a title to this menu as the menu button itself is 120# the title in this case (it is not a springloaded menu like the others). 121# 122# WARNING: %f, %b and %s substition macros will all be empty for 123# any function sequence in this menu. Also the function selected() 124# will always abort the function sequence for the same reason. 125# 126 127# A table of menu items of places the user likes to jump to. 128# Add your own directory jumps here. 129item "CD .." chdir("..") 130item "CD Start" chdir("%D") 131item "CD Home" chdir("~/") 132item "CD Bitmaps" chdir("==X_BITMAPS==") 133 134# Place a line accross the menu to seperate the next items 135line 136 137# Execute a simple command to start a new xbmbrowser 138# Assuming it is on your command PATH. 139# NOTE the use of input to set the %i substitute string 140item "New Browser.." input("New Browser","%d") exec("xbmbrowser '%i' &") 141 142# More Global Commands not requiring any specific file selection 143item "Text Editor.." input("File to Edit","") \ 144 exec("xterm -g 80x40 -name Vi -T Vi -n Vi -e vi %i &") 145item "Make Dir.." input("Make Directory","") exec("mkdir '%i'") 146item "Execute Cmd.." input("Command to Execute","") exec('%i') 147line 148 149# Provide a means for the user to exit the program. 150# NOTE: this item may be automatically added in a future 151# version of xbmbrowser. But not yet! 152item "Quit Browser.." confirm("Really Quit?") quit() 153 154 155# ------------------------- 156menu "global" "Global Menu" 157# 158# The global menu can be poped up anywhere within the icon display area. 159# and is generally used for general actions common to all file types. 160# IE: general file commands such as renaming, deleting and text editing. 161# 162# The global menu may or may not have a file selected when poped up by the 163# user. As such the substitions %f, %b and %s could be empty strings. The 164# selected() function prevents the user getting himself into trouble 165# because of this. 166# 167 168# Rename or Move a file 169# NOTE the appropiate quoting for the shell command) 170# and the use of selected() here to ensure a file is pointed to. 171item "Rename" selected() input( "Rename File", '%f') \ 172 exec("mv '%f' '%i'") rescan() 173 174# Copy a file elsewhere 175item "Copy" selected() input("Copy File",'%f') \ 176 exec("cp '%f' '%i'") rescan() 177 178# Duplicate this file (no user input required) 179# NOTE: use of base and suffix 180item "Duplicate" selected() exec("cp '%f' '%b_2%s'") rescan() 181 182# Delete file with confirm 183item "Delete" selected() confirm("Really Delete `%f' ?") \ 184 exec("rm '%f'") rescan() 185 186line 187 188# General Command Execute 189# NOTE: that selected is not needed to prevent %f being an empty string 190item "Execute" input("Command to Execute"," %f") exec("%i") 191 192# Make a test editor available globally (don't wait for it either) 193# NOTE that no quotes are used around %f so that the user can't 194# edit a empty file in case no file is selected by the user. 195item "Text Editor" exec("xterm -e ${VISUAL:-${EDITOR:-vi}} %f &") 196 197 198# ---------------------------------------------------------------------- 199# popup the appropriate menu below on third mouse button 200# ---------------------------------------------------------------------- 201 202# ------------------------- 203menu "bitmap" "Bitmap Menu" 204 205item "Bitmap Edit" exec("bitmap '%f' &") 206item "XV Edit" exec("xv '%f' &") 207item "SetRoot" exec("xsetroot -bitmap '%f'") 208item "SetRoot Inv" exec("xsetroot -rv -bitmap '%f'") 209 210line # PbmPlus Filters 211line 212# NOTE: the next item uses multi line shell arguemnt! 213# Don't backslash the end of line within an argument. 214# While this is allowed do not make it too long or an error may result 215item "Invert" \ 216 exec( "xbmtopbm '%f' | pnminvert | pbmtoxbm > '%b.tmp'; 217 if [ -s '%b.tmp' ]; then mv '%b.tmp' '%f'; else rm '%b.tmp'; fi" ) \ 218 rescan() 219# 220# This is better as it is unlikly to make xbmbrowser to barf on large filenames 221item "Crop" \ 222 exec( "xbmtopbm '%f' | pnmcrop 2>/dev/null | pbmtoxbm > '%b.tmp'" ) \ 223 exec( "if [ -s '%b.tmp' ]; then mv '%b.tmp' '%f'; else rm '%b.tmp'; fi" )\ 224 rescan() 225# 226# the following is a `tight' shell code to do the same thing 227item "Add Margin" \ 228 exec("xbmtopbm '%f'|pnmmargin 5|pbmtoxbm>'%b.t'&&mv '%b.t' '%f'||rm '%b.t'")\ 229 rescan() 230item "Flip Horz" \ 231 exec("xbmtopbm '%f'|pnmflip -lr|pbmtoxbm>'%b.t'&&mv '%b.t' '%f'||rm '%b.t'")\ 232 rescan() 233item "Flip Vert" \ 234 exec("xbmtopbm '%f'|pnmflip -tb|pbmtoxbm>'%b.t'&&mv '%b.t' '%f'||rm '%b.t'")\ 235 rescan() 236item "Create Mask" \ 237 exec("xbmtopbm '%f' | pbmmask | pbmtoxbm > '%b_mask%s'")\ 238 rescan() 239item "`' Mask Ext" \ 240 exec("xbmtopbm '%f' | pbmmask -expand | pbmtoxbm > '%b_mask%s'")\ 241 rescan() 242# 243## The better technique is to use a set shell script filters. 244## 245## Some example filters xbm-cmd and xbm-resize is provided as 246## an example of what you can do in a shell script. These filters 247## are cutdown versions of various programs provided with release 1.6 248## of ``Anthony's Icon Library'' from ftp.x.org:/contrib/icons/AIcons. 249## 250## These filters works with both X bitmaps and X pixmaps without change. 251## Using scripts like these result in very simple and easy menu setups 252## -- Anthony Thyssen 253# 254#item "Invert" exec("xbm-cmd '%f' pnminvert") rescan() 255#item "Flip Horz" exec("xbm-cmd '%f' pnmflip -lr") rescan() 256#item "Flip Vert" exec("xbm-cmd '%f' pnmflip -tb") rescan() 257#item "Mask" input("Mask Name", '%f') \ 258# exec("cp '%f' '%i'; xbm-cmd '%i' pbmmask") rescan() 259#item "Mask Ext" input("Mask Name", '%f') \ 260# exec("cp '%f' '%i'; xbm-cmd '%i' pbmmask -expand") rescan() 261#line 262#item "Resize crop" exec("xbm-cmd '%f' pnmcrop 2>/dev/null") rescan() 263#item "Resize expd" exec("xbm-cmd '%f' pnmmargin 5") rescan() 264#item "Resize std" exec("xbm-resize '%f' >/dev/null") rescan() 265#item "Resize 16" exec("xbm-resize -16 '%f' >/dev/null") rescan() 266#item "Resize 32" exec("xbm-resize -32 '%f' >/dev/null") rescan() 267#item "Resize 48" exec("xbm-resize -48 '%f' >/dev/null") rescan() 268#item "Resize 64" exec("xbm-resize -64 '%f' >/dev/null") rescan() 269#item "Resize 64x38" exec("xbm-resize -64x38 '%f' >/dev/null") rescan() 270#item "Resize input" input("Resize to","") \ 271# exec("xbm-resize -%i '%f' >/dev/null") rescan() 272# 273line # PbmPlus Converters 274line 275item ">Pixmap" exec("xbmtopbm '%f' | ppmtoxpm > '%b.xpm'" ) rescan() 276 277# ------------------------- 278menu "pixmap" "Pixmap Menu" 279 280item "Pixmap Edit" exec("pixmap -f '%f' &") 281item "XPaint Edit" exec("xpaint '%f' &") 282item "SetRoot" exec("xloadimage -quiet -onroot '%f' &") 283item "SetRoot xv" exec("xv -root -noresetroot '%f' -quit &") 284# Use this version if xv does not understand X pixmaps (v3.01 and up) 285#item "SetRoot xv" exec("xpmtoppm '%f' | xv -root -noresetroot - -quit &") 286 287line # PbmPlus Filters 288line 289item "Crop" \ 290 exec("xpmtoppm '%f'| pnmcrop |ppmtoxpm>'%b.t'&&mv '%b.t' '%f'||rm '%b.t'")\ 291 rescan() 292item "Add Margin" \ 293 exec("xpmtoppm '%f'|pnmmargin 5|ppmtoxpm>'%b.t'&&mv '%b.t' '%f'||rm '%b.t'")\ 294 rescan() 295item "Flip Horz" \ 296 exec("xpmtoppm '%f'|pnmflip -lr|ppmtoxpm>'%b.t'&&mv '%b.t' '%f'||rm '%b.t'")\ 297 rescan() 298item "Flip Vert" \ 299 exec("xpmtoppm '%f'|pnmflip -tb|ppmtoxpm>'%b.t'&&mv '%b.t' '%f'||rm '%b.t'")\ 300 rescan() 301 302line # PbmPlus Converters 303line 304item ">Xbm Thr" exec("xpmtoppm '%f' | ppmtopgm | 305 pgmtopbm -threshold | pbmtoxbm > '%b.xbm'" ) rescan() 306item ">Xbm Dth" exec("xpmtoppm '%f' | ppmtopgm | pgmnorm 2>/dev/null | 307 pgmtopbm -fs | pbmtoxbm > '%b.xbm'" ) rescan() 308item ">Gif" exec("xpmtoppm '%f' | ppmtogif > '%b.gif'" ) rescan() 309 310# ------------------------- 311menu "directory" "Dir Menu" 312 313item "Goto.." chdir('%f') 314item "New Browser" exec("xbmbrowser '%f' &") 315line 316item "Delete" exec("rmdir '%f'") # this is fairly safe 317#item "Delete Dir" confirm("DANGER -- Really Delete ALL of `%f' -- DANGER")\ 318# exec("rm -fr '%f'") # this is very dangerous! 319 320# ----------------------- 321menu "other" "Other Menu" 322 323item "Text Edit" exec("xterm -e ${VISUAL:-${EDITOR:-vi}} '%f' &") 324item "XV Image" exec("xv '%f' &") 325 326line # PbmPlus Convertors 327line 328item "Icon -> Xbm" \ 329 exec("icontopbm '%f' | pbmtoxbm > '%b.xbm' ") rescan() 330item "Gif -> Xpm" \ 331 exec("giftopnm '%f' | ppmquant 256 2>/dev/null | 332 ppmtoxpm 2>/dev/null > '%b.xpm' ") rescan() 333 334# ----------------------- 335 336