Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a global settings application #60

Open
IanTrudel opened this issue Mar 8, 2020 · 10 comments
Open

Creating a global settings application #60

IanTrudel opened this issue Mar 8, 2020 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@IanTrudel
Copy link
Collaborator

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
Copy link
Owner

redhog commented Mar 8, 2020

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
Copy link
Owner

redhog commented Mar 8, 2020

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

glass-action --help
  • it can do a bunch of stuff both to the data stored in ghosts.sqlite3, and to the running session and its apps and windows...

@redhog
Copy link
Owner

redhog commented Mar 8, 2020

Related tickets: #59 #55

@IanTrudel
Copy link
Collaborator Author

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
Copy link
Owner

redhog commented Mar 8, 2020

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
Copy link
Collaborator Author

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

@redhog
Copy link
Owner

redhog commented Mar 8, 2020

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
Copy link
Collaborator Author

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

@IanTrudel IanTrudel self-assigned this Mar 11, 2020
@IanTrudel
Copy link
Collaborator Author

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 redhog added the enhancement New feature or request label Aug 24, 2022
@redhog
Copy link
Owner

redhog commented Aug 24, 2022

Related to #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants