Home Forums Wiki Doc Install Extras Screenshots Source Code Projects Blog Users Groups Register
Glx-Dock / Cairo-Dock List of forums Technical discussions | Discussions techniques Best way to open file manager on middle click
The latest stable release is the *3.4.0* : How to install it here.
Note: We just switched from BZR to Git on Github! (only to host the code and your future pull requests)
Technical discussions | Discussions techniques

Subjects Author Language Messages Last message
[Locked] Best way to open file manager on middle click
brianw English 5 fabounet [Read]
07 May 2012 à 13:11

brianw, Thursday 03 May 2012 à 05:06


Subscription date : 25 April 2012
Messages : 270
I would like to add open folder using middle click for my applet and was wondering what you guys consider the best method using python as the applet programming language. I could not find any reference to the cairo_dock_fm_launch_uri, that seems to be used in the source code, under the dbus interface for extra plugins. Would an os.system call be advisable with either gvfs-open or xdg-open or would you advise to have the user set the file manager under the configuration and not open on middle click unless it is set?

Eduardo Mucelli, Thursday 03 May 2012 à 12:20


Subscription date : 05 August 2009
Messages : 285
I would definitely go with subprocess, instead of os.system, and xdg-open. Subprocess is intended to replace many modules/calls, e.g., os.system. And xdg-open is the Free Desktop Foundation standard and (theoretically) works across Linux desktop environments. Therefore, it would be something like:

import subprocess
subprocess.call(["xdg-open", "/home/directory/that/you/want/"])

brianw, Thursday 03 May 2012 à 15:16


Subscription date : 25 April 2012
Messages : 270
Thank you, that is what I was leaning towards (xdg-open) and appreciate the advice. I had forgotten about subprocess replacing system, thanks for the reminder. Works perfectly, at least on my system.

matttbe, Friday 04 May 2012 à 23:04


Subscription date : 24 January 2009
Messages : 12573
Another solution is maybe to directly use gldi with Python. But I guess it's a bit longer and harder... (-> http://wiki.python.org/moin/IntegratingPythonWithOtherLanguages ; e.g. with ctypes)
But I think xdg-open is here a better choice!

PS: thank you for testing our DBus API. Don't hesitate to report any ideas/bugs and share any applets

brianw, Saturday 05 May 2012 à 14:40


Subscription date : 25 April 2012
Messages : 270
Thanks mattbe, I took a quick look and it seems interesting. When I get time I may go through the tutorial.

One thing I like about doing this in python is that I am using multiprocessing to do a task in the background and use queues to communicate and python made that simple. Using queues made it simple to get real-time (or pretty close to it) updates from the background downloader and display that info on the icon. I took a quick look the other day at the C API and how it does the background tasks (like the documentation example talks about downloading a file) but I couldn't find anything on realtime progress and it talked about a 2 phase approach where the second phase which does the update does not occur until the first phase is complete (now I haven't looked into this much so it may be simple to implement). I wanted the updates as the background process was running and the queue ideology was easy to implement in python. I did have some trouble at the start trying to get a background daemon to run when my plugin was instantiated but I did get a solution figured out.

Right now I am almost done my YoutubeDl plugin. I am just cleaning up some error checking and need to finish just a few things. Then I need to comment the code and write up the readme and applet handbook.

fabounet, Monday 07 May 2012 à 13:11


Subscription date : 30 November 2007
Messages : 17118
the C API also allows you to do backgroung task (with a CairoTask)
indeed you have 2 phases : the one in a thread that get the data, and the one in the main loop that update the icon (drawing).
and to get refresh periodically, you just say the interval of time you want to execute the task.

but you're right, it's generally so much easier to do things in Python than in C that's why we made the CDApplet Python class.

Technical discussions | Discussions techniques

Subjects Author Language Messages Last message
[Locked] Best way to open file manager on middle click
brianw English 5 fabounet [Read]
07 May 2012 à 13:11


Glx-Dock / Cairo-Dock List of forums Technical discussions | Discussions techniques Best way to open file manager on middle click Top

Online users :

Powered by ElementSpeak © 2007 Adrien Pilleboue, 2009-2013 Matthieu Baerts.
Dock based on CSS Dock Menu (Ndesign) with jQuery. Icons by zgegball
Cairo-Dock is a free software under GNU-GPL3 licence. First stable version created by Fabounet.
Many thanks to TuxFamily for the web Hosting and Mav for the domain name.