Nautilus integration - New TiddlyWiki script

11 views
Skip to first unread message
Message has been deleted

Paco Rivière

unread,
May 21, 2009, 6:20:40 PM5/21/09
to TiddlyWikiDev
I've cooked a bash script to get a new empty TW right-clicking in a
nautilus folder. It then opens in firefox

It follows nautilus-scripts style and is based in the File Processing
new-text-document script.

Unfortunately I haven't succeded to integrate it in Nautilus actions,
nor in gdm menus - nor opens with file:/// instead of firefox, dont
know why. I even see a simple deb package - or any other distro pack -
to integrate in repositories.

Installation: just copy it in your $HOME/Scripts folder, and
(optionally) edit it to set your prefered behavior.
=========

It sounds to me a natural way of creating new templates.

Here it is:
----
#!/bin/bash
#
# Add a new tiddlywiki in the current directory.
#
# Distributed under the terms of GNU GPL version 2 or later
#
# Copyright (C) 2003 Dexter Ang [the...@mydestiny.net
# based on work by Jeffrey Philips and Johnathan Bailes
# and a script I found on themedepot.org
# TiddlyWiki mods due to Paco Rivière - http://pacoriviere.cat

# KNOWN BUGS:
# - Never tested with an invalid directory. Don't know how.
# - When you enter a blank filename, it generates a .txt hidden file.
# - There's probably more.
# 2003-12-08 Dexter Ang [the...@mydestiny.net]
# Modified for Nautilus 2.4
# -- now detects if executed on desktop "x-nautilus-desktop:///"
# so that it creates the file in /home/{user}/Desktop

# SETTING BEGIN HERE ***
# **********************
# Folder to hold this script and the empty template
TEMPLATE="$HOME/Scripts/empty.html"

# Base name for the new document
NEW="Nou_TiddlyWiki"

# New file extension
EXTENSION="html"

# URL to get an empty template - feel free to change it to other
flavours (Not cheked!)
URL="http://www.tiddlywiki.com/empty.html"
# **********************
# SETTING END HERE ***
# Do not edit after this line

# Remove comment to set Debug Mode. Displays crucial variable values
#DEBUG_MODE=1

# Remove comment to automatically generate filename. Set to 1 to ask
for filename
#ASK_MODE=1

# If template doesn't exist, wget it
if ! [ -a "$TEMPLATE" ] ; then
wget $URL
fi

# Function for displaying variable values and anything else I want
debug() {
[ -n "$DEBUG_MODE" ] && gdialog --title "Debug Mode" --msgbox "$*"
200 100
}

# This gets the current directory. It is "space-space" as it replaces
%20 with spaces
Current_Dir="`echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed -e 's/^file:\/
\///' -e 's/%20/\ /g'`"

if [ $Current_Dir == "" ]; then
Current_Dir=$HOME"/Documents"
fi

# Added 2003-12-08 Dexter Ang
if [ $Current_Dir == "x-nautilus-desktop:///" ]; then
Current_Dir=$HOME"/Desktop"
fi

debug "Current_Dir = $Current_Dir"

if [ $ASK_MODE == "1" ]; then
debug "In Ask Mode"
New_Document="`gdialog --title "New Filename" --inputbox "Enter a new
filename" 200 100 2>&1`"
if [ $? -ne "0" ]; then
debug "Canceled"
exit 1
fi
else
debug "In Non-Ask Mode"
New_Document=$NEW
fi
debug "New_Document = $New_Document"

COUNT=1

# If file doesn't exist, copy it
if ! [ -a "$Current_Dir/$New_Document.$EXTENSION" ] ; then
cp $TEMPLATE "$Current_Dir/$New_Document.$EXTENSION"
# else, go loop until you get a number that works!
else
while ! [ "$retry" ] ; do
let $((COUNT++))
if ! [ -a "$Current_Dir/$New_Document($COUNT).$EXTENSION" ] ; then
cp $TEMPLATE "$Current_Dir/$New_Document($COUNT).$EXTENSION"
retry=1
firefox "$Current_Dir/$New_Document($COUNT).$EXTENSION"
fi
done
fi
Reply all
Reply to author
Forward
0 new messages