redhog / InfiniteGlass

Window manager with infinite desktop, infinite zoom and infinite window resolution
https://redhog.github.io/InfiniteGlass/
GNU General Public License v3.0
35 stars 5 forks source link

Creating a global settings application #60

Open IanTrudel opened 4 years ago

IanTrudel commented 4 years ago

A global settings application written in Python and Tkinker should be a sound proposition. How would you go about to use InfiniteGlass libraries to properly interface the application with the window manager?

redhog commented 4 years ago

Okay so this wouldn't be too hard: Nearly everything is done using window properties, and a small number of things are done using ClientMessage:s.

The sources for the command-line interface glass-action should be a good place to start. It uses the InfiniteGlass python library, which is actually just a thin wrapper on top of python-xlib.

There are also some documentation, but it's far from complete.

For a settings app, I guess you mostly need to have it change the config files, then reload one of the components (the only one that can't be restarted is glass-ghosts, but it could be made to be able to reload its config file). For this, there is good example code in glass-action.

Is this something you'd like to experiment with?

redhog commented 4 years ago

Btw, I'd recommend playing around with glass-action, starting with

glass-action --help
redhog commented 4 years ago

Related tickets: https://github.com/redhog/InfiniteGlass/issues/59 https://github.com/redhog/InfiniteGlass/issues/55

IanTrudel commented 4 years ago

Yes, I'd like to experiment with this. Exploring the source has been interesting but there are still too many things I don't know yet. Just trying to find ways to contribute...

Does glass-action have code to save and restore an application? An important feature to learn how to do!

redhog commented 4 years ago

Only sort of. It has a method to send any message to a window, which is what's used to sleep it.

glass-action send --window windowid --mask StructureNotifyMask IG_SLEEP
IanTrudel commented 4 years ago

How would I tell the settings application how to save its state? You had mentioned before about pysmlib or something.

redhog commented 4 years ago

There are two ways that an app can be made to save/restore state:

The proper way: Use pysml to implement a pysmlib client. There's an example here: https://github.com/redhog/InfiniteGlass/blob/master/pysmlib/clientest.py In addition to what that code does, you need to take the client_id and stick it in a property SM_CLIENT_ID on each window of the app. To make this work easily, you should probably run the pysmlib stuff in a separate thread. It is possible to handle both smlib and x events in parallell using poll(), but it's a bit hairy...

The hack: Use glass-session-wrapper. Your app needs only to take a directory path as a command line parameter to load its state from (if non-empty) and save its state there and exit when it receives SIGINT.

IanTrudel commented 4 years ago

Thanks! The proper way is simple enough. Though, today I will stick to finish the other window decorations animation to show you.

IanTrudel commented 4 years ago

We could use an ORM to deal with this problem. The following frameworks will work in Python and SQLite.

The idea would be to maintain information in a database instead of configuration files. A check would be performed on the YAML files at startup and insert changes in the database when necessary. Then, when a new version of InifiniteGlass is released and has a new schema, it will be possible to perform a migration (up or down, if downgrade) that will rework the YAML and thus ensuring that we do not mess up user configuration and that it is usable for new versions.

Django ORM (standalone) | SQLAlchemy | Pony ORM

redhog commented 2 years ago

Related to https://github.com/redhog/InfiniteGlass/issues/55