[opensuse] KDE and directories
I think I know the answer to this (and Google was no help), but I thought I would ask in case I messed something very obvious: Is it possible to have KDE run a program when you enter a directory? Say in Dolphin. We want to sense if the current directory contains a file with a specific name. If so, do something. The point is that it should be automatic. And it must be done for all directories. There is no name rule or pattern that can be used. We already register numerous file associations. So I explored https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-inf.... There is something about Non-regular files and inode/directory. But I just don't see how to use this to trigger running a program. Has anyone implemented this in such a general way? -- Roger Oberholtzer -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Op dinsdag 7 november 2017 10:03:33 CET schreef Roger Oberholtzer:
I think I know the answer to this (and Google was no help), but I thought I would ask in case I messed something very obvious:
Is it possible to have KDE run a program when you enter a directory? Say in Dolphin. We want to sense if the current directory contains a file with a specific name. If so, do something. The point is that it should be automatic. And it must be done for all directories. There is no name rule or pattern that can be used.
We already register numerous file associations. So I explored https://specifications.freedesktop.org/shared-mime-info-spec/shared-mime-inf o-spec-0.18.html. There is something about Non-regular files and inode/directory. But I just don't see how to use this to trigger running a program. Has anyone implemented this in such a general way?
yep, done that years ago to print tickets that were generated in html. I wrote a script that looped 12(?) times, ran it through cron every minute, hence generating a check, plus running another script, every 5 seconds.. The 1st script checked for presence of html files in a couple of folders, the 2nd converted the html files to ps, then sent it to the ticketprinter in case of box office sales. Of course all the files were (re)moved after succesful handling,. So, cron is your friend. -- Gertjan Lettink, a.k.a. Knurpht openSUSE Board Member openSUSE Forums Team -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Roger Oberholtzer wrote:
I think I know the answer to this (and Google was no help), but I thought I would ask in case I messed something very obvious:
Is it possible to have KDE run a program when you enter a directory? Say in Dolphin. We want to sense if the current directory contains a file with a specific name. If so, do something. The point is that it should be automatic. And it must be done for all directories. There is no name rule or pattern that can be used.
I presume entering means changing current working directory to <some directory>. Monitoring that sounds like a job for inotify - but I am not sure if changing current working directory is a filesystem event. How is the file created? It might be better to monitor all directories for a user and only look for that file being created or updated. -- Per Jessen, Zürich (7.1°C) http://www.cloudsuisse.com/ - your owncloud, hosted in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, Nov 7, 2017 at 11:59 AM, Per Jessen <per@computer.org> wrote:
Roger Oberholtzer wrote:
I think I know the answer to this (and Google was no help), but I thought I would ask in case I messed something very obvious:
Is it possible to have KDE run a program when you enter a directory? Say in Dolphin. We want to sense if the current directory contains a file with a specific name. If so, do something. The point is that it should be automatic. And it must be done for all directories. There is no name rule or pattern that can be used.
I presume entering means changing current working directory to <some directory>. Monitoring that sounds like a job for inotify - but I am not sure if changing current working directory is a filesystem event.
How is the file created? It might be better to monitor all directories for a user and only look for that file being created or updated.
The file is updated independent of this. It contains status information about the data in that directory. This status information should be used to update a map (Navit) to reflect the status of the data in that directory. It only applies to the current directory. So a cron job is not appropriate. It must be triggered by the user entering the directory. -- Roger Oberholtzer -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, 7 Nov 2017 12:29:20 +0100 Roger Oberholtzer <roger.oberholtzer@gmail.com> wrote:
On Tue, Nov 7, 2017 at 11:59 AM, Per Jessen <per@computer.org> wrote:
Roger Oberholtzer wrote:
I think I know the answer to this (and Google was no help), but I thought I would ask in case I messed something very obvious:
Is it possible to have KDE run a program when you enter a directory? Say in Dolphin. We want to sense if the current directory contains a file with a specific name. If so, do something. The point is that it should be automatic. And it must be done for all directories. There is no name rule or pattern that can be used.
I presume entering means changing current working directory to <some directory>. Monitoring that sounds like a job for inotify - but I am not sure if changing current working directory is a filesystem event.
How is the file created? It might be better to monitor all directories for a user and only look for that file being created or updated.
The file is updated independent of this. It contains status information about the data in that directory. This status information should be used to update a map (Navit) to reflect the status of the data in that directory. It only applies to the current directory. So a cron job is not appropriate. It must be triggered by the user entering the directory.
I think you need to do more analysis on your problem and come up with a different solution. As others have said, what do you mean by 'the user entering the directory'? Do you mean accessing one or more of the files in the directory? Or accessing a directory listing including metadata about the files? Or simply changing working directory, or what? If the former, what if somebody accesses a file without entering the directory (e.g. by providing a full path)? What if they access via a symlink or a hard link? Why can't you trust the processes to update the status information themselves? I'd be more tempted by a system that kept the data in directories to which the target processes had no access and then allowed them to access the data via a gatekeeper process that had greater access rights and which checked whether each process's requests were kosher and maybe logged them. But a search for 'linux how can i tell when a process accesses a file' (without quotes) turns up a few interesting links, such as https://unix.stackexchange.com/questions/18844/list-the-files-accessed-by-a-... HTH, Dave -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, Nov 7, 2017 at 12:58 PM, Dave Howorth <dave@howorth.org.uk> wrote:
As others have said, what do you mean by 'the user entering the directory'? Do you mean accessing one or more of the files in the directory? Or accessing a directory listing including metadata about the files? Or simply changing working directory, or what?
When the user navigates the file system with Dolphin, they can click on a directory. Dolphin then shows the contents of that directory.
From my POV, the user has entered the directory. I think Dolphin would refer to this as the current working directory. There is only one current working directory at a time. This has nothing to do with moving around in, say, bash. It is fully limited to Dolphin. This is why I am looking for a KDE solution. Accessing a file in a directory is not enough either.
If the former, what if somebody accesses a file without entering the directory (e.g. by providing a full path)? What if they access via a symlink or a hard link? Why can't you trust the processes to update the status information themselves?
It is not about accessing a file. It is about making the directory the current working directory.
I'd be more tempted by a system that kept the data in directories to which the target processes had no access and then allowed them to access the data via a gatekeeper process that had greater access rights and which checked whether each process's requests were kosher and maybe logged them.
If I could, via the Desktop, limit the action to a single directory and all it's sub-directories, I am happy. Like all directories in and including $HOME/data would be fine.
But a search for 'linux how can i tell when a process accesses a file' (without quotes) turns up a few interesting links, such as https://unix.stackexchange.com/questions/18844/list-the-files-accessed-by-a-...
I am considering alternative approaches. But one that keeps directories separate and self-contained is best. -- Roger Oberholtzer -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Roger Oberholtzer wrote:
On Tue, Nov 7, 2017 at 12:58 PM, Dave Howorth <dave@howorth.org.uk> wrote:
As others have said, what do you mean by 'the user entering the directory'? Do you mean accessing one or more of the files in the directory? Or accessing a directory listing including metadata about the files? Or simply changing working directory, or what?
When the user navigates the file system with Dolphin, they can click on a directory. Dolphin then shows the contents of that directory. From my POV, the user has entered the directory. I think Dolphin would refer to this as the current working directory.
Right.
There is only one current working directory at a time.
Multiple Dolphin processes with multiple tabs ? Background processes with that userid?
This has nothing to do with moving around in, say, bash. It is fully limited to Dolphin. This is why I am looking for a KDE solution.
Sorry, that was not clear to me. I don't think I can help with that.
It is not about accessing a file. It is about making the directory the current working directory.
Does switching tabs in Dolphin count as change the current working directory? The user might see it as that, but in fact nothing changes. -- Per Jessen, Zürich (7.7°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Roger Oberholtzer wrote:
On Tue, Nov 7, 2017 at 11:59 AM, Per Jessen <per@computer.org> wrote:
Roger Oberholtzer wrote:
I think I know the answer to this (and Google was no help), but I thought I would ask in case I messed something very obvious:
Is it possible to have KDE run a program when you enter a directory? Say in Dolphin. We want to sense if the current directory contains a file with a specific name. If so, do something. The point is that it should be automatic. And it must be done for all directories. There is no name rule or pattern that can be used.
I presume entering means changing current working directory to <some directory>. Monitoring that sounds like a job for inotify - but I am not sure if changing current working directory is a filesystem event.
How is the file created? It might be better to monitor all directories for a user and only look for that file being created or updated.
The file is updated independent of this. It contains status information about the data in that directory. This status information should be used to update a map (Navit) to reflect the status of the data in that directory. It only applies to the current directory.
"current directory" is a status for a process, a user likely has several processes, each with a current directory.
So a cron job is not appropriate. It must be triggered by the user entering the directory.
A user can enter a directory when e.g. a cronjob is started with his userid. Does that count too? -- Per Jessen, Zürich (7.6°C) http://www.dns24.ch/ - your free DNS host, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, Nov 7, 2017 at 1:23 PM, Per Jessen <per@computer.org> wrote:
"current directory" is a status for a process, a user likely has several processes, each with a current directory.
Exactly. And it is the Dolphin process that I am interested in. Whatever it has for the current directory is the one I am interested in. If there is more than one Dolphin, no problem. Whichever Dolphin you click in, the new current directory thing should trigger. The map always shows the status of the last directory for which you did this in any Dolphin. -- Roger Oberholtzer -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, 7 Nov 2017 14:37:10 +0100 Roger Oberholtzer <roger.oberholtzer@gmail.com> wrote:
On Tue, Nov 7, 2017 at 1:23 PM, Per Jessen <per@computer.org> wrote:
"current directory" is a status for a process, a user likely has several processes, each with a current directory.
Exactly. And it is the Dolphin process that I am interested in. Whatever it has for the current directory is the one I am interested in. If there is more than one Dolphin, no problem. Whichever Dolphin you click in, the new current directory thing should trigger. The map always shows the status of the last directory for which you did this in any Dolphin.
If it is specifically the relationship to Dolphin windows then you probably need to look at that particular program and perhaps customise it. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 07/11/17 17:28, Dave Howorth wrote:
On Tue, 7 Nov 2017 14:37:10 +0100 Roger Oberholtzer <roger.oberholtzer@gmail.com> wrote:
On Tue, Nov 7, 2017 at 1:23 PM, Per Jessen <per@computer.org> wrote:
"current directory" is a status for a process, a user likely has several processes, each with a current directory.
Exactly. And it is the Dolphin process that I am interested in. Whatever it has for the current directory is the one I am interested in. If there is more than one Dolphin, no problem. Whichever Dolphin you click in, the new current directory thing should trigger. The map always shows the status of the last directory for which you did this in any Dolphin.
If it is specifically the relationship to Dolphin windows then you probably need to look at that particular program and perhaps customise it.
Just a thought - when you traverse directories in Dolphin, the 'current directory', in addition to being visible in the Location Bar in both Editable and Breadcrumb mode, is prepended to the program name visible in the title bar, in its taskbar entry and potentially other places. So presumably KWin or some Plasma component is able to probe that information from somewhere in order to display it. There's also one way in which this idea falls down - when in Details view mode, there are pointed brackets at the beginning on each subdirectory listing to provide a tree-like view where, if you click such a bracket to display the contents of a subdirectory, the Location/title bar does NOT update. This behaviour can be disabled by going to Configure Dolphin > View Modes > Details and unchecking 'Expandable Folders'. gumb -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Wednesday, 8 November 2017 0:07:10 ACDT Roger Oberholtzer wrote:
On Tue, Nov 7, 2017 at 1:23 PM, Per Jessen <per@computer.org> wrote:
"current directory" is a status for a process, a user likely has several processes, each with a current directory.
Exactly. And it is the Dolphin process that I am interested in. Whatever it has for the current directory is the one I am interested in. If there is more than one Dolphin, no problem. Whichever Dolphin you click in, the new current directory thing should trigger. The map always shows the status of the last directory for which you did this in any Dolphin.
So you need to create a plug-in for Dolphin. Dolphin will (I assume) somehow expose that information via an API. You can use that to provide input to your program. I know nothing about how to create Dolphin plug-ins - I leave that as an exercise for the reader. :) -- ============================================================== Rodney Baker VK5ZTV rodney.baker@iinet.net.au CCNA #CSCO12880208 ============================================================== -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, Nov 7, 2017 at 10:44 PM, Rodney Baker <rodney.baker@iinet.net.au> wrote:
On Wednesday, 8 November 2017 0:07:10 ACDT Roger Oberholtzer wrote:
On Tue, Nov 7, 2017 at 1:23 PM, Per Jessen <per@computer.org> wrote:
"current directory" is a status for a process, a user likely has several processes, each with a current directory.
Exactly. And it is the Dolphin process that I am interested in. Whatever it has for the current directory is the one I am interested in. If there is more than one Dolphin, no problem. Whichever Dolphin you click in, the new current directory thing should trigger. The map always shows the status of the last directory for which you did this in any Dolphin.
So you need to create a plug-in for Dolphin. Dolphin will (I assume) somehow expose that information via an API. You can use that to provide input to your program. I know nothing about how to create Dolphin plug-ins - I leave that as an exercise for the reader. :)
I suspect a plugin might be the route. I just cannot believe that the type=inode/directory bits in a [Desktop Entry] cannot also be used. I really think it is a lack of clear documentation on this item more than a lack of functionality. I will keep exploring. -- Roger Oberholtzer -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Le 08/11/2017 à 10:33, Roger Oberholtzer a écrit :
I suspect a plugin might be the route.
I just noticed there is in the kde config panel, start and stop, back ground services, an entry for a service "folder survey" (sorry I see it in french "surveillant de dossier") that could help jdd -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Wednesday, 8 November 2017 20:57:00 ACDT jdd@dodin.xyz wrote:
Le 08/11/2017 à 10:33, Roger Oberholtzer a écrit :
I suspect a plugin might be the route.
I just noticed there is in the kde config panel, start and stop, back ground services, an entry for a service "folder survey" (sorry I see it in french "surveillant de dossier") that could help
jdd
That could be one of two things; the "Recent Document Updater", that monitors the Recent Documents folder for changes, or the "Search Folder Updater", taht allows auto updates of search folders. They're the closest that I can see in English (no direct translation). -- ============================================================== Rodney Baker VK5ZTV rodney.baker@iinet.net.au CCNA #CSCO12880208 ============================================================== -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
That could be one of two things; the "Recent Document Updater", that monitors the Recent Documents folder for changes, or the "Search Folder Updater", taht allows auto updates of search folders. They're the closest that I can see in English (no direct translation).
no, I think it's "directory watcher" jdd -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Wed, Nov 8, 2017 at 1:18 PM, jdd@dodin.xyz <jdd@dodin.org> wrote:
That could be one of two things; the "Recent Document Updater", that monitors the Recent Documents folder for changes, or the "Search Folder Updater", taht allows auto updates of search folders. They're the closest that I can see in English (no direct translation).
no, I think it's "directory watcher"
I think it monitors all directories (or a selection of them) waiting for changes. No single directory is the current one. Or at least not because of any user activity. -- Roger Oberholtzer -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (7)
-
Dave Howorth
-
gumb
-
jdd@dodin.xyz
-
Knurpht - Gertjan Lettink
-
Per Jessen
-
Rodney Baker
-
Roger Oberholtzer