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

Client to awesome communication #2

Open
Juul opened this issue Dec 8, 2017 · 2 comments
Open

Client to awesome communication #2

Juul opened this issue Dec 8, 2017 · 2 comments

Comments

@Juul
Copy link
Member

Juul commented Dec 8, 2017

An X client can set arbitrary properties on itself which are communicated to the X server and intercepted by the window manager.

For custom properties it is necessary to create the property using the InternAtom function and then the property can be set by the client using ChangeProperty.

The awesome lua API can be used to subscribe to property changes:

To be notified when a property of a client changed:

client.connect_signal("property::name", function(c)
    -- do something
end)

To be notified when a property of a specific client c changed:

c:connect_signal("property::name", function()
    -- do something
end)

from the awesome lua api docs

The xprop utility can be used to inspect the current properties of a client.

Here is a node-x11 example of a client creating and setting a custom property:

// ChangeProperty/GetProperty / PropertyChange event example

var x11 = require('../../lib');
var PropertyChange = x11.eventMask.PropertyChange;

x11.createClient(function(err, display) {
    var X = display.client;
    var root = display.screen[0].root;
    var wid = X.AllocID();
    X.CreateWindow(wid, root, 0, 0, 400, 300, 0, 0, 0, 0, { eventMask: PropertyChange });
    X.MapWindow(wid);

  var foo = "DAMN";

  X.InternAtom(false, foo, function(err, fooAtom) {
    if(err) {
      console.error(err);
      process.exit(1);
    }
    
   
    // mode: 0 replace, 1 prepend, 2 append
    // mode, wid, name, type, format, data
    X.ChangeProperty(0, wid, fooAtom, X.atoms.STRING, 8, 'Hello, NodeJS');
    var interval = setInterval(function() {
           X.ChangeProperty(0, wid, fooAtom, X.atoms.STRING, 8, 'Hello, NodeJS ' + new Date());
    }, 1000);

    X.on('event', function(ev) {
        X.GetProperty(0, wid, fooAtom, X.atoms.STRING, 0, 10000000, function(err, prop) {
            if (prop.type == X.atoms.STRING)
               prop.data = prop.data.toString();
            console.log(prop.data);
        }); 
    });
    X.on('end', function() {
        clearInterval(interval);
    });
  });
});

References

@Juul
Copy link
Member Author

Juul commented Dec 8, 2017

The plan is to let fread application change the update method for both their entire region but also for sub-regions and to completely turn off updates and trigger them manually, but there might be a better method than setting properties for triggering the manual updates.

@Juul
Copy link
Member Author

Juul commented Dec 8, 2017

There should be a way for awesome to set this properties on the behalf of applications. That way app developers can bundle a file with the preferred options for their app that are then picked up by awesome (in case they don't want the app to actually deal with the e-paper display in a more dynamic manner). Folks could also share these files for existing applications from the debian repository to make them work as well as possible without modification.

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

No branches or pull requests

1 participant