dirnotes-cli is working pretty well; copy the library code from -cli to the other two
This commit is contained in:
@@ -14,20 +14,30 @@ Table of Contents
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
The **dirnotes** family of apps allows you to add a descriptive comment to a file. The descriptions are stored in two places:
|
||||
The **dirnotes** family of apps allows you to add a descriptive comment to a file.
|
||||
The descriptions are stored in two places:
|
||||
|
||||
* in the _xattr_ properties of the file
|
||||
* in a _database_ located in the user's home directory
|
||||
|
||||
[The [MacOS](#macos) stores its comments in a similar way.]
|
||||
|
||||
The <code>**dirnotes**</code> app is a GUI app, using the Qt5 framework. At startup, it displays the contents of the current directory, and the comments associated with any of the files or directories.
|
||||
Simple mouse clicks allow you to tunnel down into directories, or rise up the file system.
|
||||
You can create/edit comments and choose whether the _xattr_ or _database_ version of the comments take priority,
|
||||
The <code>**dirnotes**</code> app is a GUI app, using the Qt5 framework.
|
||||
At startup, it displays the contents of the current directory, and the
|
||||
comments associated with any of the files or directories.
|
||||
Simple mouse clicks allow you to add or edit comments, tunnel down
|
||||
into directories, or rise up the file system.
|
||||
You can copy or move files (_with_ comments), and
|
||||
choose whether the _xattr_ or _database_ version of the comments
|
||||
have display priority.
|
||||
|
||||
The <code>**dirnotes-tui**</code> is a very similar app, but uses the _curses_ framework to display its activity in a terminal window. This can be handy if you have to work across a network, or if terminal apps are you preference.
|
||||
The <code>**dirnotes-tui**</code> is a very similar app, but uses the
|
||||
_curses_ framework to display its activity in a terminal window.
|
||||
This can be handy if you have to work across a network,
|
||||
or if terminal apps are your preference.
|
||||
|
||||
The <code>**dirnotes-cli**</code> is a command line tool, which may be handy for scripting.
|
||||
The <code>**dirnotes-cli**</code> is a command line tool,
|
||||
which may be handy for scripting. This all can also do maintenance on the database.
|
||||
|
||||
## USAGE
|
||||
|
||||
@@ -40,38 +50,47 @@ _s_ for sort, _M_ to change between xattr/database priority.
|
||||
|
||||
The **<code>dirnotes-cli</code>** has options for _-l_ list and _-c_ create a comment.
|
||||
|
||||
All three apps in the **dirnotes** family have the ability to copy files from the current directory.
|
||||
All three apps in the **dirnotes** family have the ability to
|
||||
copy/move files from the current directory, keeping the comments intact.
|
||||
All three apps have the **-h** option which shows command line usage.
|
||||
|
||||
## INSTALLATION
|
||||
|
||||
Each of the 3 apps in the family is self contained.
|
||||
The <code>**dirnotes**</code> app requires _Python3_ and the _Qt5_ framework.
|
||||
The <code>**dirnotes-tui**</code> and <code>**dirnotes-cli**</code> apps simply require _Python3_.
|
||||
The <code>**dirnotes-tui**</code> and <code>**dirnotes-cli**</code> apps
|
||||
simply require _Python3_.
|
||||
|
||||
Simply copy the file into your path, to ~/.local/bin for example.
|
||||
For a better GUI experience, copy
|
||||
<code>dirnotes.desktop</code> to <code>~/.local/share/applications</code> and
|
||||
<code>dirnotes.xpm</code> to <code>~/.local/share/icons/</code>
|
||||
|
||||
### CONFIG FILE
|
||||
|
||||
By default, the file **~/.dirnotes.conf** will be used to load the user's config.
|
||||
By default, the file **~/.config/dirnotes/dirnotes.conf** will be used to
|
||||
load the user's config.
|
||||
This is a JSON file, with three attributes that are important:
|
||||
|
||||
> * xattr_tag (default: <code>usr.xdg.comment</code>)
|
||||
> * database (default: <code>~/.dirnotes.db</code>, sensible alt: <code>/var/lib/dirnotes.db</code>)
|
||||
> * start_mode (_xattr_ or _db_ priority)
|
||||
> * xattr_tag (default: <code>usrr.xdg.comment</code>)
|
||||
> * database (default: <code>~/.local/share/dirnotes/dirnotes.db</code>, sensible alt: <code>/var/lib/dirnotes.db</code>)
|
||||
> * start_mode (_xattr_ or _db_ display priority)
|
||||
|
||||
The _config_file_ should be auto-generated the first time one of the **dirnotes** apps is run.
|
||||
[_not fully implemented_]
|
||||
|
||||
## LIMITATIONS
|
||||
|
||||
|
||||
The file comments are located in two locations: a database, and in the
|
||||
xattr properties of the file. Each of these storage locations has its
|
||||
own benefits and limitations. These can be summed up: **_xattr_** comments
|
||||
follow the iNode, **_database_** comments follow the file name.
|
||||
|
||||
|
||||
### xattr
|
||||
|
||||
Comments stored in the xattr properties can be copied/moved with the file, if you
|
||||
use the correct options: <code>**cp -p**</code>. The <code>**mv**</code> utility
|
||||
use the correct options: <code>**cp -p _src dest_**</code>.
|
||||
The <code>**mv**</code> utility
|
||||
automatically preserves _xattr_. Other programs can also be coerced into
|
||||
perserving _xattr_ properties:
|
||||
|
||||
@@ -81,8 +100,11 @@ perserving _xattr_ properties:
|
||||
|
||||
Not all file systems support xattr properties (vfat/exfat does not).
|
||||
|
||||
_xattr_ comments may only be applied to files for which the user has _write_ permission.
|
||||
|
||||
The current implementation of <code>**sshfs**</code> and <code>**scp**</code>
|
||||
do not support the copy of _xattr_ properties.
|
||||
do not support copying of _xattr_ properties. **Dropbox** type mounts are
|
||||
unlikely to support _xattr_ comments.
|
||||
If you want to copy files to a remote machine and include the _xattr_ comments, use <code>**rsync**</code> with the _-X_ option. Or <code>**tar**</code>.
|
||||
|
||||
Some editing apps (like _vim_) will create a new file when saving the data, which orphans the _xattr_ comments. For these apps, use the _database_ system.
|
||||
@@ -91,23 +113,30 @@ Removable disk devices (usb sticks) which are formatted with a Linux-based files
|
||||
|
||||
## database
|
||||
|
||||
Comments stored in the database work for all filesystem types (including vfat/exfat/sshfs)
|
||||
Comments stored in the database work for all filesystem types
|
||||
(including vfat/exfat/sshfs)
|
||||
|
||||
Comments are personalized to the _current user_.
|
||||
Another user on the same system will not see these comments.
|
||||
The _database_ comments that are stored in
|
||||
<code>~/.local/share/dirnotes/dirnotes.db</code> are inherently associated
|
||||
with a single user. If the _database_ is located in
|
||||
<code>/var/lib/dirnotes.db</code>, it can be shared by all the users in the system.
|
||||
|
||||
Files are indexed by their complete path name. Removable filesystems should be
|
||||
mounted in a consistent way, so that the complete path name is reproducable.
|
||||
mounted in a consistent way, so that the complete path name is reproducable.
|
||||
Symlinks are _not_
|
||||
dereferenced, so they may have comments bound to them.
|
||||
|
||||
Comments stored in the database do not travel with the files when
|
||||
they are moved or copied, unless using the **dirnotes** family of tools.
|
||||
|
||||
The _database_ comments that are stored in <code>~/.dirnotes.db</code> are inherently associated with a single user. If the _database_ is located in <code>/var/lib/dirnotes.db</code>, it is shared by all the users in the system. The comment with the 'most recent timestamp' wins.
|
||||
_Database_ comments may be applied to any visible file, _even if they are readonly_.
|
||||
For exmple, comments may be attached to the files in <code>/usr/bin/\*</code> even though they are probably owned by _root_.
|
||||
|
||||
## PROGRAMMER NOTES
|
||||
|
||||
Instead of an API, here is how you can get directly at the underlying comment data.
|
||||
If you intend to use the **dirnotes** apps, try to keep the two versions of the comments in sync.
|
||||
If you intend to use the **dirnotes** apps,
|
||||
try to keep the two versions of the comments in sync.
|
||||
|
||||
* xattr
|
||||
|
||||
@@ -122,11 +151,14 @@ to display the comments/author/date on a file. For example:
|
||||
user.xdg.comment.author: patb
|
||||
user.xdg.comment.date: 2022-09-29 08:07:42
|
||||
|
||||
The other options on the **xattr** command line tool allow you to write (*xattr -w*) or delete (*xattr -d*) the comments.
|
||||
The other options on the **xattr** command line tool allow you to
|
||||
write (*xattr -w*) or delete (*xattr -d*) the comments.
|
||||
|
||||
* database
|
||||
|
||||
The comments are stored in an Sqlite3 database, usually located at "~/.dirnotes.db". The database itself is contained within that file, and its schema is this:
|
||||
The comments are stored in an Sqlite3 database, usually
|
||||
located at "~/.local/share/dirnotes/dirnotes.db".
|
||||
The database itself is contained within that file, and its schema is this:
|
||||
|
||||
~~~~
|
||||
CREATE TABLE dirnotes (name TEXT, date DATETIME, size INTEGER, comment TEXT, comment_date DATETIME, author TEXT)
|
||||
@@ -143,9 +175,12 @@ The comments are stored in an Sqlite3 database, usually located at "~/.dirnotes.
|
||||
|author | the system name of the user who created the comment | patb |
|
||||
|
||||
|
||||
The _date_ and _size_ fields reflect the file's modification date and size at the time of the last edit of the file comment, which is stored in _comment_date_.
|
||||
The _date_ and _size_ fields reflect the file's modification date and size
|
||||
at the time of the last edit of the file comment, which is stored in _comment_date_.
|
||||
|
||||
As comments are editted or appended, new records are added to the database. Older records are are not purged. This gives you a history of the comments, but it means that fetching the most recent comment involves something like
|
||||
As comments are editted or appended, new records are added to the database.
|
||||
Older records are are not purged. This gives you a history of the comments,
|
||||
but it means that fetching the most recent comment involves something like
|
||||
|
||||
~~~~
|
||||
SELECT * FROM dirnotes WHERE name=? ORDER BY comment_date DESC
|
||||
@@ -157,10 +192,24 @@ The database is created the first time one of the **dirnotes** apps is run.
|
||||
|
||||
* misc
|
||||
|
||||
The <code>**dirnotes**</code> gui app has a desktop icon built into the code. There is not need for an external .icon file.
|
||||
The <code>**dirnotes**</code> gui app has a desktop icon built into the code.
|
||||
There is not need for an external .icon file, but there is an .xpm file included
|
||||
in the project, which can be copied to ~/.local/share/icons/
|
||||
|
||||
### comment date & author
|
||||
|
||||
The <code>copy()/move()</code> methods that are built into the **dirnotes** library
|
||||
will ask the operating system to copy/move the file _with_ xattr intact.
|
||||
The entry in the database is created _at the time of invocation_.
|
||||
Therefore, the xattrs will reflect the original author+date on the comments,
|
||||
whereas the database version is updated on each copy/move;
|
||||
the dirnotes-comments details will therefor diverge over time.
|
||||
|
||||
There was _no_ consideration given for language translation. Email [me](mail:patb@pbeirne.com) if you want this, or can help.
|
||||
|
||||
All these apps only accomadate a single line comment. An embedded newline will
|
||||
cause unpredictable behaviour.
|
||||
|
||||
### MacOS {#macos}
|
||||
|
||||
The **MacOS** inherently supports file comments. The Finder app manages most of the user activity. It handles file comments in a similar manner to **Dirnotes**. Comments are stored in two places:
|
||||
@@ -192,4 +241,18 @@ the three apps. And there _may_ be some inconsistency.
|
||||
The _qt-gui_ app is working pretty well.
|
||||
|
||||
|
||||
QUESTIONS:
|
||||
|
||||
There are several open-ended questions that need to be answered.
|
||||
Does anyone have an opinion?
|
||||
|
||||
1. How important is multi-line comments?
|
||||
|
||||
2. Is it ok to put the config file and database file buried in ~/.config and ~/.local?
|
||||
|
||||
These directories exist on computers with a gui/windowing system installed, but don't neccessarily exist on headless servers. Perhaps the default locations should be in the user directory? (~/.dirnotes.conf and ~/.dirnotes.db)
|
||||
|
||||
3. Who needs translations?
|
||||
|
||||
4. Does anybody have a better edit-window for CURSES?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user